class ChefCLI::Command::Update
def apply_params!(params)
def apply_params!(params) remaining_args = parse_options(params) @policyfile_relative_path = remaining_args.shift @cookbooks_to_update += remaining_args true end
def attributes_updater
def attributes_updater @attributes_updater ||= PolicyfileServices::UpdateAttributes.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, chef_config: chef_config) end
def config_path
def config_path config[:config_file] end
def debug?
def debug? !!config[:debug] end
def handle_error(error)
def handle_error(error) ui.err("Error: #{error.message}") 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
def initialize(*args)
def initialize(*args) super @ui = UI.new @policyfile_relative_path = nil @installer = nil @attributes_updater = nil @cookbooks_to_update = [] end
def installer
def installer @installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, config: chef_config, overwrite: true) end
def run(params = [])
def run(params = []) return 1 unless apply_params!(params) attributes_updater.run if update_attributes_only? installer.run(@cookbooks_to_update, config[:exclude_deps]) unless update_attributes_only? 0 rescue PolicyfileServiceError => e handle_error(e) 1 end
def update_attributes_only?
def update_attributes_only? !!config[:update_attributes_only] end