From ad4fd2d0a8e0089c733f0745f8e8e1b047462001 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Mon, 14 Jul 2025 21:49:16 +0200 Subject: [PATCH] feat(dagger): add annotations support Signed-off-by: Miguel Martinez --- extras/dagger/main.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/extras/dagger/main.go b/extras/dagger/main.go index 0addc2bbf..8a3bb1c5a 100644 --- a/extras/dagger/main.go +++ b/extras/dagger/main.go @@ -244,6 +244,10 @@ func (att *Attestation) AddRawEvidence( // if not provided it will either be loaded from the contract or inferred automatically // +optional kind string, + // List of annotations to be attached to the evidence for example: + // "key1=value1,key2=value2" + // +optional + annotations []string, ) (*Attestation, error) { args := []string{ "attestation", "add", @@ -263,6 +267,12 @@ func (att *Attestation) AddRawEvidence( ) } + for _, annotation := range annotations { + args = append(args, + "--annotation", annotation, + ) + } + _, err := att. Container(0). WithExec(args, execOpts). @@ -284,6 +294,10 @@ func (att *Attestation) AddFileEvidence( // if not provided it will either be loaded from the contract or inferred automatically // +optional kind string, + // List of annotations to be attached to the evidence for example: + // "key1=value1,key2=value2" + // +optional + annotations []string, ) (*Attestation, error) { filename, err := path.Name(ctx) if err != nil { @@ -298,6 +312,12 @@ func (att *Attestation) AddFileEvidence( "--value", mountPath, } + for _, annotation := range annotations { + args = append(args, + "--annotation", annotation, + ) + } + if kind != "" { args = append(args, "--kind", kind, @@ -412,6 +432,10 @@ func (att *Attestation) Push( // Output format // +default="table" format OutputFormat, + // List of annotations to be attached to the attestation for example: + // "key1=value1,key2=value2" + // +optional + annotations []string, ) (string, error) { container := att.Container(0) args := []string{ @@ -420,6 +444,10 @@ func (att *Attestation) Push( "--output", string(format), } + for _, annotation := range annotations { + args = append(args, "--annotation", annotation) + } + if key != nil { container = container.WithMountedSecret("/tmp/key.pem", key) args = append(args, "--key", "/tmp/key.pem")