Skip to content

Commit

Permalink
Use library GH keychain instead of our own
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Vašek <[email protected]>
  • Loading branch information
matejvasek committed Dec 18, 2024
1 parent 770949b commit cad3409
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions hack/update-builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cad3409

Please sign in to comment.