15453 Commits

Author SHA1 Message Date
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
sophia
211da5be23
Remove box count check when trying to recover boxes
The get box + stat operations are not that slow. No need to also
go through listing out all the boxes in the vagrant box dir.
2022-04-25 12:26:49 -05:00
sophia
c23e617fce
Check for metadata.json 2022-04-25 12:26:49 -05:00
sophia
0d38ccf20c
Create boxes dir if it does not exist 2022-04-25 12:26:49 -05:00
sophia
b3f8c5a99d
Add test for removing boxes that are no longer available 2022-04-25 12:26:48 -05:00
sophia
385bcbf81b
Remove box from db if it is no longer available on disk 2022-04-25 12:26:48 -05:00
sophia
82fa38f5e0
Check for consistency between db/boxes dir when creating box collection 2022-04-25 12:26:48 -05:00
sophia
aa9a03b9de
Ensure consistency between box db and dir 2022-04-25 12:26:48 -05:00
Paul Hinze
a4f426d26e
Modify SSH utils server mode behavior so ssh -c works
Still work left to do on exec and stderr separation but this represents
enough working to let vagrant-spec assertions pass so I think it's worth a
checkpoint!
2022-04-25 12:26:48 -05:00
Paul Hinze
fda2bcf0cd
Refactor SSHRun action to make room for remote overrides 2022-04-25 12:26:48 -05:00
Paul Hinze
6471a5a310
Refactor Util::SSH to make room for remote overrides
Splitting out methods gives us a place to hook in appropriate behavior
for when we're running in a GRPC server.
2022-04-25 12:26:48 -05:00
Paul Hinze
7f56168959
Work around a few global flag collisions for ssh command
* `vagrant ssh` has a --no-tty flag colliding with the one defined in
   `bin/vagrant` - in fact none of the flags in `bin/vagrant` are
   processed in `serve` mode, so remove the code that captures them from
   the CommandInfo OptionParser dance
 * `vagrant ssh` has a `--plain` flag colliding with the one defined in
   `internal/cli/base.go` - this flag was inherited from Waypoint, so we
   can just rename it to line up with the (inversely defined) `--color`
   flag used in legacy vagrant
2022-04-25 12:26:48 -05:00
sophia
57babc2f79
Bump sdk 2022-04-25 12:26:48 -05:00
sophia
d3f22f3a68
Don't count machines that have not been created when looking for boxes in use 2022-04-25 12:26:48 -05:00
sophia
6e420689cb
Update Target State for updated states 2022-04-25 12:26:48 -05:00
sophia
b62bdd8efb
Add missing Target states to proto 2022-04-25 12:26:47 -05:00
Paul Hinze
0803b026b3
Bump sdk 2022-04-25 12:26:47 -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
Paul Hinze
80ba98cefb
Add debug target to Makefile
The default target gets a `-gcflags=""` arg added, but that should be
neutral.
2022-04-25 12:26:47 -05:00
sophia
c26d627e5a
Bump sdk 2022-04-25 12:26:47 -05:00
sophia
725f7a3b6e
go generate 2022-04-25 12:26:47 -05:00
sophia
128599ab68
Get local box metadata in remote box 2022-04-25 12:26:47 -05:00
sophia
e9e24986bd
Add ability to get metadata associated with a box 2022-04-25 12:26:47 -05:00
sophia
4af9e4166d
Bumo sdk 2022-04-25 12:26:47 -05:00
sophia
2b4c99aaa0
Don't add destroyed machines to list of active machines when searching for box usage 2022-04-25 12:26:46 -05:00
sophia
b6d42d0695
Clean up machine client 2022-04-25 12:26:46 -05:00
sophia
29d5b3627d
Always assume machine entry is valid on the ruby side 2022-04-25 12:26:46 -05:00
sophia
f55da8168a
Check if a box is in use using the machines endpoint
This returns a list of machine index entries that use the box. This
is what is expected from the Ruby side.
2022-04-25 12:26:46 -05:00
sophia
4dcd120448
Load machine from machine ref 2022-04-25 12:26:46 -05:00
sophia
c13dcc938c
Only include machines that have been created 2022-04-25 12:26:46 -05:00
sophia
30c75b4d4d
go generate 2022-04-25 12:26:46 -05:00
sophia
a39747cc59
go generate 2022-04-25 12:26:46 -05:00
sophia
62e049e201
Implement box machines 2022-04-25 12:26:46 -05:00
sophia
f1aec2c1c2
Return machine name as sym 2022-04-25 12:26:46 -05:00
sophia
bc641209e8
Check for box version 2022-04-25 12:26:46 -05:00
sophia
ba0bb1d9c6
Add machine tests for boxes 2022-04-25 12:26:45 -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
7eccedba12
Add test for box with 0 version number 2022-04-25 12:26:45 -05:00
sophia
fc649b0937
Set first match without version constraint 2022-04-25 12:26:45 -05:00
sophia
517c33aacf
Ensure json data is recieved from vagrant cloud 2022-04-25 12:26:45 -05:00
sophia
18f3dc62c5
Bump sdk 2022-04-25 12:26:45 -05:00
sophia
8b5bc0cd1c
Set box metadata url 2022-04-25 12:26:45 -05:00
sophia
d9bcdba830
go generate 2022-04-25 12:26:45 -05:00
sophia
c60836fc12
Get box provider from target 2022-04-25 12:26:45 -05:00
sophia
e27fb8aa07
Ensure json metadata is retrieved for box 2022-04-25 12:26:45 -05:00
sophia
f97aff623f
Set default log level fwhen launching vagrant ruby 2022-04-25 12:26:45 -05:00
sophia
3516aa7131
Set defailt Vagrant log level 2022-04-25 12:26:44 -05:00