Module: RatDeployer::Config

Defined in:
lib/rat_deployer/config.rb

Class Method Summary collapse

Class Method Details

.allObject



6
7
8
# File 'lib/rat_deployer/config.rb', line 6

def self.all
  @all ||= YAML.load_file(File.expand_path('./rat_config.yml')) || {}
end

.envObject



20
# File 'lib/rat_deployer/config.rb', line 20

def self.env() ENV.fetch('RAT_ENV') end

.for_env(e = env) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/rat_deployer/config.rb', line 9

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

.imagesObject



21
# File 'lib/rat_deployer/config.rb', line 21

def self.images() all.fetch('images', {}) end

.machineObject



18
# File 'lib/rat_deployer/config.rb', line 18

def self.machine() for_env.fetch("machine") end

.prompt_enabled?Boolean

Returns:

  • (Boolean)


17
# File 'lib/rat_deployer/config.rb', line 17

def self.prompt_enabled?() ENV['RAT_PROMPT'] != "false" end

.remoteObject



19
# File 'lib/rat_deployer/config.rb', line 19

def self.remote() ENV['RAT_REMOTE'] =~ /true|1|yes/ end

.remote_machine_flagsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rat_deployer/config.rb', line 23

def self.remote_machine_flags
  case machine
  when Symbol, String
    `docker-machine config #{machine}`.gsub(/\n/, ' ')
  when Hash
    [
      "--tlsverify",
      "-H='#{machine.fetch('host')}'",
      "--tlscacert='#{machine.fetch('ca_cert')}'",
      "--tlscert='#{machine.fetch('cert')}'",
      "--tlskey='#{machine.fetch('key')}'",
    ].join(' ')
  end
end