From e72b1dc7d116444dabea49bccccbb15d3f9002d4 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 22 Oct 2024 12:04:58 -0500 Subject: [PATCH] google/externalaccount: return error messages from file cred opening subjectToken function now return error messages when failing to open file credentials. This will allow distinguishing between file not found and other errors. --- google/externalaccount/filecredsource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/externalaccount/filecredsource.go b/google/externalaccount/filecredsource.go index 33766b972..cdd28b45f 100644 --- a/google/externalaccount/filecredsource.go +++ b/google/externalaccount/filecredsource.go @@ -26,7 +26,7 @@ func (cs fileCredentialSource) credentialSourceType() string { func (cs fileCredentialSource) subjectToken() (string, error) { tokenFile, err := os.Open(cs.File) if err != nil { - return "", fmt.Errorf("oauth2/google/externalaccount: failed to open credential file %q", cs.File) + return "", fmt.Errorf("oauth2/google/externalaccount: failed to open credential file %q due to %v", cs.File, err) } defer tokenFile.Close() tokenBytes, err := ioutil.ReadAll(io.LimitReader(tokenFile, 1<<20))