Skip to content

Commit

Permalink
Use gcrane.Keychain for not only crane-inherit commands but also gcra…
Browse files Browse the repository at this point in the history
…ne-specific commands. (#880)
  • Loading branch information
FGtatsuro committed Dec 21, 2020
1 parent 8b4c3b5 commit d29eb11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/gcrane/cmd/gc.go
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"log"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/gcrane"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/google"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -47,7 +47,7 @@ func gc(root string, recursive bool) {
log.Fatalln(err)
}

auth := google.WithAuthFromKeychain(authn.DefaultKeychain)
auth := google.WithAuthFromKeychain(gcrane.Keychain)

if recursive {
if err := google.Walk(repo, printUntaggedImages, auth); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/gcrane/cmd/list.go
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"log"

"github.com/google/go-containerregistry/pkg/gcrane"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/google"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -50,13 +51,13 @@ func ls(root string, recursive, j bool) {
}

if recursive {
if err := google.Walk(repo, printImages(j), google.WithAuthFromKeychain(google.Keychain)); err != nil {
if err := google.Walk(repo, printImages(j), google.WithAuthFromKeychain(gcrane.Keychain)); err != nil {
log.Fatalln(err)
}
return
}

tags, err := google.List(repo, google.WithAuthFromKeychain(google.Keychain))
tags, err := google.List(repo, google.WithAuthFromKeychain(gcrane.Keychain))
if err != nil {
log.Fatalln(err)
}
Expand Down

0 comments on commit d29eb11

Please sign in to comment.