Module: Gitlab::QA::Runtime::Env

Extended by:
Env
Included in:
Env
Defined in:
lib/gitlab/qa/runtime/env.rb

Constant Summary collapse

ENV_VARIABLES =
{
  'GITLAB_USERNAME' => :user_username,
  'GITLAB_PASSWORD' => :user_password,
  'GITLAB_LDAP_USERNAME' => :ldap_username,
  'GITLAB_LDAP_PASSWORD' => :ldap_password,
  'GITLAB_USER_TYPE' => :user_type,
  'GITLAB_SANDBOX_NAME' => :gitlab_sandbox_name,
  'GITLAB_QA_ACCESS_TOKEN' => :qa_access_token,
  'GITLAB_URL' => :gitlab_url,
  'EE_LICENSE' => :ee_license
}.freeze

Instance Method Summary collapse

Instance Method Details

#logs_dirObject



31
32
33
# File 'lib/gitlab/qa/runtime/env.rb', line 31

def logs_dir
  ENV['QA_LOGS_DIR'] || '/tmp/gitlab-qa/logs'
end

#qa_access_tokenObject



23
24
25
# File 'lib/gitlab/qa/runtime/env.rb', line 23

def qa_access_token
  ENV['GITLAB_QA_ACCESS_TOKEN']
end

#require_license!Object

Raises:

  • (ArgumentError)


48
49
50
51
52
# File 'lib/gitlab/qa/runtime/env.rb', line 48

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

Raises:

  • (ArgumentError)


54
55
56
57
58
# File 'lib/gitlab/qa/runtime/env.rb', line 54

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

Raises:

  • (ArgumentError)


60
61
62
63
64
# File 'lib/gitlab/qa/runtime/env.rb', line 60

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

#screenshots_dirObject



27
28
29
# File 'lib/gitlab/qa/runtime/env.rb', line 27

def screenshots_dir
  ENV['QA_SCREENSHOTS_DIR'] || '/tmp/gitlab-qa/screenshots'
end

#variablesObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gitlab/qa/runtime/env.rb', line 35

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