Skip to content

Commit

Permalink
Fixed Tyler's nits
Browse files Browse the repository at this point in the history
Change-Id: I2dc28d4f427509b3e62eeb9f14b1583178812038
  • Loading branch information
gIthuriel committed Jan 12, 2021
1 parent 5e41ced commit 3ab5162
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion google/internal/externalaccount/basecredentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions google/internal/externalaccount/filecredsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand All @@ -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

}

0 comments on commit 3ab5162

Please sign in to comment.