class ChefDK::Command::CleanPolicyRevisions
Attributes
policy_group[R]
policy_name[R]
ui[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
ChefDK::Command::Base::new
# File lib/chef-dk/command/clean_policy_revisions.rb, line 64 def initialize(*args) super @ui = UI.new end
Public Instance Methods
apply_params!(params)
click to toggle source
# File lib/chef-dk/command/clean_policy_revisions.rb, line 98 def apply_params!(params) remaining_args = parse_options(params) if !remaining_args.empty? ui.err("Too many arguments") ui.err("") ui.err(opt_parser) false else true end end
clean_policies_service()
click to toggle source
# File lib/chef-dk/command/clean_policy_revisions.rb, line 79 def clean_policies_service @policy_list_service ||= PolicyfileServices::CleanPolicies.new(config: chef_config, ui: ui) end
debug?()
click to toggle source
# File lib/chef-dk/command/clean_policy_revisions.rb, line 84 def debug? !!config[:debug] end
handle_error(error)
click to toggle source
# File lib/chef-dk/command/clean_policy_revisions.rb, line 88 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
run(params)
click to toggle source
# File lib/chef-dk/command/clean_policy_revisions.rb, line 69 def run(params) return 1 unless apply_params!(params) clean_policies_service.run 0 rescue PolicyfileServiceError => e handle_error(e) 1 end