Skip to content

Commit

Permalink
Return magic error for crane auth get (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr committed Jan 5, 2021
1 parent 02c0712 commit d1ffc8b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/crane/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ func NewCmdAuthGet(argv ...string) *cobra.Command {
if err != nil {
log.Fatal(err)
}

// If we don't find any credentials, there's a magic error to return:
//
// https://github.com/docker/docker-credential-helpers/blob/f78081d1f7fef6ad74ad6b79368de6348386e591/credentials/error.go#L4-L6
// https://github.com/docker/docker-credential-helpers/blob/f78081d1f7fef6ad74ad6b79368de6348386e591/credentials/credentials.go#L61-L63
if authorizer == authn.Anonymous {
fmt.Fprint(os.Stdout, "credentials not found in native keychain\n")
os.Exit(1)
}

auth, err := authorizer.Authorization()
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit d1ffc8b

Please sign in to comment.