Skip to content

Commit 6f96bba

Browse files
authored
gcrane: Use page size of 10,000 for googley things (#1645)
We dropped down to 1000 for the sake of ECR, but that doesn't make much sense, really. Per https://cloud.google.com/artifact-registry/quotas#limits this will return up to 10k items.
1 parent 375fb61 commit 6f96bba

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

pkg/v1/google/keychain.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ type googleKeychain struct {
5353
// gcloud configuration in the scope of this one process.
5454
func (gk *googleKeychain) Resolve(target authn.Resource) (authn.Authenticator, error) {
5555
// Only authenticate GCR and AR so it works with authn.NewMultiKeychain to fallback.
56-
host := target.RegistryStr()
57-
if host != "gcr.io" &&
58-
!strings.HasSuffix(host, ".gcr.io") &&
59-
!strings.HasSuffix(host, ".pkg.dev") &&
60-
!strings.HasSuffix(host, ".google.com") {
56+
if !isGoogle(target.RegistryStr()) {
6157
return authn.Anonymous, nil
6258
}
6359

@@ -90,3 +86,10 @@ func resolve() authn.Authenticator {
9086
}
9187
return authn.Anonymous
9288
}
89+
90+
func isGoogle(host string) bool {
91+
return host == "gcr.io" ||
92+
strings.HasSuffix(host, ".gcr.io") ||
93+
strings.HasSuffix(host, ".pkg.dev") ||
94+
strings.HasSuffix(host, ".google.com")
95+
}

pkg/v1/google/list.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ func newLister(repo name.Repository, options ...Option) (*lister, error) {
8989

9090
func (l *lister) list(repo name.Repository) (*Tags, error) {
9191
uri := &url.URL{
92-
Scheme: repo.Registry.Scheme(),
93-
Host: repo.Registry.RegistryStr(),
94-
Path: fmt.Sprintf("/v2/%s/tags/list", repo.RepositoryStr()),
95-
// ECR returns an error if n > 1000:
96-
// https://github.com/google/go-containerregistry/issues/681
97-
RawQuery: "n=1000",
92+
Scheme: repo.Registry.Scheme(),
93+
Host: repo.Registry.RegistryStr(),
94+
Path: fmt.Sprintf("/v2/%s/tags/list", repo.RepositoryStr()),
95+
RawQuery: "n=10000",
96+
}
97+
98+
// ECR returns an error if n > 1000:
99+
// https://github.com/google/go-containerregistry/issues/681
100+
if !isGoogle(repo.RegistryStr()) {
101+
uri.RawQuery = "n=1000"
98102
}
99103

100104
tags := Tags{}

0 commit comments

Comments
 (0)