commands/up: validate provision-with args [GH-1957]

This commit is contained in:
Mitchell Hashimoto 2013-09-02 15:06:03 -07:00
parent e8d2e05c4e
commit b8dc881792
6 changed files with 26 additions and 0 deletions

View File

@ -71,6 +71,7 @@ BUG FIXES:
- core: Multiple forwarded ports with different protocols but the same
host port can be specified. [GH-2059]
- core: `:nic_type` option for private networks is respected. [GH-1704]
- commands/up: provision-with validates the provisioners given. [GH-1957]
- guests/arch: use systemd way of setting host names. [GH-2041]
- guests/debian: Force bring up eth0. Fixes hangs on setting hostname.
[GH-2026]

View File

@ -379,6 +379,10 @@ module Vagrant
error_key(:provider_not_found)
end
class ProvisionerFlagInvalid < VagrantError
error_key(:provisioner_flag_invalid)
end
class PluginGemError < VagrantError
error_key(:plugin_gem_error)
end

View File

@ -25,6 +25,9 @@ module VagrantPlugins
argv = parse_options(opts)
return if !argv
# Validate the provisioners
validate_provisioner_flags!(options)
@logger.debug("'reload' each target VM...")
with_target_vms(argv) do |machine|
machine.action(:reload, options)

View File

@ -41,6 +41,9 @@ module VagrantPlugins
argv = parse_options(opts)
return if !argv
# Validate the provisioners
validate_provisioner_flags!(options)
# Go over each VM and bring it up
@logger.debug("'Up' each target VM...")

View File

@ -20,6 +20,18 @@ module VagrantPlugins
options[:provision_types] = list.map { |type| type.to_sym }
end
end
# This validates the provisioner flags and raises an exception
# if there are invalid ones.
def validate_provisioner_flags!(options)
(options[:provision_types] || []).each do |type|
klass = Vagrant.plugin("2").manager.provisioners[type]
if !klass
raise Vagrant::Errors::ProvisionerFlagInvalid,
name: type.to_s
end
end
end
end
end
end

View File

@ -428,6 +428,9 @@ en:
provider_not_found: |-
The provider '%{provider}' could not be found, but was requested to
back the machine '%{machine}'. Please use a provider that exists.
provisioner_flag_invalid: |-
'%{name}' is not a known provisioner. Please specify a valid
provisioner.
scp_permission_denied: |-
Failed to upload a file to the guest VM via SCP due to a permissions
error. This is normally because the user running Vagrant doesn't have