Class: ChefDK::Command::Install
- Defined in:
- lib/chef-dk/command/install.rb
Instance Attribute Summary collapse
-
#policyfile_relative_path ⇒ Object
readonly
Returns the value of attribute policyfile_relative_path.
-
#ui ⇒ Object
Returns the value of attribute ui.
Instance Method Summary collapse
- #apply_params!(params) ⇒ Object
- #debug? ⇒ Boolean
- #handle_error(error) ⇒ Object
-
#initialize(*args) ⇒ Install
constructor
A new instance of Install.
- #installer ⇒ Object
- #run(params = []) ⇒ Object
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
Constructor Details
Instance Attribute Details
#policyfile_relative_path ⇒ Object (readonly)
Returns the value of attribute policyfile_relative_path.
52 53 54 |
# File 'lib/chef-dk/command/install.rb', line 52 def policyfile_relative_path @policyfile_relative_path end |
#ui ⇒ Object
Returns the value of attribute ui.
54 55 56 |
# File 'lib/chef-dk/command/install.rb', line 54 def ui @ui end |
Instance Method Details
#apply_params!(params) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/chef-dk/command/install.rb', line 91 def apply_params!(params) remaining_args = (params) if remaining_args.size > 1 ui.err() return 1 else @policyfile_relative_path = remaining_args.first end end |
#debug? ⇒ Boolean
77 78 79 |
# File 'lib/chef-dk/command/install.rb', line 77 def debug? !!config[:debug] end |
#handle_error(error) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/chef-dk/command/install.rb', line 81 def handle_error(error) ui.err("Error: #{error.}") 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
73 74 75 |
# File 'lib/chef-dk/command/install.rb', line 73 def installer @installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd) end |
#run(params = []) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/chef-dk/command/install.rb', line 64 def run(params = []) apply_params!(params) installer.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end |