53 Commits

Author SHA1 Message Date
hashicorp-copywrite[bot]
36a312ee26
add missing license headers and update copyright file headers to BUS-1.1 2023-08-10 21:53:25 +01:00
Chris Roberts
3d0d0148e9 Update tests to use real UI instance
Replaces use of UI doubles within tests to use actual UI instance
    to ensure calls are passing parameters correctly.
2021-06-23 14:04:48 -07:00
Chris Roberts
f26440ee38 Only allow the all special value to be matched when requested
This prevents the all special value from being matched on the
non-defined raw action names when the typed triggers support
is enabled.
2020-06-12 17:09:31 -07:00
Chris Roberts
916655dbd3 Fix trigger matching on :all special value
Updates the type to do a proper comparison when checking for
the `:all` special value as well as applied ignores.

Fixes #11599
2020-06-09 16:12:48 -07:00
Chris Roberts
217f2530db Use machine specific triggers instance when machine is available in runner 2020-03-26 17:20:55 -07:00
Chris Roberts
d08c68ecf3 Adjust how trigger actions are inserted into the stack
This adjusts how triggers are implemented during a normal run. Any
defined triggers which are applicable are located and injected into
the run stack as the stack is built, including hook type triggers.

Support is included for dynamic hook lookup.

The data type used when defining triggers has also been relaxed to
support symbols, strings, or constants.
2020-03-17 15:07:36 -07:00
Chris Roberts
88c675694a Update trigger abort behavior when running parallel actions
When the provider supports parallel actions and actions are being
run in parallel, do not immediately kill the process on failure.
Instead terminate the action thread and log the exit code. Once
all running actions have completed, the process will then exit
with the stored exit code.
2019-06-04 16:40:59 -07:00
Brian Cain
eb3e309f89
Ensure guest names are string when filtering
Prior to this commit, if a guest name was given as a symbol, the
filter_triggers method would fail to properly match it with the only_on
option, as it is not a valid type to the #String.match method. This
commit fixes that by converting the parameter to a string so that it can
be properly matched on the guest.
2019-05-13 14:07:22 -07:00
Brian Cain
35ee3e2342
Fixes #10823: Use Process.exit! for abort trigger option
Prior to this commit, the `abort` option for triggers would just call
`exit`, which would end up raising a SystemExit exception, signaling
Vagrant to abort. This broke down however in a multithreaded context
like when running multiple guests at once on supported providers,
resulting in Vagrant failing to exit cleanly and instead raise an
exception. This commit changes that by instead using `Process.exit!` to
abort Vagrant.
2019-05-03 14:48:54 -07:00
Brian Cain
08214ec90f
Ensure action param is a symbol, and if nil return to do nothing 2019-02-01 13:34:15 -08:00
Brian Cain
16b5ad74ca
Handle command triggers with run_remote options
This commit adds some handling around when a machine does not exist at
all but a trigger was defined with a run_remote option
2019-02-01 13:34:15 -08:00
Brian Cain
ec9bda78c3
Remove comment 2019-02-01 13:34:15 -08:00
Brian Cain
fefb702359
Introduce type and command triggers
This commit introduces some basic functionality for typed triggers:

- command
- action

Command triggers are triggers that will run before or after a given
sub-command.

