Class: ChefDK::Command::Push
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
- #chef_config ⇒ Object
- #debug? ⇒ Boolean
- #handle_error(error) ⇒ Object
-
#initialize(*args) ⇒ Push
constructor
A new instance of Push.
- #push ⇒ Object
- #run(params = []) ⇒ Object
Methods inherited from Base
#needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#err, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_root, #stderr, #stdout, #system_command
Constructor Details
Instance Attribute Details
#policy_group ⇒ Object (readonly)
Returns the value of attribute policy_group.
56 57 58 |
# File 'lib/chef-dk/command/push.rb', line 56 def policy_group @policy_group end |
#policyfile_relative_path ⇒ Object (readonly)
Returns the value of attribute policyfile_relative_path.
55 56 57 |
# File 'lib/chef-dk/command/push.rb', line 55 def policyfile_relative_path @policyfile_relative_path end |
#ui ⇒ Object
Returns the value of attribute ui.
58 59 60 |
# File 'lib/chef-dk/command/push.rb', line 58 def ui @ui end |
Instance Method Details
#apply_params!(params) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/chef-dk/command/push.rb', line 108 def apply_params!(params) remaining_args = (params) if remaining_args.size < 1 or remaining_args.size > 2 ui.err() return false else @policy_group = remaining_args[0] @policyfile_relative_path = remaining_args[1] end true end |
#chef_config ⇒ Object
83 84 85 86 87 |
# File 'lib/chef-dk/command/push.rb', line 83 def chef_config return @chef_config if @chef_config Chef::WorkstationConfigLoader.new(config[:config_file]).load @chef_config = Chef::Config end |
#debug? ⇒ Boolean
79 80 81 |
# File 'lib/chef-dk/command/push.rb', line 79 def debug? !!config[:debug] end |
#handle_error(error) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/chef-dk/command/push.rb', line 97 def handle_error(error) ui.err("Error: #{error.}") if error.respond_to?(:cause) && error.cause cause = error.cause ui.err("Reason: #{cause.class.name}") ui.err("") ui.err(cause.) ui.err(cause.backtrace.join("\n")) if debug? end end |
#push ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/chef-dk/command/push.rb', line 89 def push @push ||= PolicyfileServices::Push.new(policyfile: policyfile_relative_path, ui: ui, policy_group: policy_group, config: chef_config, root_dir: Dir.pwd) end |
#run(params = []) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/chef-dk/command/push.rb', line 70 def run(params = []) return 1 unless apply_params!(params) push.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end |