@@ -121,8 +121,12 @@ func (di *DefaultPromoterImplementation) SignImages(
121
121
// used at all and images would be signed with a wrong identity.
122
122
di .signer = sign .New (signOpts )
123
123
124
- // We only sign the first normalized image of each edge.
125
- sortedEdges := map [string ][]reg.PromotionEdge {}
124
+ // We only sign the first normalized image per digest of each edge.
125
+ type key struct {
126
+ identity string
127
+ digest image.Digest
128
+ }
129
+ sortedEdges := map [key ][]reg.PromotionEdge {}
126
130
for edge := range edges {
127
131
// Skip signing the signature, sbom and attestation layers
128
132
if strings .HasSuffix (string (edge .DstImageTag .Tag ), ".sig" ) ||
@@ -131,19 +135,19 @@ func (di *DefaultPromoterImplementation) SignImages(
131
135
continue
132
136
}
133
137
134
- identity := targetIdentity (& edge )
135
- if _ , ok := sortedEdges [identity ]; ! ok {
136
- sortedEdges [identity ] = []reg.PromotionEdge {}
138
+ k := key { identity : targetIdentity (& edge ), digest : edge . Digest }
139
+ if _ , ok := sortedEdges [k ]; ! ok {
140
+ sortedEdges [k ] = []reg.PromotionEdge {}
137
141
}
138
- sortedEdges [identity ] = append (sortedEdges [identity ], edge )
142
+ sortedEdges [k ] = append (sortedEdges [k ], edge )
139
143
}
140
144
141
145
t := throttler .New (opts .MaxSignatureOps , len (sortedEdges ))
142
146
// Sign the required edges
143
147
for d := range sortedEdges {
144
148
d := d
145
- go func (identity string ) {
146
- t .Done (di .signAndReplicate (signOpts , identity , sortedEdges [identity ]))
149
+ go func (k key ) {
150
+ t .Done (di .signAndReplicate (signOpts , k . identity , sortedEdges [k ]))
147
151
}(d )
148
152
if t .Throttle () > 0 {
149
153
break
0 commit comments