class ChefCLI::PolicyfileServices::CleanPolicies
def run
def run revisions_to_remove = orphaned_policies if revisions_to_remove.empty? ui.err("No policy revisions deleted") return true end results = revisions_to_remove.map do |policy| [ remove_policy(policy), policy ] end failures = results.select { |result, _policy| result.is_a?(Exception) } unless failures.empty? details = failures.map do |result, policy| "- #{policy.policy_name} (#{policy.revision_id}): #{result.class} #{result}" end message = "Failed to delete some policy revisions:\n" + details.join("\n") + "\n" raise PolicyfileCleanError.new(message, MultipleErrors.new("multiple errors")) end true end