Skip to content

Commit

Permalink
Re-exec gcloud token source when we refresh (#1017)
Browse files Browse the repository at this point in the history
Previously, this was storing a single exec.Command, but that gets
consumed when it gets Run, failing with:

exec: already started

This will re-exec the gcloud when needed.
  • Loading branch information
jonjohnsonjr committed May 13, 2021
1 parent 4c244d6 commit 21a2dc2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/v1/google/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewGcloudAuthenticator() (authn.Authenticator, error) {
return authn.Anonymous, nil
}

ts := gcloudSource{GetGcloudCmd()}
ts := gcloudSource{GetGcloudCmd}

// Attempt to fetch a token to ensure gcloud is installed and we can run it.
token, err := ts.Token()
Expand Down Expand Up @@ -145,12 +145,12 @@ type gcloudOutput struct {

type gcloudSource struct {
// This is passed in so that we mock out gcloud and test Token.
cmd *exec.Cmd
exec func() *exec.Cmd
}

// Token implements oauath2.TokenSource.
func (gs gcloudSource) Token() (*oauth2.Token, error) {
cmd := gs.cmd
cmd := gs.exec()
var out bytes.Buffer
cmd.Stdout = &out

Expand Down

0 comments on commit 21a2dc2

Please sign in to comment.