From cad340936e04ccee9d436e3afd0edaf2dbdc53cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Va=C5=A1ek?= Date: Wed, 18 Dec 2024 18:00:00 +0100 Subject: [PATCH] Use library GH keychain instead of our own MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej VaĊĦek --- hack/update-builder.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hack/update-builder.go b/hack/update-builder.go index ac52c4b30..b5129da1d 100644 --- a/hack/update-builder.go +++ b/hack/update-builder.go @@ -31,6 +31,7 @@ import ( docker "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" "github.com/google/go-containerregistry/pkg/authn" + ghAuth "github.com/google/go-containerregistry/pkg/authn/github" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/empty" "github.com/google/go-containerregistry/pkg/v1/mutate" @@ -737,19 +738,7 @@ func newGHClient(ctx context.Context) *github.Client { }))) } -var DefaultKeychain = authn.NewMultiKeychain(ghKeychain{}, authn.DefaultKeychain) - -type ghKeychain struct{} - -func (g ghKeychain) Resolve(resource authn.Resource) (authn.Authenticator, error) { - if resource.RegistryStr() != "ghcr.io" { - return authn.Anonymous, nil - } - return &authn.Basic{ - Username: "gh-action", - Password: os.Getenv("GITHUB_TOKEN"), - }, nil -} +var DefaultKeychain = authn.NewMultiKeychain(ghAuth.Keychain, authn.DefaultKeychain) func dockerDaemonAuthStr(img string) (string, error) { ref, err := name.ParseReference(img)