72 Commits

Author SHA1 Message Date
Chris Roberts
ee85eed227 Check that project ref is set before using 2022-06-27 11:23:57 -07:00
Chris Roberts
139349b136 Remove vagrantfiles from default arguments in call 2022-06-24 18:25:50 -07:00
Chris Roberts
3e783b6074 Fix up project vagrantfile usage and target init 2022-06-20 13:00:42 -07:00
Chris Roberts
ab34fddbc4 Remove automatic target initialization, update caching 2022-06-15 11:15:08 -07:00
Chris Roberts
7e387b6d10 Update core scopes to use Vagrantfile 2022-06-15 11:13:40 -07:00
Paul Hinze
f2417e09a8
Merge pull request #284 from hashicorp/provider-options-bugfixes
Fix some bugs in provider options handling
2022-06-08 18:02:31 -05: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
8b5d4b8631
Update and address protobuf package deprecations
These changes address the following warning showing up on `go get`
operations:

    go: module github.com/golang/protobuf is deprecated: Use the
    "google.golang.org/protobuf" module instead.

All changes are made using the recommendations in the per-function
deprecation notices from the docs at
https://pkg.go.dev/github.com/golang/protobuf/ptypes
2022-06-08 11:51:19 -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
Paul Hinze
88822f5a96
Override provider for all non-active targets
Instead of only targets with empty providers. This helps address a
problem that @soapy1 found in review where machines that failed to come
up would get stuck with the wrong provider.
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
625806f448
Don't delete machine datadir when SetId("") is called
Legacy's `Machine#id=()` has an important side effect when a nil ID is
specified - it clears the contents of the machine's DataDir.

We mirrored this behavior over to gogo, with a subtle difference - we
deleted the whole DataDir vs just its children.

It turns out the Docker provider relies on the DataDir being
cleared-but-not-removed by doing a SetId dance in its InitState action.
(see 1e6259dd00d702f83048c75c5c229ce6494c4c6e).

