Skip to content

Commit

Permalink
Drop ReplaceSignatures
Browse files Browse the repository at this point in the history
This doesn't do what it says it does. Instead, it duplicates all the
signatures. This is very confusing and almost certainly a mistake.

Signed-off-by: Jon Johnson <[email protected]>
  • Loading branch information
jonjohnsonjr committed Oct 11, 2023
1 parent 4c5669d commit 0ca6c05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 45 deletions.
18 changes: 3 additions & 15 deletions pkg/oci/mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,7 @@ func (si *signedImage) Attestations() (oci.Signatures, error) {
}
}
if si.so.ro != nil {
replace, err := si.so.ro.Replace(base, si.att)
if err != nil {
return nil, err
}
return ReplaceSignatures(replace)
return si.so.ro.Replace(base, si.att)
}
return AppendSignatures(base, si.att)
}
Expand Down Expand Up @@ -332,11 +328,7 @@ func (sii *signedImageIndex) Attestations() (oci.Signatures, error) {
}
}
if sii.so.ro != nil {
replace, err := sii.so.ro.Replace(base, sii.att)
if err != nil {
return nil, err
}
return ReplaceSignatures(replace)
return sii.so.ro.Replace(base, sii.att)
}
return AppendSignatures(base, sii.att)
}
Expand Down Expand Up @@ -437,11 +429,7 @@ func (si *signedUnknown) Attestations() (oci.Signatures, error) {
}
}
if si.so.ro != nil {
replace, err := si.so.ro.Replace(base, si.att)
if err != nil {
return nil, err
}
return ReplaceSignatures(replace)
return si.so.ro.Replace(base, si.att)
}
return AppendSignatures(base, si.att)
}
Expand Down
30 changes: 0 additions & 30 deletions pkg/oci/mutate/signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package mutate

import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/sigstore/cosign/v2/pkg/oci"
)
Expand Down Expand Up @@ -49,35 +48,6 @@ func AppendSignatures(base oci.Signatures, sigs ...oci.Signature) (oci.Signature
}, nil
}

// ReplaceSignatures produces a new oci.Signatures provided by the base signatures
// replaced with the new oci.Signatures.
func ReplaceSignatures(base oci.Signatures) (oci.Signatures, error) {
sigs, err := base.Get()
if err != nil {
return nil, err
}
adds := make([]mutate.Addendum, 0, len(sigs))
for _, sig := range sigs {
ann, err := sig.Annotations()
if err != nil {
return nil, err
}
adds = append(adds, mutate.Addendum{
Layer: sig,
Annotations: ann,
})
}
img, err := mutate.Append(empty.Image, adds...)
if err != nil {
return nil, err
}
return &sigAppender{
Image: img,
base: base,
sigs: sigs,
}, nil
}

type sigAppender struct {
v1.Image
base oci.Signatures
Expand Down

0 comments on commit 0ca6c05

Please sign in to comment.