Class: ChefCLI::Command::Push
- Includes:
- ChefCLI::Configurable
- Defined in:
- lib/chef-cli/command/push.rb
Instance Attribute Summary collapse
-
#policy_group ⇒ Object
readonly
Returns the value of attribute policy_group.
-
#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) ⇒ Push
constructor
A new instance of Push.
- #push ⇒ Object
- #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
Instance Attribute Details
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
57 58 59 |
# File 'lib/chef-cli/command/push.rb', line 57 def policy_group @policy_group end |
#policyfile_relative_path ⇒ Object (readonly)
Returns the value of attribute policyfile_relative_path.
56 57 58 |
# File 'lib/chef-cli/command/push.rb', line 56 def policyfile_relative_path @policyfile_relative_path end |
#ui ⇒ Object
Returns the value of attribute ui.
59 60 61 |
# File 'lib/chef-cli/command/push.rb', line 59 def ui @ui end |
Instance Method Details
#apply_params!(params) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/chef-cli/command/push.rb', line 103 def apply_params!(params) remaining_args = (params) if remaining_args.size < 1 || remaining_args.size > 2 ui.err(opt_parser) return false else @policy_group = remaining_args[0] @policyfile_relative_path = remaining_args[1] end true end |
#debug? ⇒ Boolean
81 82 83 |
# File 'lib/chef-cli/command/push.rb', line 81 def debug? !!config[:debug] end |
#handle_error(error) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/chef-cli/command/push.rb', line 93 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 ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/chef-cli/command/push.rb', line 85 def push @push ||= PolicyfileServices::Push.new(policyfile: policyfile_relative_path, ui:, policy_group:, config: chef_config, root_dir: Dir.pwd) end |
#run(params = []) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/chef-cli/command/push.rb', line 71 def run(params = []) return 1 unless apply_params!(params) push.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end |