Skip to content

Commit

Permalink
Only upload to the tlog once!
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Lorenc <dlorenc@google.com>
  • Loading branch information
Dan Lorenc authored and tekton-robot committed Aug 21, 2021
1 parent 98e6c21 commit 407e75f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/chains/rekor.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ func shouldUploadTlog(cfg config.Config, tr *v1beta1.TaskRun) bool {
if !cfg.Transparency.VerifyAnnotation {
return true
}

// Already uploaded, don't do it again
if _, ok := tr.Annotations[ChainsTransparencyAnnotation]; ok {
return false
}
// verify the annotation
for k, v := range tr.Annotations {
if k == RekorAnnotation && v == "true" {
Expand Down
9 changes: 9 additions & 0 deletions pkg/chains/rekor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ func TestShouldUploadTlog(t *testing.T) {
annotations: map[string]string{RekorAnnotation: "true"},
expected: true,
},
{
description: "already uploaded",
cfg: config.TransparencyConfig{
Enabled: true,
VerifyAnnotation: true,
},
annotations: map[string]string{ChainsTransparencyAnnotation: "foo"},
expected: false,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 407e75f

Please sign in to comment.