Action triggers are for running triggers before or after internal
actions for Vagrant. This could be before or after a provision step,
before or after synced folders, or networking, etc.
2019-02-01 13:34:15 -08:00
Brian Cain
69b3b44505
Fixes #10393: Only use Shellwords on non-windows hosts
This commit updates how the trigger `run` inline option works by only
applying `Shellwords.split` to the inline command if it is going to be
run on non-Windows hosts. Otherwise pass the inline script directly to
be executed by Powershell.
2018-11-13 13:07:39 -08:00
Brian Cain
f4d618eb58
Fixes #9840: Introduce ruby option for trigger
This commit introduces a new option to the core trigger feature: `ruby`.
It can be defined to run ruby code when the trigger is configured to
fire. If you give the ruby block an env and machine argument, the
defined ruby code can use those variables internally.
2018-10-05 12:53:41 -07:00
Brian Cain
58ebd52f99
Add abort option to core triggers
This commit adds a new option `abort`, which when configured, will exit
the Vagrant process completely. If set to `true`, it will exit cleanly
with exit code 0. Otherwise, the exit code can be configured.
2018-09-25 09:40:36 -07:00
Mikhail Emelchenkov
ed8ecd15e1
Fix: trigger embedded plugin fails to exec scripts at paths contains spaces 2018-08-17 15:14:54 -07:00
Brian Cain
29aba535ce
(#10104) Ensure trigger run args are an array prior to join
Prior to this commit, if the args key was a string rather than an array
of strings, the `join` command would fail when appending the arguments
to the run command for a given script. This commit updates that by
ensuring the `args` option is an array prior to joining the arguments.
2018-08-14 10:29:51 -07:00
Brian Cain
52c3dcc70e
(#9997) Catch and allow for non-standard exit codes
Prior to this commit, the run trigger option wouldn't catch for failures
outside of the #Subprocess.execute raising exceptions. This commit fixes
that by inspecting the exit code result of the subprocess and using the
new `exit_codes` option to determine how to move forward with the
trigger.
2018-07-09 15:56:26 -07:00
Brian Cain
a9be56b356
Code updates based on PR feedback 2018-04-24 10:04:40 -07:00
Brian Cain
daffd87200
Use match over match? for Ruby 2.3 2018-04-20 12:24:32 -07:00
Brian Cain
188fd5d6a6
Split out run methods with Powershell functions 2018-04-20 10:51:38 -07:00
Brian Cain
12b1a3dfe4
Update triggers based on code review 2018-04-20 10:51:38 -07:00
Brian Cain
4e5e4d0214
Use args setting for run option in trigger 2018-04-20 10:51:38 -07:00
Brian Cain
8451cbf854
Move up location of error message 2018-04-20 10:51:38 -07:00
Brian Cain
c35e0a4f9a
Update docs with some basic trigger examples 2018-04-20 10:51:38 -07:00
Brian Cain
e0806f623c
Remove TODO 2018-04-20 10:51:38 -07:00
Brian Cain
6bf01965de
Fix run command for windows hosts 2018-04-20 10:51:38 -07:00
Brian Cain
a5fe84d64f
Fix string translation 2018-04-20 10:51:38 -07:00
Brian Cain
7cdb32f642
Use inclunde? instead of any? for ruby 2.3 2018-04-20 10:51:38 -07:00
Brian Cain
767a315393
Trigger cleanup 2018-04-20 10:51:38 -07:00
Brian Cain
85dedf25d9
Ensure that :all triggers don't get filtered out 2018-04-20 10:51:38 -07:00
Brian Cain
600557ff24
Move strings to translation file 2018-04-20 10:51:38 -07:00
Brian Cain
a1e4fe4411
Align how local provisioner looks with shell provisioner 2018-04-20 10:51:38 -07:00
Brian Cain
a857056136
Update color for run_remote to match shell provisioner colors 2018-04-20 10:51:38 -07:00
Brian Cain
8b71c24f90
Match properly on guests with trigger filtering 2018-04-20 10:51:38 -07:00
Brian Cain
a4faaa1a4d
Provision run_remote using the shell provisioner 2018-04-20 10:51:38 -07:00
Brian Cain
fd2878309b
Move exception warnings in run function 2018-04-20 10:51:38 -07:00
Brian Cain
e078767b2b
run now supports script files as well as inline scripts 2018-04-20 10:51:38 -07:00
Brian Cain
8b70abd4d0
Send the correct config message to warn 2018-04-20 10:51:38 -07:00
Brian Cain
59965f4fd6
Properly filter triggers 2018-04-20 10:51:38 -07:00
Brian Cain
975b8e774c
Get basic run triggers executing inline scripts 2018-04-20 10:51:38 -07:00
Brian Cain
d750169f6e
Add some logging around run and run_remote 2018-04-20 10:51:38 -07:00
Brian Cain
48b7c682ad
Use active machine object 2018-04-20 10:51:38 -07:00
Brian Cain
93af398f9e
Update params for NoStageGiven error 2018-04-20 10:51:38 -07:00
Brian Cain
bbf4e3c521
Reduce fire trigger methods to a single method 2018-04-20 10:51:38 -07:00
Brian Cain
eac2fcf71e
Filter triggers based on only_on restraint 2018-04-20 10:51:38 -07:00
Brian Cain
6373441ab2
Ensure guest name is a string 2018-04-20 10:51:38 -07:00
Brian Cain
76418b9fcd
Simplify trigger selection 2018-04-20 10:51:38 -07:00
Brian Cain
0e5cd900f8
Add missing param 2018-04-20 10:51:38 -07:00