73 Commits

Author SHA1 Message Date
Chris Roberts
e958c6183a Adds initial HCP config support
Adds initial basic support for HCP based configuration in vagrant-go.
The initalization process has been updated to remove Vagrantfile parsing
from the client, moving it to the runner using init jobs for the basis
and the project (if there is one). Detection is done on the file based
on extension for Ruby based parsing or HCP based parsing.

Current HCP parsing is extremely simple and currently just a base to
build off. Config components will be able to implement an `Init`
function to handle receiving configuration data from a non-native source
file. This will be extended to include a default approach for injecting
defined data in the future.

Some cleanup was done in the state around validations. Some logging
adjustments were applied on the Ruby side for better behavior
consistency.

VirtualBox provider now caches locale detection to prevent multiple
checks every time the driver is initialized.
2023-09-07 17:26:10 -07:00
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
6d88f3a54f Fix up some of the testing 2023-06-05 14:18:53 -07:00
sophia
7441927f06 Set not created machine state when appropriate 2022-07-25 15:16:40 -05:00
Chris Roberts
58fce40886 Add AsTarget() to machine and include nicer output 2022-07-11 15:08:08 -07:00
Chris Roberts
08bcc8e9c7 When unsetting machine ID, just set state to not created 2022-07-08 16:38:02 -07:00
Chris Roberts
0a4b9c9019 Always save the target when saving machine 2022-07-08 16:38:02 -07:00
Chris Roberts
b82d55cc37 Update vagrantfile to load machines via factory 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
ffc2dd729b Use more generic hash for folder options. This will allow using exisiting mappers 2022-07-07 12:30:24 -05:00
Paul Hinze
91478e9e0a
Fix method for getting default synced folder type
As a part of a series of larger changes the default synced folder type
accidentally got wired up to DefaultProvider instead of its dedicated
defaultSyncedFolderType() method.

This was working fine for "virtualbox" where the provider name and the
synced folder name are both the same, but it was causing virtualbox
synced folders to be selected when using the "docker" provider and
making things break.

This is one necessary step to get machine lifecycles working again with
Docker.
2022-07-07 11:24:53 -05:00
sophia
adadf26c9c Check if communicator is available before detecting guests 2022-06-29 17:23:43 -05:00
Chris Roberts
9783951719 Ensure caching and use default provider value 2022-06-27 18:08:02 -07:00
Chris Roberts
f50f700e5c Update machine to use vagrantfile for synced folders 2022-06-20 13:01:13 -07:00
Chris Roberts
e03058d9e8 Fix up synced folder collection generation 2022-06-15 11:15:04 -07:00
Chris Roberts
7e387b6d10 Update core scopes to use Vagrantfile 2022-06-15 11:13:40 -07: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
4d79c95177
Update tests and address one thing caught by them
Namely, the specified synced folder type should override the default type
2022-05-25 17:56:40 -05:00
Paul Hinze
25fcf61364
Sort synced folder plugins by priority and honor allowed setting
It turns out that synced folder plugins aren't returned in a consistent
order, which was causing all kinds of mayhem.

We can tone down that mayhem by implementing a shim of priority sorting
the plugins. This shim can be removed once we have proper priority
registration in the SDK.
2022-05-25 16:19:50 -05:00
sophia
8801e030b7
Get default synced folder type
(cherry picked from commit cd6baafb9238a58e992519e0576565d1a57bf8f5)
(but modified to work)
2022-05-25 16:19:50 -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
398d982408 Add decode hook for string -> path.Path 2022-04-25 14:12:28 -05:00
Chris Roberts
7e68e25994
Seed target and machine into plugins directly 2022-04-25 12:26:58 -05:00
sophia
6313596d62
Remove manual seeding of (guest and synced folder) plugins 2022-04-25 12:26:53 -05:00
sophia
ac18a1c001
Don't add a box to the db when querying the machine for it's box
If the box does not exist in the db, then a box will be returned
with the name and provider information. All other box information
at that point is unknown.
2022-04-25 12:26:45 -05:00
sophia
c60836fc12
Get box provider from target 2022-04-25 12:26:45 -05:00
Paul Hinze
7c1d2e5368
Use optional fields on Synced Folder instead of empty string checks
Addresses concerns raised in discussion here
https://github.com/hashicorp/vagrant-ruby/pull/219#discussion_r816966056
and makes it so we don't have to change any plugin code to make things
work.

Depends on https://github.com/hashicorp/vagrant-plugin-sdk/pull/133
2022-04-25 12:26:44 -05:00
sophia
7f0adfce78
Add tests for synced folders 2022-04-25 12:26:42 -05:00
sophia
727bf91b18
Raise error if no guest plugins found 2022-04-25 12:26:40 -05:00
Chris Roberts
64751ae8b9
Update machine ID storage to prevent lost ID 2022-04-25 12:26:39 -05:00
sophia
2519b9b6ac
Clear target record when destroying machine 2022-04-25 12:26:38 -05:00
Chris Roberts
b10ff0d51d
Sort guest plugins before running detection
When detecting the machine guest, first sort the guest plugins
    by the number of ancestors. This allows for returning on the
    first match instead of requiring running the detection process
    on every registered guest plugin.
2022-04-25 12:26:36 -05:00
sophia
6daa8d52a2
Remove code for avoiding duped synced folders in config 2022-04-25 12:26:34 -05:00
sophia
19f3d2f0b6
Refactor named plugin bits to apply to all components 2022-04-25 12:26:33 -05:00
sophia
153d218d68
Set plugin name 2022-04-25 12:26:32 -05:00
Chris Roberts
bf393065fa
Update guest and synced folder plugin loading to seed machine 2022-04-25 12:26:31 -05:00
sophia
896cdea21f
Delete machine from db 2022-04-25 12:26:23 -05:00
sophia
3dbd9286be
Merge targets with upserting 2022-04-25 12:26:23 -05:00
sophia
12de22a7db
Get machine state 2022-04-25 12:26:23 -05:00
sophia
8a39ee6960
Set target state in addition to machine state 2022-04-25 12:26:22 -05:00
Chris Roberts
acb32d33f7
Get parent count directly from plugin 2022-04-25 12:26:14 -05:00
sophia
9ea254735a
Set target uuid opposed to resource id
The uuid is the public identifier vs the resource id which should
be for internal operations.
The target uuid should correspond to the machine id (given by
the provider)
2022-04-25 12:26:13 -05:00
sophia
63a4b76c21
Add tests for setting machine id 2022-04-25 12:26:13 -05:00
sophia
294293097c
Set empty machine id when destroying 2022-04-25 12:26:13 -05:00
sophia
ea680d78f7
Seed synced folder plugins with machine 2022-04-25 12:26:12 -05:00
sophia
a86bf277aa
Use guest specified in vagrantfile if available 2022-04-25 12:26:11 -05:00
sophia
31e57414b4
Destroy machine + remove data dir when machine id is set to empty value 2022-04-25 12:26:11 -05:00
sophia
1fe695bdf3
Use Vagrantfile info to configure target box 2022-04-25 12:26:06 -05:00