diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-04 09:23:19 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-07-04 09:23:19 +0000 |
commit | d81ce8b25c50d96f47d6cdbcdfc3d1f66fca0f96 (patch) | |
tree | 471621cd53167e2e9b15239f25638fa33e684eb6 /qa | |
parent | 391710f29d1e82dafb3244691d541573a21acda2 (diff) | |
parent | 2a8d0b59a37be30e27255220b911c6d052ca48e1 (diff) | |
download | gitlab-ce-d81ce8b25c50d96f47d6cdbcdfc3d1f66fca0f96.tar.gz |
Merge branch 'qa-112-prefer-env-credentials-for-gcloud' into 'master'
Auto DevOps QA: Prefer gcloud credentials from env
See merge request gitlab-org/gitlab-ce!20338
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/runtime/env.rb | 4 | ||||
-rw-r--r-- | qa/qa/service/kubernetes_cluster.rb | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 2126ce6b234..7610c7f3f43 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -62,6 +62,10 @@ module QA def gcloud_zone ENV.fetch('GCLOUD_ZONE') end + + def has_gcloud_credentials? + %w[GCLOUD_ACCOUNT_KEY GCLOUD_ACCOUNT_EMAIL].none? { |var| ENV[var].to_s.empty? } + end end end end diff --git a/qa/qa/service/kubernetes_cluster.rb b/qa/qa/service/kubernetes_cluster.rb index 7627c8c7ad9..abd9d53554f 100644 --- a/qa/qa/service/kubernetes_cluster.rb +++ b/qa/qa/service/kubernetes_cluster.rb @@ -50,11 +50,15 @@ module QA end def login_if_not_already_logged_in - account = `gcloud auth list --filter=status:ACTIVE --format="value(account)"` - if account.empty? + if Runtime::Env.has_gcloud_credentials? attempt_login_with_env_vars else - puts "gcloud account found. Using: #{account} for creating K8s cluster." + account = `gcloud auth list --filter=status:ACTIVE --format="value(account)"` + if account.empty? + raise "Failed to login to gcloud. No credentials provided in environment and no credentials found locally." + else + puts "gcloud account found. Using: #{account} for creating K8s cluster." + end end end |