From 3bc2aa6e2325ee901c967b157205a564fa313ac5 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Thu, 15 Dec 2022 16:24:20 +0000 Subject: [PATCH] result: change reason types to strings Signed-off-by: Justin Chadwell --- frontend/attestations/sbom/sbom.go | 2 +- solver/llbsolver/proc/provenance.go | 2 +- solver/result/attestation.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/attestations/sbom/sbom.go b/frontend/attestations/sbom/sbom.go index 54e8e316a2a2..4d86f74140bf 100644 --- a/frontend/attestations/sbom/sbom.go +++ b/frontend/attestations/sbom/sbom.go @@ -88,7 +88,7 @@ func CreateSBOMScanner(ctx context.Context, resolver llb.ImageMetaResolver, scan Kind: gatewaypb.AttestationKindBundle, Ref: stsbom, Metadata: map[string][]byte{ - result.AttestationReasonKey: result.AttestationReasonSBOM, + result.AttestationReasonKey: []byte(result.AttestationReasonSBOM), }, InToto: result.InTotoAttestation{ PredicateType: intoto.PredicateSPDX, diff --git a/solver/llbsolver/proc/provenance.go b/solver/llbsolver/proc/provenance.go index 4d8506b2987f..e1b6ed96ee6e 100644 --- a/solver/llbsolver/proc/provenance.go +++ b/solver/llbsolver/proc/provenance.go @@ -45,7 +45,7 @@ func ProvenanceProcessor(attrs map[string]string) llbsolver.Processor { res.AddAttestation(p.ID, llbsolver.Attestation{ Kind: gatewaypb.AttestationKindInToto, Metadata: map[string][]byte{ - result.AttestationReasonKey: result.AttestationReasonProvenance, + result.AttestationReasonKey: []byte(result.AttestationReasonProvenance), result.AttestationInlineOnlyKey: []byte(strconv.FormatBool(inlineOnly)), }, InToto: result.InTotoAttestation{ diff --git a/solver/result/attestation.go b/solver/result/attestation.go index 6fa8403db67c..450016ffab70 100644 --- a/solver/result/attestation.go +++ b/solver/result/attestation.go @@ -12,9 +12,9 @@ const ( AttestationInlineOnlyKey = "inline-only" ) -var ( - AttestationReasonSBOM = []byte("sbom") - AttestationReasonProvenance = []byte("provenance") +const ( + AttestationReasonSBOM = "sbom" + AttestationReasonProvenance = "provenance" ) type Attestation[T any] struct {