Class: ChefDK::Command::Install
Instance Attribute Summary collapse
Instance Method Summary
collapse
#chef_config, #chefdk_config, #config_loader
Methods inherited from Base
#needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#chefdk_home, #err, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_chefdk_location, #omnibus_embedded_bin_dir, #omnibus_install?, #omnibus_root, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ Install
63
64
65
66
67
68
69
|
# File 'lib/chef-dk/command/install.rb', line 63
def initialize(*args)
super
@ui = UI.new
@policyfile_relative_path = nil
@installer = nil
end
|
Instance Attribute Details
#policyfile_relative_path ⇒ Object
Returns the value of attribute policyfile_relative_path.
59
60
61
|
# File 'lib/chef-dk/command/install.rb', line 59
def policyfile_relative_path
@policyfile_relative_path
end
|
#ui ⇒ Object
Returns the value of attribute ui.
61
62
63
|
# File 'lib/chef-dk/command/install.rb', line 61
def ui
@ui
end
|
Instance Method Details
#apply_params!(params) ⇒ Object
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/chef-dk/command/install.rb', line 107
def apply_params!(params)
remaining_args = parse_options(params)
if remaining_args.size > 1
ui.err(opt_parser)
return false
else
@policyfile_relative_path = remaining_args.first
true
end
end
|
#config_path ⇒ Object
93
94
95
|
# File 'lib/chef-dk/command/install.rb', line 93
def config_path
config[:config_file]
end
|
#debug? ⇒ Boolean
89
90
91
|
# File 'lib/chef-dk/command/install.rb', line 89
def debug?
!!config[:debug]
end
|
#handle_error(error) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/chef-dk/command/install.rb', line 97
def handle_error(error)
ui.err("Error: #{error.message}")
if error.respond_to?(:reason)
ui.err("Reason: #{error.reason}")
ui.err("")
ui.err(error.extended_error_info) if debug?
ui.err(error.cause.backtrace.join("\n")) if debug?
end
end
|
#installer ⇒ Object
85
86
87
|
# File 'lib/chef-dk/command/install.rb', line 85
def installer
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd)
end
|
#run(params = []) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/chef-dk/command/install.rb', line 71
def run(params = [])
return 1 unless apply_params!(params)
chef_config
installer.run
0
rescue PolicyfileServiceError => e
handle_error(e)
1
end
|