Properly print warnings on config settings that aren't supported

This commit is contained in:
Brian Cain 2018-04-06 11:23:43 -07:00
parent 188fd5d6a6
commit e25cb51f15
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
3 changed files with 17 additions and 3 deletions

View File

@ -113,10 +113,19 @@ module VagrantPlugins
# Convert @run and @run_remote to be a "Shell provisioner" config
if @run && @run.is_a?(Hash)
# Powershell args and privileged for run commands is currently not supported
# so by default use empty string or false if unset. This helps the validate
# function determine if the setting was purposefully set, to print a warning
if !@run.key?(:powershell_args)
@run[:powershell_args] = ""
end
if !@run.key?(:privileged)
@run[:privileged] = false
end
new_run = VagrantPlugins::Shell::Config.new
new_run.set_options(@run)
# don't run local commands as sudo by default
new_run.privileged = false
new_run.finalize!
@run = new_run
end
@ -152,6 +161,10 @@ module VagrantPlugins
machine.ui.warn(I18n.t("vagrant.config.triggers.privileged_ignored",
command: @command))
end
if @run.powershell_args != ""
machine.ui.warn(I18n.t("vagrant.config.triggers.powershell_args_ignored"))
end
end
if @run_remote

View File

@ -1723,6 +1723,8 @@ en:
Invalid type found for `only_on`. All values must be a `String` or `Regexp`.
privileged_ignored: |-
The `privileged` setting for option `run` for trigger command '%{command}' will be ignored and set to false.
powershell_args_ignored: |-
The setting `powershell_args` is not supported for the trigger option `run` and will be ignored.
run:
bad_type: |-
Invalid type set for `run` on trigger for command '%{cmd}'. `run`

View File

@ -33,6 +33,5 @@ The trigger class takes various options.
+ `args`
+ `inline`
+ `path`
+ `powershell_args`
* `warn` (string) - A warning message that will be printed at the beginning of a trigger.