module RatDeployer::Config

This module handles config fetching from env and config files

Public Class Methods

all() click to toggle source
# File lib/rat_deployer/config.rb, line 7
def self.all
  @all ||= YAML.load_file(File.expand_path('./rat_config.yml')) || {}
end
env() click to toggle source
# File lib/rat_deployer/config.rb, line 27
def self.env
  ENV['RAT_ENV'] || 'default'
end
for_env(e = env) click to toggle source
# File lib/rat_deployer/config.rb, line 11
def self.for_env(e = env)
  environmental = all.fetch('environments', {})
  default_conf = environmental.fetch('default', {})
  env_conf     = environmental.fetch(e, {})

  default_conf.deep_merge(env_conf)
end
images() click to toggle source
# File lib/rat_deployer/config.rb, line 31
def self.images
  all.fetch('images', {})
end
project_name() click to toggle source
# File lib/rat_deployer/config.rb, line 35
def self.project_name
  (for_env['project_name'] || all.fetch('project_name'))
    .gsub(/\{env\}/, env)
end
prompt_enabled?() click to toggle source
# File lib/rat_deployer/config.rb, line 19
def self.prompt_enabled?
  ENV['RAT_PROMPT'] != 'false'
end
remote() click to toggle source
# File lib/rat_deployer/config.rb, line 23
def self.remote
  ENV['RAT_REMOTE'] =~ /true|1|yes/
end
remote_machine_flags() click to toggle source
# File lib/rat_deployer/config.rb, line 40
def self.remote_machine_flags
  machine = for_env.fetch('machine')

  case machine
  when Hash
    [
      '--tlsverify',
      "-H='#{machine.fetch('host')}'",
      "--tlscacert='#{machine.fetch('ca_cert')}'",
      "--tlscert='#{machine.fetch('cert')}'",
      "--tlskey='#{machine.fetch('key')}'"
    ].join(' ')
  else
    raise 'Bad configuration value for `machine`'
  end
end