From 3ab51622f8f7c6982a5e78ae9644675659318e7b Mon Sep 17 00:00:00 2001 From: Patrick Jones Date: Tue, 12 Jan 2021 11:44:53 -0800 Subject: [PATCH] Fixed Tyler's nits Change-Id: I2dc28d4f427509b3e62eeb9f14b1583178812038 --- google/google.go | 2 +- google/internal/externalaccount/basecredentials_test.go | 2 +- google/internal/externalaccount/filecredsource.go | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/google/google.go b/google/google.go index a7cc83bdb..e24749199 100644 --- a/google/google.go +++ b/google/google.go @@ -9,13 +9,13 @@ import ( "encoding/json" "errors" "fmt" - "golang.org/x/oauth2/google/internal/externalaccount" "net/url" "strings" "time" "cloud.google.com/go/compute/metadata" "golang.org/x/oauth2" + "golang.org/x/oauth2/google/internal/externalaccount" "golang.org/x/oauth2/jwt" ) diff --git a/google/internal/externalaccount/basecredentials_test.go b/google/internal/externalaccount/basecredentials_test.go index b7c143fce..7ec12e4d5 100644 --- a/google/internal/externalaccount/basecredentials_test.go +++ b/google/internal/externalaccount/basecredentials_test.go @@ -39,7 +39,7 @@ var ( testNow = func() time.Time { return time.Unix(expiry, 0) } ) -func TestToken_Func(t *testing.T) { +func TestToken(t *testing.T) { targetServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if got, want := r.URL.String(), "/"; got != want { diff --git a/google/internal/externalaccount/filecredsource.go b/google/internal/externalaccount/filecredsource.go index 9d895a06e..e953ddb47 100644 --- a/google/internal/externalaccount/filecredsource.go +++ b/google/internal/externalaccount/filecredsource.go @@ -30,7 +30,6 @@ func (cs fileCredentialSource) subjectToken() (string, error) { return "", fmt.Errorf("oauth2/google: failed to read credential file: %v", err) } tokenBytes = bytes.TrimSpace(tokenBytes) - var output string switch cs.Format.Type { case "json": jsonData := make(map[string]interface{}) @@ -46,15 +45,13 @@ func (cs fileCredentialSource) subjectToken() (string, error) { if !ok { return "", errors.New("oauth2/google: improperly formatted subject token") } - output = token + return token, nil case "text": - output = string(tokenBytes) + return string(tokenBytes), nil case "": - output = string(tokenBytes) + return string(tokenBytes), nil default: return "", errors.New("oauth2/google: invalid credential_source file format type") } - return output, nil - }