From 780a312fc920ce689e1bdce19cab5edee3c30190 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 19 Apr 2013 14:14:29 -0600 Subject: [PATCH] Built-in DestroyConfirm middleware --- CHANGELOG.md | 5 +++++ lib/vagrant/action.rb | 1 + lib/vagrant/action/builtin/destroy_confirm.rb | 21 +++++++++++++++++++ plugins/providers/virtualbox/action.rb | 1 - .../virtualbox/action/destroy_confirm.rb | 17 --------------- 5 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 lib/vagrant/action/builtin/destroy_confirm.rb delete mode 100644 plugins/providers/virtualbox/action/destroy_confirm.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b172ad90..87f3813a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## 1.2.2 (unreleased) +FEATURES: + + - New `DestroyConfirm` built-in middleware for providers so they can + more easily conform to the `destroy` action. + IMPROVEMENTS: - No longer an error if the Chef run list is empty. It is now diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index b6ebe3066..74b55ac6a 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -12,6 +12,7 @@ module Vagrant autoload :Call, "vagrant/action/builtin/call" autoload :Confirm, "vagrant/action/builtin/confirm" autoload :ConfigValidate, "vagrant/action/builtin/config_validate" + autoload :DestroyConfirm, "vagrant/action/builtin/destroy_confirm" autoload :EnvSet, "vagrant/action/builtin/env_set" autoload :GracefulHalt, "vagrant/action/builtin/graceful_halt" autoload :HandleBoxUrl, "vagrant/action/builtin/handle_box_url" diff --git a/lib/vagrant/action/builtin/destroy_confirm.rb b/lib/vagrant/action/builtin/destroy_confirm.rb new file mode 100644 index 000000000..2e76737c6 --- /dev/null +++ b/lib/vagrant/action/builtin/destroy_confirm.rb @@ -0,0 +1,21 @@ +require_relative "confirm" + +module Vagrant + module Action + module Builtin + # This class asks the user to confirm the destruction of a machine + # that Vagrant manages. This is provided as a built-in on top of + # {Confirm} because it sets up the proper keys and such so that + # `vagrant destroy -f` works properly. + class DestroyConfirm < Confirm + def initialize(app, env) + force_key = :force_confirm_destroy + message = I18n.t("vagrant.commands.destroy.confirmation", + :name => env[:machine].name) + + super(app, env, message, force_key) + end + end + end + end +end diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index c83bc9b01..513583d4e 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -16,7 +16,6 @@ module VagrantPlugins autoload :Created, File.expand_path("../action/created", __FILE__) autoload :Customize, File.expand_path("../action/customize", __FILE__) autoload :Destroy, File.expand_path("../action/destroy", __FILE__) - autoload :DestroyConfirm, File.expand_path("../action/destroy_confirm", __FILE__) autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__) autoload :DiscardState, File.expand_path("../action/discard_state", __FILE__) autoload :Export, File.expand_path("../action/export", __FILE__) diff --git a/plugins/providers/virtualbox/action/destroy_confirm.rb b/plugins/providers/virtualbox/action/destroy_confirm.rb deleted file mode 100644 index 062450680..000000000 --- a/plugins/providers/virtualbox/action/destroy_confirm.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "vagrant/action/builtin/confirm" - -module VagrantPlugins - module ProviderVirtualBox - module Action - class DestroyConfirm < Vagrant::Action::Builtin::Confirm - def initialize(app, env) - force_key = :force_confirm_destroy - message = I18n.t("vagrant.commands.destroy.confirmation", - :name => env[:machine].name) - - super(app, env, message, force_key) - end - end - end - end -end