Commit graph

5519 commits

Author SHA1 Message Date
Chris Roberts
54502d5d66
Merge pull request #324 from hashicorp/fix-packaged-hang
Fix hanging commands when using packaged installation
2022-07-26 09:12:50 -07:00
Chris Roberts
b917dc466a Implement stop on the ruby internal service 2022-07-25 14:30:45 -07:00
Chris Roberts
fda4aef9c7 Make server instance accessible, return integer value 2022-07-25 14:29:38 -07:00
Paul Hinze
fc76f71ffc
Fix vbox multimachine by setting provider parallel default correctly
Turns out I misinterpreted the behavior of a ruby method with a default
being passed nil so I assumed :parallel was effectively defaulting to
true when it is the opposite.
2022-07-25 15:52:11 -05:00
Sophia Castellarin
fe4956ac83
Merge pull request #314 from hashicorp/ruby-load-global-plugins
Load global ruby plugins
2022-07-25 09:40:00 -05:00
Sven Nierlein
8fe4ec4c8d
Update nfs_client.rb for rocky 9
Starting a rocky 9 box (having nfs shares) fails with: `No match for argument: nfs-utils-lib`.
Apparently Rocky 9 does not have a `nfs-utils-lib` but mounting nfs shares without nfs-utils-lib works fine.
So updating the nfs client install to only install `nfs-utils-lib` if the package is available. That way older rhel clones
should continue to work as well.
2022-07-21 13:49:31 +02:00
Paul Hinze
9ab94f9971
Fix crashes on Vagrantfiles with provisioners
I forgot to handle nil in the new PluginOptions stuff, and options are
nil for Provisioner plugins.
2022-07-20 17:36:05 -05:00
Paul Hinze
957d0d3779
Bring plugin options back to Ruby for providers and synced folders
This removes the need for the validation workaround for Docker, because
box_updated is once again available in that context.

We don't technically need the SyncedFolder priorities back on the Ruby
side, but wiring them through for symmetry.

Depends on https://github.com/hashicorp/vagrant-plugin-sdk/pull/183
2022-07-15 12:14:47 -05:00
sophia
5bc7218a70 Load global ruby plugins 2022-07-13 14:08:46 -05:00
Paul Hinze
8d46b09a11
Fix Docker machines being lost in go side
By pruning machines that are in "unknown" status after each operation,
the Go code path exposed the fact that the Docker provider was not
updating the machine index during an "up" - leaving the state as
"unknown".

This is basically a bug within the Docker provider, so I think it's okay
to update the plugin code to correct this rather than working around the
issue in Go.

