From 6c2bc272c44bab4091c5fe96031ef61bf2fc5d1c Mon Sep 17 00:00:00 2001 From: Ryan Kohler Date: Fri, 22 Apr 2022 10:45:22 -0700 Subject: [PATCH] Changes requested by @codyoss --- .../internal/externalaccount/executablecredsource.go | 10 +++------- .../externalaccount/executablecredsource_test.go | 4 ---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/google/internal/externalaccount/executablecredsource.go b/google/internal/externalaccount/executablecredsource.go index 0e5c11b..09dd7fb 100644 --- a/google/internal/externalaccount/executablecredsource.go +++ b/google/internal/externalaccount/executablecredsource.go @@ -15,6 +15,8 @@ import ( "time" ) +var serviceAccountImpersonationCompiler = regexp.MustCompile("https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/(.*@.*):generateAccessToken") + const ( executableSupportedMaxVersion = 1 defaultTimeout = 30 * time.Second @@ -57,7 +59,7 @@ func exitCodeError(exitCode int) error { } func executableError(err error) error { - return fmt.Errorf("oauth2/google: executable command failed: %v", err.Error()) + return fmt.Errorf("oauth2/google: executable command failed: %v", err) } func executablesDisallowedError() error { @@ -73,10 +75,6 @@ var runCommand = func(ctx context.Context, command string, env []string) ([]byte cmd.Env = env response, err := cmd.Output() - if ctx.Err() != nil { - return nil, ctx.Err() - } - if err == nil { return response, nil } @@ -201,8 +199,6 @@ func (cs executableCredentialSource) getEnvironment() []string { return result } -var serviceAccountImpersonationCompiler = regexp.MustCompile("https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/(.*@.*):generateAccessToken") - func (cs executableCredentialSource) getNewEnvironmentVariables() map[string]string { result := map[string]string{ "GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE": cs.config.Audience, diff --git a/google/internal/externalaccount/executablecredsource_test.go b/google/internal/externalaccount/executablecredsource_test.go index d935513..1d6f66e 100644 --- a/google/internal/externalaccount/executablecredsource_test.go +++ b/google/internal/externalaccount/executablecredsource_test.go @@ -28,10 +28,6 @@ func String(s string) *string { return &s } -var emptyEnv = func() []string { - return []string{} -} - func TestCreateExecutableCredential(t *testing.T) { ec := ExecutableConfig{ Command: "blarg",