diff --git a/auth/credentials/detect.go b/auth/credentials/detect.go index cfa0c88f8105..2d9a73edf365 100644 --- a/auth/credentials/detect.go +++ b/auth/credentials/detect.go @@ -76,7 +76,7 @@ func DetectDefault(opts *DetectOptions) (*auth.Credentials, error) { if err := opts.validate(); err != nil { return nil, err } - if opts.CredentialsJSON != nil { + if len(opts.CredentialsJSON) > 0 { return readCredentialsFileJSON(opts.CredentialsJSON, opts) } if opts.CredentialsFile != "" { diff --git a/auth/credentials/idtoken/idtoken.go b/auth/credentials/idtoken/idtoken.go index fc26505547e0..2c1ad6004aec 100644 --- a/auth/credentials/idtoken/idtoken.go +++ b/auth/credentials/idtoken/idtoken.go @@ -104,7 +104,7 @@ func NewCredentials(opts *Options) (*auth.Credentials, error) { } func (o *Options) jsonBytes() []byte { - if o.CredentialsJSON != nil { + if len(o.CredentialsJSON) > 0 { return o.CredentialsJSON } var fnOverride string diff --git a/auth/internal/transport/transport.go b/auth/internal/transport/transport.go index 2e2451c57645..718a6b171458 100644 --- a/auth/internal/transport/transport.go +++ b/auth/internal/transport/transport.go @@ -53,11 +53,11 @@ func CloneDetectOptions(oldDo *credentials.DetectOptions) *credentials.DetectOpt } // Smartly size this memory and copy below. - if oldDo.CredentialsJSON != nil { + if len(oldDo.CredentialsJSON) > 0 { newDo.CredentialsJSON = make([]byte, len(oldDo.CredentialsJSON)) copy(newDo.CredentialsJSON, oldDo.CredentialsJSON) } - if oldDo.Scopes != nil { + if len(oldDo.Scopes) > 0 { newDo.Scopes = make([]string, len(oldDo.Scopes)) copy(newDo.Scopes, oldDo.Scopes) }