Class: ChefDK::Command::PushArchive
- Includes:
- ChefDK::Configurable
- Defined in:
- lib/chef-dk/command/push_archive.rb
Instance Attribute Summary collapse
-
#archive_path ⇒ Object
readonly
Returns the value of attribute archive_path.
-
#policy_group ⇒ Object
readonly
Returns the value of attribute policy_group.
-
#ui ⇒ Object
Returns the value of attribute ui.
Instance Method Summary collapse
- #apply_params!(params) ⇒ Object private
- #archive_file ⇒ Object
- #debug? ⇒ Boolean private
- #handle_error(error) ⇒ Object private
-
#initialize(*args) ⇒ PushArchive
constructor
A new instance of PushArchive.
- #push_archive_service ⇒ Object private
- #run(params) ⇒ Object
Methods included from ChefDK::Configurable
#chef_config, #chefdk_config, #config_loader, #generator_config, #knife_config
Methods inherited from Base
#needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#chefdk_home, #err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_chefdk_location, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_install?, #omnibus_root, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ PushArchive
Returns a new instance of PushArchive.
62 63 64 65 66 67 68 |
# File 'lib/chef-dk/command/push_archive.rb', line 62 def initialize(*args) super @policy_group = nil @archive_path = nil @chef_config = nil @ui = UI.new end |
Instance Attribute Details
#archive_path ⇒ Object (readonly)
Returns the value of attribute archive_path.
60 61 62 |
# File 'lib/chef-dk/command/push_archive.rb', line 60 def archive_path @archive_path end |
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
58 59 60 |
# File 'lib/chef-dk/command/push_archive.rb', line 58 def policy_group @policy_group end |
#ui ⇒ Object
Returns the value of attribute ui.
56 57 58 |
# File 'lib/chef-dk/command/push_archive.rb', line 56 def ui @ui end |
Instance Method Details
#apply_params!(params) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
113 114 115 116 117 118 119 120 121 |
# File 'lib/chef-dk/command/push_archive.rb', line 113 def apply_params!(params) remaining_args = (params) if remaining_args.size != 2 ui.err(opt_parser) return false end @policy_group, @archive_path = remaining_args end |
#archive_file ⇒ Object
103 104 105 |
# File 'lib/chef-dk/command/push_archive.rb', line 103 def archive_file File.(archive_path) end |
#debug? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
108 109 110 |
# File 'lib/chef-dk/command/push_archive.rb', line 108 def debug? !!config[:debug] end |
#handle_error(error) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 85 86 87 88 89 90 |
# File 'lib/chef-dk/command/push_archive.rb', line 82 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 |
#push_archive_service ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 96 97 98 99 100 101 |
# File 'lib/chef-dk/command/push_archive.rb', line 93 def push_archive_service @push_archive_service ||= ChefDK::PolicyfileServices::PushArchive.new( archive_file: archive_file, policy_group: policy_group, ui: ui, config: chef_config ) end |
#run(params) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/chef-dk/command/push_archive.rb', line 70 def run(params) return 1 unless apply_params!(params) push_archive_service.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end |