class JamesBond::MissionKubernetes::Config

Attributes

raw_hash[RW]
yaml_path[RW]

Public Class Methods

new(yaml_path:) click to toggle source
# 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

Public Instance Methods

for(env:,command:) click to toggle source
# 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

Private Instance Methods

extract_config_from_yaml(yaml_path) click to toggle source
# File lib/james_bond/mission_kubernetes/config.rb, line 29
def extract_config_from_yaml(yaml_path)
  @raw_hash = YAML.load(File.read(yaml_path)).freeze
end
raise_error(command, env) click to toggle source
# File lib/james_bond/mission_kubernetes/config.rb, line 25
def raise_error(command, env)
  raise "No config for '#{command}' command in '#{env}' environment"
end