From e99137b437692d40942db08e99ddd19e0aaf2326 Mon Sep 17 00:00:00 2001 From: Brad Wadsworth Date: Wed, 14 Sep 2022 10:29:01 -0500 Subject: [PATCH] Added ability to use access tokens for secret Signed-off-by: Brad Wadsworth --- pkg/clients/gke/gke.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/clients/gke/gke.go b/pkg/clients/gke/gke.go index f665986..4feac7d 100644 --- a/pkg/clients/gke/gke.go +++ b/pkg/clients/gke/gke.go @@ -39,14 +39,16 @@ var DefaultScopes = []string{ func WrapRESTConfig(ctx context.Context, rc *rest.Config, credentials []byte, scopes ...string) error { var ts oauth2.TokenSource if credentials != nil { - // CredentialsFromJSON creates a TokenSource that handles token caching. if isJSON(credentials) { + // If credentials are in a JSON format, extract the credential from the JSON + // CredentialsFromJSON creates a TokenSource that handles token caching. creds, err := google.CredentialsFromJSON(ctx, credentials, scopes...) if err != nil { return errors.Wrap(err, "cannot load Google Application Credentials from JSON") } ts = creds.TokenSource } else { + // if the credential not in a JSON format, treat the credential as an access token t := oauth2.Token{ AccessToken: string(credentials), }