From e25cb51f1539672905f7942e7cc1298c3269a5a3 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 6 Apr 2018 11:23:43 -0700 Subject: [PATCH] Properly print warnings on config settings that aren't supported --- plugins/kernel_v2/config/vm_trigger.rb | 17 +++++++++++++++-- templates/locales/en.yml | 2 ++ .../source/docs/triggers/configuration.html.md | 1 - 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/kernel_v2/config/vm_trigger.rb b/plugins/kernel_v2/config/vm_trigger.rb index 98969fab7..beeb812a1 100644 --- a/plugins/kernel_v2/config/vm_trigger.rb +++ b/plugins/kernel_v2/config/vm_trigger.rb @@ -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 diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 11b8eb807..a18676f44 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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` diff --git a/website/source/docs/triggers/configuration.html.md b/website/source/docs/triggers/configuration.html.md index f66333a79..6ba3ddd1d 100644 --- a/website/source/docs/triggers/configuration.html.md +++ b/website/source/docs/triggers/configuration.html.md @@ -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.