Module: Gitlab::QA::Runtime::Env
Constant Summary collapse
- ENV_VARIABLES =
{ 'GITLAB_USERNAME' => :user_username, 'GITLAB_PASSWORD' => :user_password, 'GITLAB_LDAP_USERNAME' => :ldap_username, 'GITLAB_LDAP_PASSWORD' => :ldap_password, 'GITLAB_FORKER_USERNAME' => :forker_username, 'GITLAB_FORKER_PASSWORD' => :forker_password, 'GITLAB_USER_TYPE' => :user_type, 'GITLAB_SANDBOX_NAME' => :gitlab_sandbox_name, 'GITLAB_QA_ACCESS_TOKEN' => :qa_access_token, 'GITHUB_ACCESS_TOKEN' => :github_access_token, 'GITLAB_URL' => :gitlab_url, 'EE_LICENSE' => :ee_license, 'GCLOUD_ACCOUNT_EMAIL' => :gcloud_account_email, 'GCLOUD_ACCOUNT_KEY' => :gcloud_account_key, 'CLOUDSDK_CORE_PROJECT' => :cloudsdk_core_project, 'GCLOUD_ZONE' => :gcloud_zone }.freeze
Instance Method Summary collapse
- #dev_access_token_variable ⇒ Object
- #host_artifacts_dir ⇒ Object
- #qa_access_token ⇒ Object
- #require_kubernetes_environment! ⇒ Object
- #require_license! ⇒ Object
- #require_no_license! ⇒ Object
- #require_qa_access_token! ⇒ Object
- #run_id ⇒ Object
- #variables ⇒ Object
Instance Method Details
#dev_access_token_variable ⇒ Object
40 41 42 |
# File 'lib/gitlab/qa/runtime/env.rb', line 40 def dev_access_token_variable env_value_if_defined('GITLAB_QA_DEV_ACCESS_TOKEN') end |
#host_artifacts_dir ⇒ Object
44 45 46 |
# File 'lib/gitlab/qa/runtime/env.rb', line 44 def host_artifacts_dir @host_artifacts_dir ||= File.join(ENV['QA_ARTIFACTS_DIR'] || '/tmp/gitlab-qa', Runtime::Env.run_id) end |
#qa_access_token ⇒ Object
36 37 38 |
# File 'lib/gitlab/qa/runtime/env.rb', line 36 def qa_access_token ENV['GITLAB_QA_ACCESS_TOKEN'] end |
#require_kubernetes_environment! ⇒ Object
79 80 81 82 83 |
# File 'lib/gitlab/qa/runtime/env.rb', line 79 def require_kubernetes_environment! %w[GCLOUD_ACCOUNT_EMAIL GCLOUD_ACCOUNT_KEY CLOUDSDK_CORE_PROJECT GCLOUD_ZONE].each do |env_key| raise ArgumentError, "Environment variable #{env_key} must be set to run kubernetes specs" unless ENV.key?(env_key) end end |
#require_license! ⇒ Object
61 62 63 64 65 |
# File 'lib/gitlab/qa/runtime/env.rb', line 61 def require_license! return if ENV.include?('EE_LICENSE') raise ArgumentError, 'GitLab License is not available. Please load a license into EE_LICENSE env variable.' end |
#require_no_license! ⇒ Object
67 68 69 70 71 |
# File 'lib/gitlab/qa/runtime/env.rb', line 67 def require_no_license! return unless ENV.include?('EE_LICENSE') raise ArgumentError, "Unexpected EE_LICENSE provided. Please unset it to continue." end |
#require_qa_access_token! ⇒ Object
73 74 75 76 77 |
# File 'lib/gitlab/qa/runtime/env.rb', line 73 def require_qa_access_token! return unless ENV['GITLAB_QA_ACCESS_TOKEN'].to_s.strip.empty? raise ArgumentError, "Please provide GITLAB_QA_ACCESS_TOKEN" end |
#run_id ⇒ Object
32 33 34 |
# File 'lib/gitlab/qa/runtime/env.rb', line 32 def run_id @run_id ||= "gitlab-qa-run-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(4)}" end |
#variables ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gitlab/qa/runtime/env.rb', line 48 def variables vars = {} ENV_VARIABLES.each do |name, attribute| # Variables that are overriden in the environment take precedence # over the defaults specified by the QA runtime. value = env_value_if_defined(name) || send(attribute) # rubocop:disable GitlabSecurity/PublicSend vars[name] = value if value end vars end |