Skip to content

Commit

Permalink
chore: Add conditional configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Glastra <[email protected]>
  • Loading branch information
matglas committed May 10, 2024
1 parent 4c21b2f commit 3539103
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 11 additions & 4 deletions attestation/material/material.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,17 @@ func (a *Attestor) Attest(ctx *attestation.AttestationContext) error {
func (a *Attestor) MarshalJSON() ([]byte, error) {
output := attestorJson{
Materials: a.materials,
Configuration: attestorConfiguration{
IncludeGlob: a.includeGlob,
ExcludeGlob: a.excludeGlob,
},
}

if a.includeGlob != "" || a.excludeGlob != "" {
config := attestorConfiguration{}

if a.includeGlob != "" {
config.IncludeGlob = a.includeGlob
}
if a.excludeGlob != "" {
config.ExcludeGlob = a.excludeGlob
}
}

return json.Marshal(output)
Expand Down
15 changes: 11 additions & 4 deletions attestation/product/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,17 @@ func (a *Attestor) Attest(ctx *attestation.AttestationContext) error {
func (a *Attestor) MarshalJSON() ([]byte, error) {
output := attestorJson{
Products: a.products,
Configuration: &attestorConfiguration{
IncludeGlob: a.includeGlob,
ExcludeGlob: a.excludeGlob,
},
}

if a.includeGlob != "" || a.excludeGlob != "" {
config := attestorConfiguration{}

if a.includeGlob != "" {
config.IncludeGlob = a.includeGlob
}
if a.excludeGlob != "" {
config.ExcludeGlob = a.excludeGlob
}
}

return json.Marshal(output)
Expand Down

0 comments on commit 3539103

Please sign in to comment.