-
Notifications
You must be signed in to change notification settings - Fork 547
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
Several cleanups to SignCmd
#674
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ import ( | |
"path/filepath" | ||
"strings" | ||
|
||
"github.com/google/go-containerregistry/pkg/authn" | ||
"github.com/google/go-containerregistry/pkg/name" | ||
"github.com/google/go-containerregistry/pkg/v1/remote" | ||
"github.com/peterbourgon/ff/v3/ffcli" | ||
|
@@ -259,12 +258,9 @@ func SignCmd(ctx context.Context, ko KeyOpts, annotations map[string]interface{} | |
} | ||
} | ||
|
||
remoteOpts := []remote.Option{ | ||
remote.WithAuthFromKeychain(authn.DefaultKeychain), | ||
remote.WithContext(ctx), | ||
} | ||
remoteOpts := DefaultRegistryClientOpts(ctx) | ||
|
||
var toSign []name.Digest | ||
toSign := make([]name.Digest, 0, len(imgs)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary, but not worse than what exists. @jonjohnsonjr assures me that the number of recursive images is unbounded |
||
for _, inputImg := range imgs { | ||
|
||
// A key file or token is required unless we're in experimental mode! | ||
|
@@ -273,20 +269,24 @@ func SignCmd(ctx context.Context, ko KeyOpts, annotations map[string]interface{} | |
return fmt.Errorf("unable to resolve attachment %s for image %s", attachment, inputImg) | ||
} | ||
|
||
get, err := remote.Get(ref, remoteOpts...) | ||
h, err := Digest(ctx, ref) | ||
if err != nil { | ||
return errors.Wrap(err, "getting remote image") | ||
return errors.Wrap(err, "resolving digest") | ||
} | ||
toSign = append(toSign, ref.Context().Digest(h.String())) | ||
|
||
repo := ref.Context() | ||
toSign = append(toSign, repo.Digest(get.Digest.String())) | ||
|
||
if recursive && get.MediaType.IsIndex() { | ||
imgs, err := getTransitiveImages(get, repo, remoteOpts...) | ||
if recursive { | ||
get, err := remote.Get(ref, remoteOpts...) | ||
if err != nil { | ||
return err | ||
return errors.Wrap(err, "getting remote image") | ||
} | ||
if get.MediaType.IsIndex() { | ||
imgs, err := getTransitiveImages(get, ref.Context(), remoteOpts...) | ||
if err != nil { | ||
return err | ||
} | ||
toSign = append(toSign, imgs...) | ||
} | ||
toSign = append(toSign, imgs...) | ||
} | ||
} | ||
|
||
|
@@ -304,9 +304,7 @@ func SignCmd(ctx context.Context, ko KeyOpts, annotations map[string]interface{} | |
} | ||
} | ||
|
||
for len(toSign) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch, didn't simplify this after refining the recursion |
||
img := toSign[0] | ||
toSign = toSign[1:] | ||
for _, img := range toSign { | ||
// The payload can be specified via a flag to skip generation. | ||
payload := staticPayload | ||
if len(payload) == 0 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#669 :p