summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-03-18 12:46:30 -0700
committersersut <serdar@opscode.com>2014-03-18 12:46:30 -0700
commitd55aed9c5fb60c14ac32f409de861b0667371b66 (patch)
tree4cd0837543a65becb8170551f578f56ec5d984f1
parent5a20374ba1f3347ee79dc1ad93eb9cc50940c1d6 (diff)
downloadchef-d55aed9c5fb60c14ac32f409de861b0667371b66.tar.gz
Break apart logic of ClientBulkDelete#run into smaller pieces.
-rw-r--r--lib/chef/knife/client_bulk_delete.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/chef/knife/client_bulk_delete.rb b/lib/chef/knife/client_bulk_delete.rb
index 25bce4300b..1e1d6af190 100644
--- a/lib/chef/knife/client_bulk_delete.rb
+++ b/lib/chef/knife/client_bulk_delete.rb
@@ -58,25 +58,32 @@ class Chef
exit 0
end
- unless validators_to_delete.empty?
+ check_and_delete_validators(validators_to_delete)
+ check_and_delete_clients(clients_to_delete)
+ end
+
+ def check_and_delete_validators(validators)
+ unless validators.empty?
unless config[:delete_validators]
ui.msg("Following clients are validators and will not be deleted.")
- print_clients(validators_to_delete)
+ print_clients(validators)
ui.msg("You must specify --delete-validators to delete the validator clients")
else
ui.msg("The following validators will be deleted:")
- print_clients(validators_to_delete)
+ print_clients(validators)
if ui.confirm("Are you sure you want to delete these validators", true, false)
- destroy_clients(validators_to_delete)
+ destroy_clients(validators)
end
end
end
+ end
- unless clients_to_delete.empty?
+ def check_and_delete_clients(clients)
+ unless clients.empty?
ui.msg("The following clients will be deleted:")
- print_clients(clients_to_delete)
+ print_clients(clients)
ui.confirm("Are you sure you want to delete these clients")
- destroy_clients(clients_to_delete)
+ destroy_clients(clients)
end
end