So here we need to mirror that behavior in order for the Docker provider
to work properly.
2022-05-25 13:41:48 -05:00
sophia
bb30ff94ff Don't refresh the project more then necessary
The project does not need to be retreived from the db every time
it is queried for data. However, it does need to be updated whenever
a target is initialized from the project (eg. an upsert machine
action happens). This is because upserting a target will update the
associated project. Leaving the core.Project with stale data
unless it is refreshed.
2022-05-10 15:24:14 -05:00
sophia
da3ab7f9b3 Refresh project when querying for project info
It is not guaranteed which project is ever being used. So whenever
some project property is queried make sure to refresh the project
by getting the latest one from the database.
2022-05-04 11:23:46 -05:00
sophia
053d658e52 Get default provider from go side
For now the go side will just return a hard coded value for the
default provider. It should be implementing the algorithm defined
at https://www.vagrantup.com/docs/providers/basic_usage.html#default-provider
2022-05-04 11:23:12 -05:00
sophia
25dfcd039f Update paths to use Path type instead of string 2022-04-25 14:12:28 -05:00
sophia
02a0409ca8
Make core Project implement the Project interface from the sdk 2022-04-25 12:26:58 -05:00
Chris Roberts
7e68e25994
Seed target and machine into plugins directly 2022-04-25 12:26:58 -05:00
sophia
a7d258abb3
Seed target after creation 2022-04-25 12:26:53 -05:00
Paul Hinze
8f9952089a
Fix commands that run without a project
Some commands like `vagrant init` and `vagrant box` should be able to
run successfully without a full Project available in VAGRANT_CWD (in
other words, they don't require that a valid Vagrantfile be available.)

Thus far we've been assuming that a Project is available when
dispatching commands, which mean that commands of this nature weren't
working.

Here we make the Basis available to serve as an alternative client to
Vagrant::Environment::Remote such that it can be instantiated and passed
through to commands. This required some changes to Environment::Remote
to make its interactions with the client more defensive, but we manage
to avoid needing to make any changes to the normal legacy codepaths.
2022-04-25 12:26:47 -05:00
Paul Hinze
61fbd0f622
Move Basis, Project, and Target seeding earlier
Having these objects populate their seeds during `Run` was too late for
those values to show up in command plugins, which would be seeded with
empty args instead.

h/t @chrisroberts for the debugging help and fix suggestion!
2022-04-25 12:26:47 -05:00
sophia
8547cb696d
Test project 2022-04-25 12:26:42 -05:00
Paul Hinze
92c345b42d
Allow go push plugins to use config from Vagrantfile
* Populate push configs when parsing the vagrantfile
* Allow untyped configs to be shipped over GRPC
* In our demo plugin, walk the vagrantfile and snag the config

Example Vagrantfile that works with the demo plugin:

```ruby
Vagrant.configure("2") do |config|
  config.push.define "myplugin" do |push|
    push.coolkey = "coolvalue"
    push.alist = ["so", "many", "items"]
    push.ahash = { "hashkey" => "hashvalue" }
  end
end

```
2022-04-25 12:26:21 -05:00
sophia
aeda0ec039
Pass error status with job completion results 2022-04-25 12:26:20 -05:00
Paul Hinze
2460961749
Switch to centralized VagrantCWD implementation
Now depends on https://github.com/hashicorp/vagrant-plugin-sdk/pull/104
2022-04-25 12:26:12 -05:00
sophia
36dbd73945
Add endpoint for accessing basis/project/target config 2022-04-25 12:26:06 -05:00
sophia
0153f75b09
Remove unused core components 2022-04-25 12:26:06 -05:00
Chris Roberts
6b37b7ba55
Add seed functions and seed before running 2022-04-25 12:26:05 -05:00
sophia
de996a6047
Move box loading to machine 2022-04-25 12:26:01 -05:00
sophia
d49944a25d
Only init targets when running a job scoped at the project or target 2022-04-25 12:26:01 -05:00
Chris Roberts
a2147ed27f
Update basis ResourceId to match interface 2022-04-25 12:25:59 -05:00
sophia
d786649e03
Add box if not found in box collection 2022-04-25 12:25:55 -05:00
sophia
2dfb9b933e
Get boxes from project 2022-04-25 12:25:55 -05:00
sophia
2b93a26b50
Inject a box into the machine
This should be updated once the box collection and provider are
implemented in order to select the right box from the box
collection.
2022-04-25 12:25:54 -05:00
Chris Roberts
7595f1533f
Enable plugin mappers 2022-04-25 12:25:50 -05:00
Chris Roberts
7cc07642a5
Use project for host capabilities 2022-04-25 12:24:47 -05:00
sophia
b30bbcb13a
Don't check for 'found' in basis/project/target query results 2022-04-25 12:24:39 -05:00
sophia
591dcced22
Remotve machine names function from project 2022-04-25 12:24:37 -05:00
sophia
5ca687cad4
Implement project home path, cwd and default private key 2022-04-25 12:24:36 -05:00
Chris Roberts
8b8f5adf67
Defer the unlock when loading target 2022-04-25 12:24:31 -05:00
Chris Roberts
c562132e11
Update save behavior of project and get target index from basis 2022-04-25 12:24:31 -05:00
Chris Roberts
9319409d45
Load all targets defined within project 2022-04-25 12:24:29 -05:00
Chris Roberts
b9478e7eee
Load target when not already loaded 2022-04-25 12:24:29 -05:00
sophia
806f6e7399
Set a target dir when loading from a project 2022-04-25 12:24:29 -05:00
sophia
10a1f1011b
Get datadir for machine and project 2022-04-25 12:24:29 -05:00
sophia
3e74501d26
Get full path to Vagrantfile without Vagrantfile name 2022-04-25 12:24:28 -05:00
sophia
6cde007530
Get Vagrantfile path from project 2022-04-25 12:24:28 -05:00
sophia
6eea1b0afd
Add endpoint for getting all machines from the index 2022-04-25 12:24:27 -05:00
sophia
b22c128671
Get a target from target index 2022-04-25 12:24:26 -05:00
sophia
551aa2970f
Rename machine index to target index 2022-04-25 12:24:25 -05:00