Merge pull request #12461 from sharifelgamal/gcp-svc-account
Create GCP auth pull secret even if creds JSON is nilpull/12470/head
commit
c0534a666c
|
@ -72,7 +72,7 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
|
||||||
// Grab credentials from where GCP would normally look
|
// Grab credentials from where GCP would normally look
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
creds, err := google.FindDefaultCredentials(ctx)
|
creds, err := google.FindDefaultCredentials(ctx)
|
||||||
if err != nil || creds.JSON == nil {
|
if err != nil {
|
||||||
if detect.IsCloudShell() {
|
if detect.IsCloudShell() {
|
||||||
if c := os.Getenv("CLOUDSDK_CONFIG"); c != "" {
|
if c := os.Getenv("CLOUDSDK_CONFIG"); c != "" {
|
||||||
f, err := ioutil.ReadFile(path.Join(c, "application_default_credentials.json"))
|
f, err := ioutil.ReadFile(path.Join(c, "application_default_credentials.json"))
|
||||||
|
@ -98,6 +98,11 @@ func enableAddonGCPAuth(cfg *config.ClusterConfig) error {
|
||||||
return nil
|
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
|
// Actually copy the creds over
|
||||||
f := assets.NewMemoryAssetTarget(creds.JSON, credentialsPath, "0444")
|
f := assets.NewMemoryAssetTarget(creds.JSON, credentialsPath, "0444")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue