Skip to content

Commit f8af9c7

Browse files
authored
fix(dagger): stop caching attestation functions across runs (#3468)
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
1 parent 85af496 commit f8af9c7

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎extras/dagger/main.go‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ type ParentCIContext struct {
133133
}
134134

135135
// Initialize a new attestation
136+
//
137+
// Cached only for the session: a new attestation must be initialized on every run,
138+
// reusing a cached attestation ID from a previous run fails once that attestation is gone
139+
//
140+
// +cache="session"
136141
func (m *Chainloop) Init(
137142
ctx context.Context,
138143
// Chainloop API token
@@ -341,6 +346,8 @@ func (m *Chainloop) Resume(
341346
}
342347

343348
// Check the attestation status
349+
//
350+
// +cache="session"
344351
func (att *Attestation) Status(ctx context.Context) (string, error) {
345352
return att.
346353
Container(0).
@@ -419,6 +426,8 @@ func (m *Chainloop) WithInstance(
419426
}
420427

421428
// Add a raw string piece of evidence to the attestation
429+
//
430+
// +cache="session"
422431
func (att *Attestation) AddRawEvidence(
423432
ctx context.Context,
424433
// Evidence name. Don't pass a name if the material
@@ -483,6 +492,8 @@ func (att *Attestation) AddRawEvidence(
483492
}
484493

485494
// Add a file type piece of evidence to the attestation
495+
//
496+
// +cache="session"
486497
func (att *Attestation) AddFileEvidence(
487498
ctx context.Context,
488499
// Evidence name. Don't pass a name if the material
@@ -556,6 +567,7 @@ func (att *Attestation) AddFileEvidence(
556567
return att, err
557568
}
558569

570+
// +cache="session"
559571
func (att *Attestation) Debug() *dagger.Container {
560572
return att.Container(0).Terminal()
561573
}
@@ -684,6 +696,8 @@ func cliContainer(ttl int, token *dagger.Secret, instance InstanceInfo, parentCI
684696
}
685697

686698
// Build an ephemeral container with everything needed to process the attestation
699+
//
700+
// +cache="session"
687701
func (att *Attestation) Container(
688702
// Cache TTL for chainloop commands, in seconds
689703
// Defaults to 0: no caching
@@ -736,6 +750,8 @@ const (
736750
)
737751

738752
// Generate, sign and push the attestation to the chainloop control plane
753+
//
754+
// +cache="session"
739755
func (att *Attestation) Push(
740756
ctx context.Context,
741757
// The private key to sign the attestation
@@ -781,6 +797,8 @@ func (att *Attestation) Push(
781797
}
782798

783799
// Mark the attestation as failed
800+
//
801+
// +cache="session"
784802
func (att *Attestation) MarkFailed(
785803
ctx context.Context,
786804
// The reason for canceling, in human-readable form
@@ -791,6 +809,8 @@ func (att *Attestation) MarkFailed(
791809
}
792810

793811
// Mark the attestation as canceled
812+
//
813+
// +cache="session"
794814
func (att *Attestation) MarkCanceled(
795815
ctx context.Context,
796816
// The reason for canceling, in human-readable form
@@ -833,6 +853,8 @@ func (att *Attestation) reset(ctx context.Context,
833853
/// standalone API calls
834854

835855
// Create a new workflow
856+
//
857+
// +cache="session"
836858
func (m *Chainloop) WorkflowCreate(
837859
ctx context.Context,
838860
// Chainloop API token

0 commit comments

Comments
 (0)