-
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
Conversation
1. Use the `DefaultRegistryClientOpts` which is a superset of what we use now, but sets `User-Agent`, 2. Pre-allocate the `toSign` array to have space for at least the number of images passed in (only more if recursive), 3. Use `Digest` to access the initial hash, which saves a `remote.Get` when we're passed a digest and non-recursive (at the cost of two requests when we are passed a tag in recursive mode), 4. Change the way we iterate over `toSign` to be conventional (not sure why we were doing it the other way before, but I'm guessing the two loops we now have were previously fused). Signed-off-by: Matt Moore <mattomata@gmail.com>
remote.WithAuthFromKeychain(authn.DefaultKeychain), | ||
remote.WithContext(ctx), | ||
} | ||
remoteOpts := DefaultRegistryClientOpts(ctx) |
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
|
||
var toSign []name.Digest | ||
toSign := make([]name.Digest, 0, len(imgs)) |
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.
unnecessary, but not worse than what exists. @jonjohnsonjr assures me that the number of recursive images is unbounded
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, didn't simplify this after refining the recursion
DefaultRegistryClientOpts
which is a superset of what we use now, but setsUser-Agent
,toSign
array to have space for at least the number of images passed in (only more if recursive),Digest
to access the initial hash, which saves aremote.Get
when we're passed a digest and non-recursive (at the cost of two requests when we are passed a tag in recursive mode),toSign
to be conventional (not sure why we were doing it the other way before, but I'm guessing the two loops we now have were previously fused).Signed-off-by: Matt Moore mattomata@gmail.com