74 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
sophia
49280286ad Strip new lines from error details
The error details message should just be one string without spacing
so the terminal can set a output length. This will allow messages
from Ruby and Go errors to have similar formating.
2022-09-19 15:14:42 -04:00
sophia
add66c4c2a Include message in rpc status error from ruby 2022-09-19 15:14:42 -04:00
Paul Hinze
7c56c74bb6
Support and honor the "primary" option for Command plugins 2022-07-27 11:36:04 -05:00
sophia
c2d8f892ac Find type to unany objects when mapping
find_types works fine until you have a module which has the same name but different case. For example, the VagrantVmware package is HashiCorp::VagrantVMwareDesktop. All the protos are at Hashicorp::Vagrant::… So, you end up with this fun

Object.constants.select { |n| n.to_s.downcase == "hashicorp" }
=> [:HashiCorp, :Hashicorp]

So, when trying to walk down the modules to find the right type to unany to, Vagrant sometimes takes the wrong path (eg. Down the HashiCorp module instead of the Hashicorp module).

This change will keep a list of the parent modules when walking down the module list. This way if a dead end is reached then Vagrant can go a level back and keep searching for the correct class.
2022-07-26 12:22:28 -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
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
sophia
67a5c43873 Add Machine state direct converter 2022-06-29 16:03:22 -05:00
Chris Roberts
a2e0c5619e Use __finalized variable to determine finalization 2022-06-27 11:26:08 -07:00
Chris Roberts
778d009bfb Mark configs with unique id. Use id for provisioner caching. 2022-06-22 12:33:07 -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
872812eaa4 Fix up some direct conversions to prevent wrong cache returns 2022-06-20 13:08:01 -07:00
Chris Roberts
ede3b03f8c Update logger and call internal finalize on configs 2022-06-15 11:14:07 -07:00
Chris Roberts
dc5c643364 Add direct conversions of types 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
sophia
afc6d1c27d
Extract core plugin manager from context 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
Paul Hinze
253c6658b3
Truncate error message to address RST_STREAM issues
This is the result of a whole journey of learning about GRPC errors! See
the hefty inline comment which has all the context for future
generations.
2022-04-25 12:26:49 -05:00
Paul Hinze
06ad1b4565
Fixup tests for Ruby 3.0
This is a pass through test failures and deprecation warnings:

 * Make all ambiguous `.with(..., key: val)` use explicit hashes to
   prevent test failures for argument mismatch in Ruby 3.0
 * Scope down all unbounded `raise_error` to address warnings (remove
   one test that was revealed to be referencing a nonexistent variable
   once the raise_error was scoped.)
 * Update all `any_instance` usage to new syntax to address warnings
 * Allow the service cache to be cleared and do so between some tests
 * Fix a small bug in with_plugin's plugin not found code path (revealed
   by a scoped and_raise)
2022-04-25 12:26:40 -05:00
Chris Roberts
74ff5da434
Trace item registration in the cache 2022-04-25 12:26:39 -05:00
Chris Roberts
6dd5a3ae9b
Load plugins within #with_plugin helper 2022-04-25 12:26:39 -05:00
Chris Roberts
b0b5d1191e
Update and document cacher 2022-04-25 12:26:38 -05:00
Chris Roberts
f88254eb23
Let #with_plugin load plugins by type 2022-04-25 12:26:38 -05:00
Chris Roberts
3e7f72b9b0
Extract direct arguments to use for spec 2022-04-25 12:26:37 -05:00
Chris Roberts
987998aa41
Grab cacher from local instance 2022-04-25 12:26:37 -05:00
Chris Roberts
b976be72bd
Simplify cacher 2022-04-25 12:26:37 -05:00
Chris Roberts
d82702064f
Only deactivate remote plugin manager if activated 2022-04-25 12:26:37 -05:00
Chris Roberts
83ca40e239
Refactor Ruby service implementations
Update the Ruby service implementations to use the funcspec util
    module for generating spec content. A helper method is now used
    for generating a parent class for services to subclass which
    automatically includes all required modules for usage.
2022-04-25 12:26:37 -05:00
Paul Hinze
ff86d86ac8
Provisioner Plugins 2022-04-25 12:26:37 -05:00
Chris Roberts
095a0f8847
WIP checkpoint with callable remote provider action 2022-04-25 12:26:35 -05:00
Chris Roberts
d2f795e11b
Provide client to manager enable helper method 2022-04-25 12:26:35 -05:00
sophia
6c28de9ea9
Refactor named plugin service/client endpoints 2022-04-25 12:26:33 -05:00
Chris Roberts
cd99ff6525
Add logging to funcspec helper and build named types correctly 2022-04-25 12:26:30 -05:00
Chris Roberts
14895eded1
Grab value from cache when mapping 2022-04-25 12:26:29 -05:00
Chris Roberts
58dd2e491f
Update cacher implementation 2022-04-25 12:26:28 -05:00
Chris Roberts
e29011d0b3
Add FuncSpec module
This module provides helper methods for handling FuncSpecs
    and generating FuncSpec::Args protos. At this stage it is
    intended for use in client implementations
2022-04-25 12:26:28 -05:00
sophia
891eb27e9a
Rename plugin "target" to "addr" 2022-04-25 12:26:27 -05:00
sophia
93ec8c1571
Refactor with_plugins util 2022-04-25 12:26:24 -05:00
sophia
f3a1a9caa6
Add dependency on common protos for error details 2022-04-25 12:26:24 -05:00
sophia
75e6081e6d
Fill in provider ruby service 2022-04-25 12:26:23 -05:00
sophia
53f7b3f8eb
Update tests for GRPC errors 2022-04-25 12:26:20 -05:00
sophia
deb667ecd3
Use common rpc errdetails messages 2022-04-25 12:26:20 -05:00
sophia
df5f7d40e8
Rename exception logger to exception transformer
The exception logger no longer logs errors. Instead it transforms
the errors into a grpc friendly format. The exception that would
have been logged at this point gets logged when the task completes.
2022-04-25 12:26:20 -05:00