169 Commits

Author SHA1 Message Date
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
4d403ef02a Only raise error if version load is nil 2022-06-15 11:15:08 -07:00
Chris Roberts
2274efa568 Add helper method for performing partial loads 2022-06-15 11:06:33 -07:00
Chris Roberts
2af4ee0859 Always store values even when not registered 2022-06-15 11:06:33 -07:00
Chris Roberts
dfc2a6d6f4 Make dummy config a proper config instance and remove to_proto 2022-06-15 11:06:33 -07: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
Chris Roberts
6d0e08942b
Convert error logger message to warn 2022-04-25 12:26:39 -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
Paul Hinze
a841da4fc6
Add a simple push plugin in Go
The only tweak required to get this to work was allowing a DummyConfig
to survive being passed through a remote plugin on the Ruby side.
2022-04-25 12:26:21 -05:00
sophia
8d1b9a4a8c
Update regex for dummy config fields 2022-04-25 12:24:20 -05:00
sophia
b152cc4f2b
Allow dummy config to eval config blocks to set instance variables 2022-04-25 12:24:18 -05:00
sophia
0923f1edf2
Collect config for Vagrantfile config element that does not exist in Ruby 2022-04-25 12:24:17 -05:00
Chris Roberts
e7a6f397da Updates for Ruby 3.0 2021-06-21 15:57:46 -07:00
Brian Cain
ace67ccdeb
Remove platform require since it is no longer required in file 2019-09-10 13:28:37 -07:00
Brian Cain
a22acba467
Simplify line and path checks for exception handling in config loading 2019-09-10 13:27:23 -07:00
Brian Cain
ccf99d8c0c
Fixes #11022: Show proper path & letter drive on exceptions for windows
Prior to this commit, vagrant was not grabbing all of the tokens on
Windows for showing the full drive because the ruby api for it behaves
differenly on windows compared to other platforms. This commit changes
that by ensuring the letter drive is attached to the path when showing
an exception.
2019-09-06 13:37:38 -07:00
Brian Cain
6051f3598e
Fixes #10224: Allow validation of config while ignoring provider
This commit adds a new flag to the `vagrant validate` command which
allows users to completely ignore the provider block of a config file.
This is useful for when you are running `vagrant validate` in CI and
don't want to install a valid provider to check the syntax of your
Vagratnfile. When the flag is invoked, a warning will be displayed
saying that the provider block will be ignored and not validated.
2018-10-30 13:37:22 -07:00
Josh Soref
1a5ddea9f4 Spelling fixes
* account
* addresses
* administrator
* afterwards
* because
* bridgeable
* capabilities
* capability
* checksum
* configuration
* configuration for
* configure
* criteria
* delimited
* delivered
* derivatives
* description
* detect
* directory
* display
* downloading
* during
* electric
* enabling
* encountered
* equivalent
* executable
* executed
* hashicorp
* hypervisor
* hyphens
* implementation
* incorporate
* inheritance
* initialize
* instance
* instead
* interactions
* invocable
* machine
* maximum
* message
* mounting
* overridden
* overwrite
* paramiko
* preparing
* provides
* provisioning
* recursively
* requested
* resetting
* retryable
* running
* satisfied
* searching
* sometimes
* specified
* successfully
* synced folders
* unauthorized
* underlying
* userprofile
* vagrant
* vagrantfile
* variable
* various
* version
* virtual
* windows
2018-03-14 14:41:04 +00:00
Chris Roberts
257441ed78 Log location of caller for missing configuration key requests 2018-01-03 09:41:45 -08:00
Brian Cain
627babe15e (#9055) Print more helpful error message for NameEror exceptions
This commit adds some additional handling for when Vagrant loads config
files. Instead of showing the basic ruby exception, it prints a more
helpful error message and tries to direct the user to the line number
and file where the exception is occuring.
2017-12-14 15:31:48 -08:00
Brian Cain
774e19b152 Disable loading identical Vagrantfile twice from same dir
Prior to this commit, if a user set the env var VAGRANT_HOME to be the
same directory where the project home is, Vagrant would load that file
twice and merge its config. This caused various provisioner and other
provider blocks to unexpectedly run twice. This commit updates the
config loader to look and see if the `:root` and `:home` procs are
equal, and if so, removes the `:home` object so that it isn't loaded and
duplicated. This commit however does not prevent duplicate loading if an
identical Vagrantfile exists in the home and project dir if those
locations are different.
2017-06-22 09:04:21 -07:00
Mitchell Hashimoto
c471f37955 core: parse line numbers for Vagrantfile syntax errors on Win [GH-6445] 2015-11-20 15:34:52 -08:00
Sam Phippen
eeb750cd33 Catch encoding problems with sources provided to Vagrant::Config::Loader#set
Here we implement a naive solution to #5605 which catches the case that
a provided source contains an object which cannot be inspected, because
an object contained within in has an #inspect string that returns a
string that is incompatible with the encoding in
`Encoding.default_external` or a string which cannot be downcast to
7-bit ascii.

The Ruby VM implementation of "#inspect" implements this checking on
these lines of code: http://git.io/vZYNS. A Ruby level override of
this method does not cause this problem. For example:

```ruby
class Foo
  def inspect
    "😍".encode("UTF-16LE")
  end
```

will not cause the problem, because that's a Ruby implementation and the
VM's checks don't occur.

However, if we have an Object which **does** use the VM implementation
of inspect, that contains an object that has an inspect string which
returns non-ascii, we encounter the bug. For example:

```ruby
class Bar
  def inspect
    "😍".encode("UTF-16LE")
  end
end

class Foo
  def initialize
     @bar = Bar.new
  end
end

Foo.new.inspect
```

Will cause the issue.

The solution this patch provides basically catches the encoding error
and inserts a string which attempts to help the user work out which
object was provided without blowing up. Most likely, this was caused
by a user having a weird encoding coming out of one of the sources
passed in, but without a full repro case, it's not clear whether a patch
should be applied to a different object in the system.

Closes #5605.
2015-09-08 17:30:50 +01:00
Seth Vargo
6b2ef13785 Be more defensive when trying to get the line number
Since this is the last line of defense before raising an error, we want to make
sure we don't cause an error while trying to render the error.
2015-05-31 18:32:23 -07:00
Adam Spiers
ce13051d61 eliminate guesswork with Vagrantfile errors
If the Vagrantfile has some kind of error, display not only
its path and the exception message, but also the originating
line number and exception class.

Also log the full backtrace when the error is in a provider
block, just as it is done when it's outside a provider block.
2015-05-31 18:25:51 -07:00
Seth Vargo
d2874064f4 Use .key? instead of .has_key? 2015-01-05 18:29:01 -05:00
Kalman Hazins
bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Alex Rodionov
34ec385c81 core: public_send vs send when merging configs
This fixes the problem when config keys collide with Kernel/Object
methods (private). An example is `exec` which is used in vagrant-exec
plugin.

Compare:

> old.send :exec
ArgumentError: wrong number of arguments (0 for 1+)
> old.public_send :exec
=> #<Vagrant::Config::V2::DummyConfig:0x007fe212cc05c8>
2014-05-07 19:02:21 +07:00
Mitchell Hashimoto
92df8cf6ae Handle a lot of TODOs 2014-04-29 16:50:58 -07:00
Mitchell Hashimoto
4df8636c38 core: instantiate all keys in a V2 config prior to merging
This forces everything to get a new instance, so we don't accidentally
overwrite any values across multiple machines.
2014-04-21 13:55:30 -07:00
Mitchell Hashimoto
f72db0c611 core: config raises NoMethodError on bad calls once finalized 2014-02-05 16:14:58 -08:00
phinze
ee44e717f0 core: fix small comment typo 2013-11-27 18:56:48 -06:00
Mitchell Hashimoto
7ef6c5d9d7 Unused config objects are finalized properly [GH-1877] 2013-07-23 17:36:48 -05:00
Mitchell Hashimoto
98a23be689 Get rid of unused class 2013-04-10 10:48:56 -07:00
Mitchell Hashimoto
7547a0d34a V2 missing key returns a DummyConfig as well 2013-02-28 00:17:58 -08:00
Mitchell Hashimoto
af2690635e Unknown keys return a DummyConfig rather than OpenStruct 2013-02-28 00:16:43 -08:00
Mitchell Hashimoto
d15acde8c0 Capture missing key calls in V1 configs and record them as warnings 2013-02-28 00:06:49 -08:00
Mitchell Hashimoto
595d6f7848 Record invalid key accesses as an error on config 2013-02-08 16:54:24 -08:00
Mitchell Hashimoto
87026b2d9e Remove old TOOD that was fulfilled 2013-02-05 22:17:00 -08:00
Mitchell Hashimoto
a8c7ad30ee Be a bit more fine grained about errors that are reported for Vfiles 2013-01-31 18:52:29 -08:00
Mitchell Hashimoto
e9327c4a28 Better logging in the config logger 2013-01-30 20:12:41 -08:00
Mitchell Hashimoto
c57ba9de58 Give a nice human-friendly error message when problems loading Vfile 2013-01-30 20:01:41 -08:00
Mitchell Hashimoto
2d57afbbda Support warnings/errors when upgrading Vagrantfiles internally 2013-01-20 22:04:50 -05:00
Mitchell Hashimoto
37e36010e0 Remove the ErrorRecorder 2013-01-18 13:15:22 -08:00
Mitchell Hashimoto
e651eb3aa1 Add a V2 config helper to merge errors since that seems common 2013-01-18 13:03:07 -08:00
Mitchell Hashimoto
3f3c7027aa Machine objects are passed into validate instead of env 2013-01-18 12:43:53 -08:00
Mitchell Hashimoto
a8b57ba13f Ignore empty error groups 2013-01-18 12:27:29 -08:00
Mitchell Hashimoto
e0c8fadae4 I can remove the validate! method from the v1 root 2013-01-18 12:18:30 -08:00
Mitchell Hashimoto
e6f9586d83 New validation method on the root that returns errors 2013-01-18 12:14:40 -08:00