Module: Chef::Knife::API::Support

Defined in:
lib/knife/api.rb

Overview

adding Support module

Class Method Summary collapse

Class Method Details

.run_knife(command, args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/knife/api.rb', line 13

def self.run_knife(command, args)
  command = command.to_s.split(/[\s_]+/) unless command.is_a?(Array)
  command += args
  command += ['-c', ENV['CHEF_CONFIG']] if ENV['CHEF_CONFIG']

  opts = Chef::Application::Knife.new.options
  Chef::Knife.run(command, opts)
  # believe this to be a problem -- if knife command would otherwise
  # indicate a chef error this creates a false positive
  0
rescue SystemExit => e
  abort("Chef run failed with status " + e.status.to_s)
end