Skip to content

Commit

Permalink
Don't store signatures if there is none of them
Browse files Browse the repository at this point in the history
Currently, the copy command prints the message 'Storing signatures' and
calls the signature storing function, even if there are no signatures
present. This can mislead users and make them believe that there are
image signatures.

The proposed change modifies the copy function to print the message and
invoke the image storing function only if there is at least one signature.

Signed-off-by: Mike <mike.sul@foundries.io>
  • Loading branch information
mike-sul committed Jun 15, 2023
1 parent a3692d6 commit 8bbc9c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions copy/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ func (c *copier) copySingleImage(ctx context.Context, policyContext *signature.P
}
sigs = append(sigs, newSigs...)

c.Printf("Storing signatures\n")
if err := c.dest.PutSignaturesWithFormat(ctx, sigs, targetInstance); err != nil {
return nil, "", "", fmt.Errorf("writing signatures: %w", err)
if len(sigs) > 0 {
c.Printf("Storing signatures\n")
if err := c.dest.PutSignaturesWithFormat(ctx, sigs, targetInstance); err != nil {
return nil, "", "", fmt.Errorf("writing signatures: %w", err)
}
}

return manifestBytes, retManifestType, retManifestDigest, nil
Expand Down

0 comments on commit 8bbc9c4

Please sign in to comment.