Skip to content

Commit

Permalink
Merge pull request #12461 from sharifelgamal/gcp-svc-account
Browse files Browse the repository at this point in the history
Create GCP auth pull secret even if creds JSON is nil
  • Loading branch information
sharifelgamal authored Sep 14, 2021
2 parents 9f96701 + 5672d40 commit c0534a6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/addons/addons_gcpauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")

Expand Down

0 comments on commit c0534a6

Please sign in to comment.