Skip to content

Commit

Permalink
authn/google: fall back to anonymous authn in case of gcloud binary…
Browse files Browse the repository at this point in the history
… missing (#405)

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and jonjohnsonjr committed Mar 20, 2019
1 parent 871d0d9 commit 148cd17
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/v1/google/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"os/exec"
"time"
Expand Down Expand Up @@ -58,6 +59,13 @@ func NewEnvAuthenticator() (authn.Authenticator, error) {
// NewGcloudAuthenticator returns an oauth2.TokenSource that generates access
// tokens by shelling out to the gcloud sdk.
func NewGcloudAuthenticator() (authn.Authenticator, error) {
if _, err := exec.LookPath("gcloud"); err != nil {
// TODO(#390): Use better logger.
// gcloud is not available, fall back to anonymous
log.Println("gcloud binary not found")
return authn.Anonymous, nil
}

ts := gcloudSource{GetGcloudCmd()}

// Attempt to fetch a token to ensure gcloud is installed and we can run it.
Expand Down

0 comments on commit 148cd17

Please sign in to comment.