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

Several cleanups to SignCmd #674

Merged
merged 1 commit into from
Sep 15, 2021
Merged

Conversation

mattmoor
Copy link
Member

  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

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)
Copy link
Member

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))
Copy link
Member

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 {
Copy link
Member

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

@dekkagaijin dekkagaijin merged commit 39a1a16 into sigstore:main Sep 15, 2021
@cpanato cpanato added this to the v1.3.0 milestone Sep 15, 2021
@mattmoor mattmoor deleted the cleanup-sign branch September 15, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants