Merge pull request #12461 from sharifelgamal/gcp-svc-account

Create GCP auth pull secret even if creds JSON is nil
pull/12470/head
Sharif Elgamal 2021-09-14 08:38:53 -07:00 committed by GitHub
commit c0534a666c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -72,7 +72,7 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
// Grab credentials from where GCP would normally look
ctx := context.Background()
creds, err := google.FindDefaultCredentials(ctx)
if err != nil || creds.JSON == nil {
if err != nil {
if detect.IsCloudShell() {
if c := os.Getenv("CLOUDSDK_CONFIG"); c != "" {
f, err := ioutil.ReadFile(path.Join(c, "application_default_credentials.json"))
@ -98,6 +98,11 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
return nil
}
if creds.JSON == nil {
out.WarningT("You have authenicated with a service account that does not have an associated JSON. The GCP Auth requires credentials with a JSON file to in order to continue. The image pull secret has been imported.")
return nil
}
// Actually copy the creds over
f := assets.NewMemoryAssetTarget(creds.JSON, credentialsPath, "0444")