All we need to do is call `machine.state` instead of reaching through to
`machine.provider.state` while waiting for the container to be started.
That causes the extra logic for updating the machine index in
`machine.state` to fire.
2022-07-13 14:04:32 -05:00
Chris Roberts
da9892a62f Use #to_proto on class match, otherwise convert 2022-07-11 15:09:46 -07:00
Chris Roberts
2572d4f62b Include class where error originated 2022-07-11 15:09:21 -07:00
Chris Roberts
e082fd6359 Machine mapper no longer needs to load through environment 2022-07-11 15:09:08 -07:00
Chris Roberts
67895c927e Allow a machine client to load its target 2022-07-11 15:08:53 -07:00
Chris Roberts
d5ec939022 Request target in spec and allow conversion to machine 2022-07-08 16:38:03 -07:00
Chris Roberts
19b4adb3b8 Implement get_value rpc in vagrantfile client 2022-07-08 16:38:02 -07:00
Paul Hinze
ee8883153c
Make Docker provider work again post config refactor
- Allow machine.box to be empty without sadness (depends on
   https://github.com/hashicorp/vagrant-plugin-sdk/pull/182)
 - Get synced folder type from plugin name instead of defaulting to
   :virtualbox
2022-07-08 11:36:27 -05:00
Sophia Castellarin
66a22e5254
Merge pull request #303 from hashicorp/synced_folder_has_override_opts
Synced folder has override opts
2022-07-07 16:28:14 -05:00
Chris Roberts
f5d778d51a Revert "Merge pull request #300 from hashicorp/optimize-ruby-command-list"
This reverts commit 1c26a4abb0, reversing
changes made to 186824a568.

The changes broke plugin loading when using subcommands so these
changes will be reverted until the underlying issue can be
investigated and resolved.
2022-07-07 14:03:56 -07:00
Paul Hinze
59a8e9bb0f
Merge pull request #306 from hashicorp/fix-capability-boolean-handling
Fix Type::Booleans leaking through capabilities
2022-07-07 14:21:05 -05:00
sophia
b17c36c7c7 Fix typo 2022-07-07 12:30:24 -05:00
Sophia Castellarin
0b53e06687
Merge pull request #297 from hashicorp/port-command-fix
Use remote provider
2022-07-07 12:21:48 -05:00
sophia
f1af42a7fc Don't use hash with indifferent access when converting hash
The HashWithIndifferentAccess will change all keys to strings when
merged with another regular hash. This causes errors in cases where
hashes are merged, for example in the action builder. Symbol/String
type data is kept over the wire, so there is no need to make the
mapped hash a HashWithIndifferentAccess.
2022-07-07 11:50:03 -05:00
sophia
73801703e7 Pass machine to provider capabilities 2022-07-07 11:49:57 -05:00
Paul Hinze
75d900c93b
Fix Type::Booleans leaking through capabilities
We had some cases where calling a capability that returned a boolean was
not getting correctly unpacked, so instead of `true` or `false` the
capability was putting out
`VagrantPlugins::CommandServe::Type::Boolean`.

This may have been happening in _all_ cases where a boolean was returned
from a capability and we just didn't notice it yet because the return
value was always truthy.

These tweaks should help ensure that Ruby types make it out where they
are supposed to be in Args::Direct usage.
2022-07-07 11:29:50 -05:00
Chris Roberts
1c26a4abb0
Merge pull request #300 from hashicorp/optimize-ruby-command-list
Optimize command list generation
2022-07-07 09:29:15 -07:00
Sophia Castellarin
186824a568
Merge pull request #302 from hashicorp/private-network
Rely on string/symbol maps for hash mapping
2022-07-06 13:20:41 -05:00
sophia
eeba305399 Rely on string/symbol maps for hash mapping
Relying on HashWithIndifferentAccess in Hash mappers results in
errors when hashes get merged in Ruby. When merges between regular
hashes and HashWithIndifferentAccess happens, then all the keys
from HashWithIndifferentAccess are transformed to strings.
2022-07-01 12:47:12 -05:00
Paul Hinze
fb2a102c71
Fix init and other commands that run without a project
The Basis needs to be able to respond to Vagrantfile() and
DefaultProvider() to make it through Vagrant::Environment
initialization.

Depends on https://github.com/hashicorp/vagrant-plugin-sdk/pull/178
2022-07-01 11:56:08 -05:00
Chris Roberts
6aa50189a2 Return empty results when no content to parse 2022-07-01 08:57:28 -07:00
sophia
20ec85b021 Use remote provider 2022-06-30 16:57:41 -05:00
Chris Roberts
067e6aeed1 Add get commands implementation to client and server 2022-06-29 16:13:36 -07:00
Chris Roberts
ffa10b4d85 Return integer value from serve command 2022-06-29 16:11:53 -07:00
sophia
adadf26c9c Check if communicator is available before detecting guests 2022-06-29 17:23:43 -05:00
sophia
f4d3f38921 Fix type in communicator#ready funcspec 2022-06-29 17:23:42 -05:00
Sophia Castellarin
a08204d4ba
Merge pull request #299 from hashicorp/fix-ruby-tests
Fix ruby tests
2022-06-29 17:23:23 -05:00
sophia
67a5c43873 Add Machine state direct converter 2022-06-29 16:03:22 -05:00
Paul Hinze
986e3fb258
Merge pull request #292 from hashicorp/box-collection-nit
Scope down rescue on BoxCollection.find
2022-06-28 15:23:33 -05:00
Chris Roberts
6d4abe2b08 Remove old proto constants 2022-06-27 11:26:22 -07:00
Chris Roberts
a2e0c5619e Use __finalized variable to determine finalization 2022-06-27 11:26:08 -07:00
Chris Roberts
0aad3390c9 Add funcspec mappers for finalize and merge wrappers 2022-06-24 18:29:53 -07:00
Chris Roberts
05baac1514 Update ruby config service to use wrapper protos 2022-06-24 18:27:38 -07:00
Chris Roberts
0d562673f9 Just print class information in error content 2022-06-24 18:27:00 -07:00
Paul Hinze
47962dff37
Scope down rescue on BoxCollection.find
After https://github.com/hashicorp/vagrant-plugin-sdk/pull/175 is merged
it will properly return a NotFound so we can rescue that specifically
and let any unexpected errors propagate.
2022-06-24 16:30:51 -05:00
Chris Roberts
778d009bfb Mark configs with unique id. Use id for provisioner caching. 2022-06-22 12:33:07 -07:00
Chris Roberts
8a41ef3396 Remove previous proto generation helpers 2022-06-21 16:51:08 -07:00
Chris Roberts
2ce2494f79 Don't use actual values in logger output 2022-06-21 14:41:28 -07:00
Chris Roberts
a9b62812ac Add box metadata conversion 2022-06-21 14:41:17 -07:00
Chris Roberts
83467013e9 Handle Set and Logger types 2022-06-20 16:56:30 -07:00
Chris Roberts
2890fb57c5 Finalize the entire Vagrantfile so all config is properly available 2022-06-20 16:04:01 -07:00
Chris Roberts
872812eaa4 Fix up some direct conversions to prevent wrong cache returns 2022-06-20 13:08:01 -07:00
Chris Roberts
b8fbe1ace5 Remove some extraneous logging 2022-06-20 13:07:31 -07:00
Chris Roberts
17fc49cf41 Add provider parsing to internal endpoint 2022-06-20 13:05:26 -07:00
Chris Roberts
43979be447 Fix logger usage in plugin manager 2022-06-15 11:14:07 -07:00
Chris Roberts
dc91194f9d Load direct conversions after setup 2022-06-15 11:14:07 -07:00
Chris Roberts
ede3b03f8c Update logger and call internal finalize on configs 2022-06-15 11:14:07 -07:00
Chris Roberts
55512ca0ef Provide easy access to global cache in clients 2022-06-15 11:02:29 -07:00
Chris Roberts
44afa299f0 Perform direct type conversions 2022-06-15 11:02:24 -07:00
Chris Roberts
c24960731f Add vagrantfile client 2022-06-15 10:56:19 -07:00
Chris Roberts
8fcabc2c1d Set global broker and cache values 2022-06-15 10:56:19 -07:00
Chris Roberts
70d725f8a0 Add support for origin value restrictions and custom weighting 2022-06-15 10:56:19 -07:00
Chris Roberts
53aae744a4 Allow callables to modify vertex weight 2022-06-15 10:56:19 -07:00
Chris Roberts
439546d58c Update input vertex to allow origin only setting 2022-06-15 10:56:19 -07:00
Chris Roberts
40cd6e8616 Allow marking inputs as only accepting origin value 2022-06-15 10:56:13 -07:00
Chris Roberts
9da90f0b21 Return false if RHS does not implement hash_code 2022-06-15 10:55:00 -07:00
Chris Roberts
45b9c48f03 Add Class to known types mapper. Indifferent access for hashes. 2022-06-15 10:55:00 -07:00
Chris Roberts
df3cc08b1f Add mappers for config data and procs 2022-06-15 10:55:00 -07:00
Chris Roberts
0a80ce1ea6 Remove config mappers from provisioner 2022-06-15 10:55:00 -07:00
Chris Roberts
a826287f34 Add mappers for the vagrantfile 2022-06-15 10:55:00 -07:00
Chris Roberts
2d5cb6b0fa Force the string proto value to be a string 2022-06-15 10:55:00 -07:00
Chris Roberts
dc5c643364 Add direct conversions of types 2022-06-15 10:55:00 -07:00
Chris Roberts
f949eb9042 Load new mappers and allow for direct conversion 2022-06-15 10:55:00 -07:00
Chris Roberts
4e869330cd Load config service and use global cache 2022-06-15 10:55:00 -07:00
Chris Roberts
8061a95a81 Update internal service plugins and vagrantfile loading 2022-06-15 10:55:00 -07:00
Chris Roberts
41a47617b0 Add config service for handling configuration 2022-06-15 10:55:00 -07:00
Chris Roberts
582f253605 Update types used for provisioner service 2022-06-15 10:55:00 -07:00
Chris Roberts
cde5479b8f Set value directly as it will have indifferent access 2022-06-15 10:55:00 -07:00
Chris Roberts
82efdf3e4b Remove extraneous logging from client setup 2022-06-15 10:55:00 -07:00
Chris Roberts
79f5264c5d Since we are inspecting, don't wrap value 2022-06-15 10:55:00 -07:00
Chris Roberts
a3dd70dd50 Allow for nested plugins 2022-06-15 10:55:00 -07:00
Chris Roberts
8024bd3bf5 Clean up names in funcspec helpers 2022-06-15 10:55:00 -07:00
Chris Roberts
babe5acdaf Remove custom to_proto methods from configs 2022-06-15 10:55:00 -07:00
Chris Roberts
555d8ae7a3 Adjust provisioner to upload file before modifying it 2022-06-15 10:55:00 -07:00
Paul Hinze
71cc8ee7bb
Fix some bugs in provider options handling
- Defaultable needs to default to true when it's not specified
- We need to allow a non-defaultable provider to be selected if it shows
  up in the config
2022-06-08 17:25:16 -05:00
Paul Hinze
8b08b3117c
Use plugin options for Synced Folder priorities
Now that plugin options are available, we can use them to interpret
synced folder priorities and remove the shim we had in place.
2022-06-06 17:39:09 -05:00
Paul Hinze
8dbe72a5a0
Use Component Options to implement ProviderOptions
* Populates ComponentOptions into plugin structs
* Maps options for legacy Provider Plugins into PluginOptions
* Demos use of PluginOptions in a stub provider
* Honors plugin priority and defaultable settings
2022-06-03 16:37:05 -05:00
sophia
194882214a Add machine readable bool endpoint to terminal ui 2022-05-31 15:47:47 -05:00
sophia
32bb18e9b9 Only output machine readable data if the terminal is not interactive 2022-05-31 10:53:21 -05:00
sophia
65e851d646 Output machine readable data as table 2022-05-31 10:28:26 -05:00
Paul Hinze
49aa226613
Temporary workaround to let Docker provider work
Comment has the details, but this should hopefully be short lived
2022-05-25 16:19:50 -05:00
Paul Hinze
02a06bca45
Fixes for provider capability invocations
It looks like I might have been the first to hit provider cabability
invocation in testing these changes, and so I found these few missing
methods on the client. They're just copied over from the other
capability hosts.

Calling capabilities on a provider also revealed that the wrong Machine
type was being pulled out of the funcspec args, so we had to correct
that too in order to get the capability calls working.
2022-05-25 16:19:50 -05:00
Paul Hinze
06350a7afc
Port default provider selection
- Pulls in the SDK changes to Project.DefaultProvider and Project.Target
- Implements the hefty default provider method
- Un-hard-codes provider from Target, and sets it when a Target is
  looked up from a Project
2022-05-25 16:19:50 -05:00
Paul Hinze
102e100108
client/target_index: Make yard comments conformant 2022-05-25 16:19:49 -05:00
sophia
2c0f43db3b Make flags that are only defined as --no- work 2022-05-23 11:41:08 -05:00
sophia
0b6781444a Resolve issue with Vagrant core providing more flag options than Vagrant legacy
This occurs when boolean flags in legacy Vagrant does
not define both a positive and negative boolean flag.
For example, --force and --no-force flags
2022-05-18 15:49:17 -05:00
sophia
28beec7bad Set alias for boolean flags that have a 'no-' option 2022-05-17 15:04:07 -05:00
sophia
887903c0e1 Set aliases for command flags 2022-05-17 14:06:04 -05:00
sophia
d708bab84a Add error message for errors originating from a remote 2022-05-13 17:14:50 -05:00
sophia
ba1384eb88 Fix machine mappers 2022-05-04 11:51:43 -05:00
sophia
e020c6600e Hacks to let a remote machine be instantiated with or with out a client 2022-05-04 11:25:54 -05:00
sophia
92a0b1c541 Allow remote machine to be initialized with just a machine client 2022-05-04 11:23:06 -05:00
sophia
31393eb3a9 Fill in some missing target client functions 2022-05-04 11:22:41 -05:00
sophia
0117c01e4b Fill in environment remote class 2022-05-04 11:22:41 -05:00
sophia
f340e192f2 Fill in project ruby client 2022-05-04 11:22:41 -05:00
sophia
0a37521ef2 Remove reload machine function from the grpc api 2022-05-04 09:32:36 -05:00
sophia
6dfca17d54 Get machine state from go impl 2022-05-04 09:32:36 -05:00
sophia
b4fbf76a33 Plug machine#uid methods into remote go backend 2022-05-04 09:32:36 -05:00
sophia
adf2340712 Update Ruby clients for proto changes 2022-04-25 14:12:28 -05:00
sophia
cddcfef0a1
Update Box#UpdateInfo to use box metadata client 2022-04-25 12:26:57 -05:00
sophia
35c094f570
Get box update info 2022-04-25 12:26:57 -05:00
Chris Roberts
9ab74271cf
Add some comments and expand some method documentation 2022-04-25 12:26:57 -05:00
Chris Roberts
f220ac2f94
Add name based re-weight helper. Add documentation/comments. 2022-04-25 12:26:56 -05:00
Chris Roberts
f9e55a8f9d
Fill in vertex base methods 2022-04-25 12:26:56 -05:00
Chris Roberts
66c9fd45d6
Map key and value when converting Hash types 2022-04-25 12:26:56 -05:00
Chris Roberts
1bf4c8d090
Provide Graph#each_vertex helper to graph 2022-04-25 12:26:56 -05:00
Chris Roberts
12cb795392
Add name support for inputs 2022-04-25 12:26:56 -05:00
Paul Hinze
eacb798a71
Fix action hooks running twice in destroy_on_error scenarios
The "destroy_on_error" functionality for `vagrant up` is implemented in
the `recover()` action chain, and works by firing off a destroy action
from inside that chain.

This is all well and good, but it copies its existing `env` which has
had `action_name` set for the up action. This was causing action_hooks
for up actions to attach to this destroy action stack.

Setting the action_name explicitly in the env before firing the runner
should correct the behavior. I'm not sure if raw_action_name is used
anywhere but I figured it was better to be consistent vs conservative in
what we change.
2022-04-25 12:26:56 -05:00
Chris Roberts
305fddb49a
Retry cached path executions with full graph 2022-04-25 12:26:55 -05:00
Chris Roberts
f3a3bb83fd
Only register types for blind maps after a blind map 2022-04-25 12:26:55 -05:00
Chris Roberts
e8a4c35cf6
Remove any unpacking of value prior to mapping 2022-04-25 12:26:55 -05:00
Chris Roberts
2baea78820
Properly clone mappers 2022-04-25 12:26:55 -05:00
Chris Roberts
823e589a26
Freeze base mappers list to prevent direct modifications 2022-04-25 12:26:55 -05:00
Chris Roberts
2f9daa8498
Include value in error message when mappers not found 2022-04-25 12:26:55 -05:00
Chris Roberts
61b5d3549f
Don't use blind mapping when generating value 2022-04-25 12:26:54 -05:00
Chris Roberts
3917449552
Provide source information when mapping, register blind maps 2022-04-25 12:26:54 -05:00
Chris Roberts
f6a46634a5
When performing a blind map, if previous mapping found, use it 2022-04-25 12:26:54 -05:00
Chris Roberts
1d555b025f
Use global list of mappers and cache as defaults 2022-04-25 12:26:54 -05:00
Chris Roberts
7404ef89a6
Isolate generate class from instance so we can do class checks 2022-04-25 12:26:54 -05:00
Chris Roberts
8cc6116cdf
Store previous successful lookups for future graph generation 2022-04-25 12:26:54 -05:00
Chris Roberts
aaed7b2d82
Update Method vertex hash code and allow callable access 2022-04-25 12:26:54 -05:00
Chris Roberts
3a6308b7fc
Use blocks for logging content to reduce processing 2022-04-25 12:26:54 -05:00
sophia
7b470d4b25
Ensure box metadata has optional arguments 2022-04-25 12:26:53 -05:00
sophia
03ecb877e6
Update box metadata Name endpoint to boxName 2022-04-25 12:26:53 -05:00
sophia
66524426d0
Update ruby remote box metadata for proto changes 2022-04-25 12:26:53 -05:00
sophia
0556c804fd
Add load metadata client endpoint 2022-04-25 12:26:52 -05:00
sophia
1f5d66fd76
Get box metadata client from box 2022-04-25 12:26:52 -05:00
sophia
428c3b02fd
Use remote box metadata implementation 2022-04-25 12:26:52 -05:00
sophia
3e641fbe6b
Stub machine index proto mapper for environment test 2022-04-25 12:26:51 -05:00
sophia
333fc16096
Map provisioner config to Hash using mappers instead of assuming Struct type 2022-04-25 12:26:51 -05:00
sophia
7dd3649d73
Update Symbol proto mappers 2022-04-25 12:26:51 -05:00
sophia
d5aacc0bc6
Thrash around making to proto for config faster 2022-04-25 12:26:51 -05:00
sophia
f4811af759
Use symbol proto when protoizing plugin configs 2022-04-25 12:26:51 -05:00
sophia
ccf2bf6197
Pass config as a SDK hash in order to use the Symbol proto 2022-04-25 12:26:51 -05:00
sophia
9a61574f52
Add core plugin manager to default mapper list 2022-04-25 12:26:50 -05:00
sophia
b40dde3797
Module for core plugin manager mappers 2022-04-25 12:26:50 -05:00
sophia
afc6d1c27d
Extract core plugin manager from context 2022-04-25 12:26:50 -05:00
sophia
05244e67c1
Add mappers for core plugin manager 2022-04-25 12:26:50 -05:00
sophia
b3003e8cb6
Add core plugin service client 2022-04-25 12:26:50 -05:00
Paul Hinze
1341bfe0af
Tweak Ruby->Go error handling so exit codes match
In legacy Vagrant, any exception raised that's a subclass of
Vagrant::Errors::VagrantError is considered user-facing and so causes
the error message to be printed to the console and the process to use
exit code 1. Anything outside of that causes the process to use exit
code 255. (See `bin/vagrant` for the code.)

Here we mirror that behavior by treating errors that have a
LocalizedMessage as user-facing and those without as unexpected. This
allows the basic virtualbox component to pass in vagrant-spec!
2022-04-25 12:26:49 -05:00
Paul Hinze
09c03893b2
Simplify truncate_to per feedback
No need to spin up a full regexp if it's not necessary!
2022-04-25 12:26:49 -05:00