Module: KamalGitlabReviewApp::Env

Defined in:
lib/kamal_gitlab_review_app/env.rb

Class Method Summary collapse

Class Method Details

.accessoriesObject



30
31
32
33
34
35
# File 'lib/kamal_gitlab_review_app/env.rb', line 30

def accessories
  raw = ENV.fetch('REVIEW_ACCESSORIES', 'db').to_s.strip
  return [] if raw.empty? || raw.downcase == 'none'

  raw.split(',').map(&:strip).reject(&:empty?)
end

.db_accessoryObject

Accessory name used for DB_HOST (#{service}-#{accessory}). Defaults to the first entry in REVIEW_ACCESSORIES; override with REVIEW_DB_ACCESSORY when the DB is not first.



39
40
41
42
43
44
# File 'lib/kamal_gitlab_review_app/env.rb', line 39

def db_accessory
  explicit = ENV['REVIEW_DB_ACCESSORY'].to_s.strip
  return explicit unless explicit.empty?

  accessories.first
end

.default_runtime_env(names) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/kamal_gitlab_review_app/env.rb', line 46

def default_runtime_env(names)
  env = {
    'GENERAL_HOST' => names.fetch(:host),
    'KAMAL_SERVICE' => names.fetch(:service)
  }
  env['DB_HOST'] = names[:db_host] if names[:db_host]
  env
end

.dns_provider_nameObject



26
27
28
# File 'lib/kamal_gitlab_review_app/env.rb', line 26

def dns_provider_name
  ENV.fetch('REVIEW_DNS_PROVIDER', 'cloudflare').to_s.strip.downcase
end

.environment_prefixObject



18
19
20
# File 'lib/kamal_gitlab_review_app/env.rb', line 18

def environment_prefix
  ENV.fetch('REVIEW_ENVIRONMENT_PREFIX', 'review/mr')
end

.host_label_prefixObject



22
23
24
# File 'lib/kamal_gitlab_review_app/env.rb', line 22

def host_label_prefix
  ENV.fetch('REVIEW_HOST_LABEL_PREFIX', 'mr')
end

.review_domainObject

Raises:

  • (KeyError)


7
8
9
10
11
12
# File 'lib/kamal_gitlab_review_app/env.rb', line 7

def review_domain
  value = ENV['REVIEW_DOMAIN'].to_s.strip
  raise KeyError, 'key not found: "REVIEW_DOMAIN"' if value.empty?

  value
end

.service_prefixObject



14
15
16
# File 'lib/kamal_gitlab_review_app/env.rb', line 14

def service_prefix
  ENV.fetch('REVIEW_SERVICE_PREFIX', 'app_mr')
end