Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change signature annotation to version #797

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions internal/promoter/image/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"sigs.k8s.io/promo-tools/v3/promoter/image/ratelimit"
"sigs.k8s.io/promo-tools/v3/types/image"
"sigs.k8s.io/release-sdk/sign"
"sigs.k8s.io/release-utils/version"
)

const (
Expand Down Expand Up @@ -210,20 +211,10 @@ func (di *DefaultPromoterImplementation) signAndReplicate(signOpts *sign.Options
// Build the reference we will use
imageRef := edges[0].DstReference()

// Add all the references as annotations to ensure we
// get a 2nd signature, otherwise cosign will not resign
mirrorList := []string{}
for i := range edges {
mirrorList = append(
mirrorList, fmt.Sprintf(
"%s/%s",
edges[i].DstRegistry.Name,
edges[i].DstImageTag.Name,
),
)
}
// Add an annotation recording the kpromo version to ensure we
// get a 2nd signature, otherwise cosign will not resign a signed image:
signOpts.Annotations = map[string]interface{}{
"org.kubernetes.kpromo.mirrors": strings.Join(mirrorList, ","),
"org.kubernetes.kpromo.version": fmt.Sprintf("kpromo-%s", version.GetVersionInfo().GitVersion),
puerco marked this conversation as resolved.
Show resolved Hide resolved
}

logrus.Infof("Signing image %s", imageRef)
Expand Down
13 changes: 6 additions & 7 deletions internal/promoter/image/signcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
yaml "gopkg.in/yaml.v2"
"sigs.k8s.io/release-sdk/sign"
"sigs.k8s.io/release-utils/http"
"sigs.k8s.io/release-utils/version"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/crane"
Expand Down Expand Up @@ -327,12 +328,6 @@ func (di *DefaultPromoterImplementation) signReference(opts *options.Options, re
}
logrus.Infof(" signing %s", refString)

// Get the mirrors list
mirrorList, err := di.getMirrors()
if err != nil {
return fmt.Errorf("getting mirror list: %w", err)
}

// Options for the new signer
signOpts := sign.Default()

Expand All @@ -344,8 +339,12 @@ func (di *DefaultPromoterImplementation) signReference(opts *options.Options, re
signOpts.IdentityToken = token
di.signer = sign.New(signOpts)

// Add an annotation recording the kpromo version to ensure we
// get a 2nd signature, otherwise cosign will not resign a signed image:
signOpts.Annotations = map[string]interface{}{
"org.kubernetes.kpromo.mirrors": strings.Join(mirrorList, ","),
"org.kubernetes.kpromo.version": fmt.Sprintf(
"kpromo-%s", version.GetVersionInfo().GitVersion,
),
}

if _, err := di.signer.SignImageWithOptions(signOpts, refString); err != nil {
Expand Down