71 Commits

Author SHA1 Message Date
Paul Hinze
ff86d86ac8
Provisioner Plugins 2022-04-25 12:26:37 -05: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
sophia
5607428a66 Don't try to recover machine without a uuid 2020-09-15 11:16:13 -05:00
sophia
943047d003 Add tests for synced folder collections 2020-08-19 17:57:57 -05:00
sophia
faad9f2717 Add tests 2020-08-19 15:00:40 -05:00
sophia
1661d1f1cf Print help message if user provides and ambiguous option 2020-07-06 10:52:05 -05: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
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
3686aed72d Add test coverage for dynamic action hook support 2020-03-03 16:23:31 -08: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
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
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
Brian Cain
5723c7181a
Add test for trigger run path with spaces 2018-08-17 15:17:49 -07:00
Brian Cain
8bce4f3828
Update tests to include passed in arg values 2018-08-14 13:24:42 -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
2000a11042
Add tests for powershell run functions 2018-04-20 10:51:38 -07:00
Brian Cain
e7d07cb110
Add rspec tests for trigger plugin 2018-04-20 10:51:38 -07:00
Brian Cain
6ea7819402
Update rspec tests for trigger plugin 2018-04-20 10:51:38 -07:00
Brian Cain
fbad4c749d
Add basic spec test for trigger class 2018-04-20 10:51:38 -07:00
Brian Cain
8b1043c199 Remove stub methods and replace with allows for rpsec 3 2017-08-04 15:02:59 -07:00
Chris Roberts
1a62743bc5 Update rspec to recent version and fix deprecations 2017-08-03 17:54:07 -07:00
Mitchell Hashimoto
85f1e05e2a core: prune machine if non-existent CWD from index [GH-4742] 2015-11-18 15:48:59 -08:00
Mitchell Hashimoto
69d9bc0fe8 Environment can_install_provider and install_provider 2015-11-05 11:50:10 -08:00
Mitchell Hashimoto
e759df11a0 core: fix crash for missing options [GH-5550] 2015-07-06 10:36:41 -06:00
Seth Vargo
f3c35855f0 Add a newline because #ocd 2014-12-08 11:35:11 -08:00
Seth Vargo
7f6a4fa3bd Add tests for plugin manager push_configs 2014-12-08 11:35:11 -08:00
Seth Vargo
60a8472891 Use a pushes registry instead of data hash 2014-12-08 11:35:09 -08:00
Matt Wrock
dc628cd722 fixes infinite loop in machine state call if provider calls machine.action 2014-11-06 08:51:47 -08:00
Kalman Hazins
bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Mitchell Hashimoto
c5b3dbbf75 core: fix final test 2014-05-01 10:12:36 -07:00
Mitchell Hashimoto
429bd73495 core: provider has default priority of 5 2014-05-01 09:26:36 -07:00
Mitchell Hashimoto
e78d087c27 Tests passing 2014-04-21 13:54:59 -07:00
Mitchell Hashimoto
bc2e3727a9 core: Add usable? check to providers 2014-04-21 13:53:07 -07:00
Mitchell Hashimoto
a0e9f46251 core: commands can use the IDs from anywhere to control 2014-04-21 13:51:24 -07:00
Fabio Rehm
54656151cf Convert specs to RSpec 2.14.8 syntax with Transpec
This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

* 507 conversions
    from: obj.should
      to: expect(obj).to

* 394 conversions
    from: == expected
      to: eq(expected)

* 260 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 85 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

* 19 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
2014-03-14 12:02:07 -03:00
Mitchell Hashimoto
d40dc919d8 core: plugin tests no longer obliterate manager 2014-02-06 20:50:51 -08:00
Mitchell Hashimoto
f72db0c611 core: config raises NoMethodError on bad calls once finalized 2014-02-05 16:14:58 -08:00
Mitchell Hashimoto
a924a7b48c core: provider capabilities 2014-01-26 14:15:06 -08:00
Mitchell Hashimoto
f713e43b00 Fix tests for new UI methods 2014-01-17 21:03:02 -08:00
Mitchell Hashimoto
08b1aee00d core: default commands to primary 2014-01-11 09:15:14 -08:00
Mitchell Hashimoto
4a99cdccdf core: allow command plugins to have options 2014-01-11 08:38:27 -08:00
Mitchell Hashimoto
010874ffad core: has_plugin? uses the new plugin manager class to check for gems 2014-01-08 10:50:28 -08:00
Mitchell Hashimoto
5922241fcb core: Modify plugin interfaces and API for hosts 2014-01-07 18:38:49 -08:00