Module: Chef::Knife::PodnixBase

Instance Method Summary collapse

Instance Method Details

#locate_config_value(key) ⇒ Object



26
27
28
29
# File 'lib/chef/knife/podnix_base.rb', line 26

def locate_config_value(key)
  key = key.to_sym
  config[key] || Chef::Config[:knife][key]
end

#msg_pair(label, value, color = :cyan) ⇒ Object



16
17
18
19
20
# File 'lib/chef/knife/podnix_base.rb', line 16

def msg_pair(label, value, color=:cyan)
  if value && !value.to_s.empty?
    ui.info "#{ui.color(label, color)}: #{value}"
  end
end

#podnix_apikeyObject



22
23
24
# File 'lib/chef/knife/podnix_base.rb', line 22

def podnix_apikey
  locate_config_value(:podnix_api_key) || ENV['PODNIX_API_KEY']
end

#validate!Object



7
8
9
10
11
12
13
14
# File 'lib/chef/knife/podnix_base.rb', line 7

def validate!
  if (!podnix_apikey)
    ui.error "You did not configure your podnix_api_key"
    ui.error "either export PODNIX_API_KEY in .bashrc"
    ui.error "or configure podnix_api_key in knife.rb"
    exit 1
  end
end