Class: ChefCLI::Command::PushArchive
- Includes:
- ChefCLI::Configurable
- Defined in:
- lib/chef-cli/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 ChefCLI::Configurable
#chef_config, #chefcli_config, #config_loader, #generator_config, #knife_config, #reset_config!
Methods inherited from Base
#check_license_acceptance, #needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_expand_path, #omnibus_install?, #omnibus_root, #package_home, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ PushArchive
Returns a new instance of PushArchive.
52 53 54 55 56 57 58 |
# File 'lib/chef-cli/command/push_archive.rb', line 52 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.
50 51 52 |
# File 'lib/chef-cli/command/push_archive.rb', line 50 def archive_path @archive_path end |
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
48 49 50 |
# File 'lib/chef-cli/command/push_archive.rb', line 48 def policy_group @policy_group end |
#ui ⇒ Object
Returns the value of attribute ui.
46 47 48 |
# File 'lib/chef-cli/command/push_archive.rb', line 46 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.
103 104 105 106 107 108 109 110 111 |
# File 'lib/chef-cli/command/push_archive.rb', line 103 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
93 94 95 |
# File 'lib/chef-cli/command/push_archive.rb', line 93 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.
98 99 100 |
# File 'lib/chef-cli/command/push_archive.rb', line 98 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.
72 73 74 75 76 77 78 79 80 |
# File 'lib/chef-cli/command/push_archive.rb', line 72 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.
83 84 85 86 87 88 89 90 91 |
# File 'lib/chef-cli/command/push_archive.rb', line 83 def push_archive_service @push_archive_service ||= ChefCLI::PolicyfileServices::PushArchive.new( archive_file:, policy_group:, ui:, config: chef_config ) end |
#run(params) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef-cli/command/push_archive.rb', line 60 def run(params) return 1 unless apply_params!(params) push_archive_service.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end |