Class: JamesBond::MissionKubernetes::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/james_bond/mission_kubernetes/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml_path:) ⇒ Config

Returns a new instance of Config.



9
10
11
12
# File 'lib/james_bond/mission_kubernetes/config.rb', line 9

def initialize(yaml_path:)
  @yaml_path = yaml_path
  extract_config_from_yaml(@yaml_path)
end

Instance Attribute Details

#raw_hashObject

Returns the value of attribute raw_hash.



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

def raw_hash
  @raw_hash
end

#yaml_pathObject

Returns the value of attribute yaml_path.



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

def yaml_path
  @yaml_path
end

Instance Method Details

#for(env:, command:) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/james_bond/mission_kubernetes/config.rb', line 15

def for(env:,command:)
  env_config = @raw_hash[env]
  raise "No config for '#{env}' environment" if !env_config

  commands = env_config.fetch("commands", proc { raise_error(command, env)} )
  commands.fetch(command, proc { raise_error(command, env) })
end