Skip to content

Commit ec74d14

Browse files
authored
Merge pull request #868 from saschagrunert/sign-recursive
Use recursive signing for multi-arch images
2 parents 38c86b3 + 40076eb commit ec74d14

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

internal/promoter/image/sign.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func (di *DefaultPromoterImplementation) SignImages(
114114
}
115115
signOpts.IdentityToken = token
116116

117+
// We want to sign all entities for multi-arch images
118+
signOpts.Recursive = true
119+
117120
// Creating a new Signer after setting the identity token is MANDATORY
118121
// because that's the only way to propagate the identity token to the
119122
// internal Signer structs. Without that, the identity token wouldn't be

internal/promoter/image/signcheck.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ func (di *DefaultPromoterImplementation) signReference(opts *options.Options, re
337337
return fmt.Errorf("generating identity token: %w", err)
338338
}
339339
signOpts.IdentityToken = token
340+
341+
// We want to sign all entities for multi-arch images
342+
signOpts.Recursive = true
343+
340344
di.signer = sign.New(signOpts)
341345

342346
// Add an annotation recording the kpromo version to ensure we

test-e2e/cip/e2e.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,11 @@ func removeSignatureLayers(snapshot *[]registry.Image) {
121121
var remove []image.Digest
122122
for i := range *snapshot {
123123
remove = []image.Digest{}
124-
for dgst := range (*snapshot)[i].Dmap {
125-
// Signature layers only have one tag
126-
if len((*snapshot)[i].Dmap[dgst]) != 1 || !strings.HasSuffix(
127-
string((*snapshot)[i].Dmap[dgst][0]), ".sig",
128-
) {
129-
continue
124+
for dgst, tags := range (*snapshot)[i].Dmap {
125+
if len(tags) == 0 || // Recursive signing may add additional layers without tags
126+
(len(tags) == 1 && strings.HasSuffix(string(tags[0]), ".sig")) { // Signature layers only have one tag
127+
remove = append(remove, dgst)
130128
}
131-
remove = append(remove, dgst)
132129
}
133130
for _, dgst := range remove {
134131
delete((*snapshot)[i].Dmap, dgst)
@@ -152,6 +149,7 @@ func checkSnapshot(
152149
// to compare them, we remove the signature layers from the current
153150
// snapshot to ensure the original images were promoted.
154151
removeSignatureLayers(&got)
152+
removeSignatureLayers(&expected)
155153

156154
diff := cmp.Diff(got, expected)
157155
if diff != "" {

0 commit comments

Comments
 (0)