58 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
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
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
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
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
Sam Phippen
790fa9f8e2 Add a failing test for #5605 2015-09-08 17:15:51 +01:00
Kalman Hazins
bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Fabio Rehm
54656151cf Convert specs to RSpec 2.14.8 syntax with Transpec
This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

* 507 conversions
    from: obj.should
      to: expect(obj).to

* 394 conversions
    from: == expected
      to: eq(expected)

* 260 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 85 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

* 19 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
2014-03-14 12:02:07 -03:00
Mitchell Hashimoto
86ede835ea Fix tests for new _finalize! changes 2014-02-05 21:16:47 -08:00
Mitchell Hashimoto
f72db0c611 core: config raises NoMethodError on bad calls once finalized 2014-02-05 16:14:58 -08:00
Mitchell Hashimoto
7ef6c5d9d7 Unused config objects are finalized properly [GH-1877] 2013-07-23 17:36:48 -05: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
2081fe5650 Tests passing for V1 config changes 2013-02-28 00:11:06 -08:00
Mitchell Hashimoto
1d1dfec940 Additional unit test to verify missing config key behavior 2013-02-08 16:55:06 -08:00
Mitchell Hashimoto
595d6f7848 Record invalid key accesses as an error on config 2013-02-08 16:54:24 -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
e651eb3aa1 Add a V2 config helper to merge errors since that seems common 2013-01-18 13:03:07 -08:00
Mitchell Hashimoto
a8b57ba13f Ignore empty error groups 2013-01-18 12:27:29 -08:00
Mitchell Hashimoto
e6f9586d83 New validation method on the root that returns errors 2013-01-18 12:14:40 -08:00
Mitchell Hashimoto
0180ed849d Move config loader order out from an ivar into a param for the #load
method
2012-12-23 16:29:23 -08:00
Mitchell Hashimoto
53860f90ab V2 loader now properly upgrades V1 configuration.
This is done by calling the `upgrade` method on the _old_ configuration
classes. The old configuration classes are given the complete new
configuration and can set whatever settings they need to on it.
2012-11-07 20:01:39 -08:00
Mitchell Hashimoto
253b433864 Support configuring the version for test plugins. 2012-11-06 21:32:26 -08:00
Mitchell Hashimoto
be294e002a Build the v2 interface, which is just a copy of V1 for now. 2012-11-06 20:51:03 -08:00
Mitchell Hashimoto
efa0a6b8c2 Clean up tests a bit more 2012-11-04 08:10:48 -08:00
Mitchell Hashimoto
0ca783e8d1 V1 config loader loads upgradable config if not V1
This is to prepare for the upcoming V2 configuration. When we're in V2,
we only want to load _upgradable_ configuration keys.
2012-11-03 21:54:32 -07:00
Mitchell Hashimoto
c803b0508a Much cleaner plugin part querying syntax.
Before we were manually going over every plugin and getting each piece,
all over the place. Now we have a central manager that will give us all
the pieces we want. There is still some cleanup to do here but this is
much better overall.
2012-11-03 21:25:28 -07:00
Mitchell Hashimoto
798704c6d2 Move the loader into the Config::V1 namespace. 2012-06-26 15:06:03 -07:00
Mitchell Hashimoto
41bc8e7454 Move Config::V1::Base to Vagrant::Plugin::V1::Config 2012-06-24 17:06:11 -07:00
Mitchell Hashimoto
7a299ae2de Configuration loader can handle upgrading.
The basic process for this is to:

1. Load the configuration using the proper loader for that version. i.e.
   if you're loading V1 config, then use the V1 loader.
2. If we just loaded a version that isn't current (imagine we're
   currently at V3), then we need to upgrade that config. So we first
   ask the V2 loader to upgrade the V1 config to V2, then we ask the V3
   loader to upgrade the V2 config to V3. We keep track of warnings and
   errors throughout this process.
3. Finally, we have a current config, so we merge it into the in-process
   configuration that is being loaded.
2012-06-23 19:56:31 -07:00
Mitchell Hashimoto
9bc1ea5f04 Use config finalize to move some version-specific logic to the version
This moves out the concept of a "default VM" from the Environment class
and makes it the responsibility of the V1 configuration that at least
one VM is defined on it. This lets the configuration ultimately decide
what a "default" implementation is.
2012-06-23 12:48:53 -07:00
Mitchell Hashimoto
70fb804128 Configuration versions can finalize config after loading
This is useful so that it can take a look at the final loaded
configuration object and possibly make some tweaks to the configuration
object. The use case this was built for was so that config V1 can verify
that there is always at least a single VM defined as a sub-VM, the
"default" VM.
2012-06-23 12:27:32 -07:00
Mitchell Hashimoto
7e19d6849b Config loader no longer assumes latest version for procs.
Previously, all procs were assumed to just be the current version. This
is certainly not going to be true always so now the version number of
the configuration must be explicit if you're assigning a proc to the
configuration loader.
2012-06-23 12:06:54 -07:00
Mitchell Hashimoto
b3db82e516 Separate out the versions the config loader knows as init params.
This means that the Config::Loader now only knows how to load
configuration for versions used to initialize the class. This lets
things like the tests be completely isolated from what the actual
configuration is for Vagrant. This will be immensely useful to verify
that the loader functionality works for non-trivial bits (like
upgrading) without depending on Vagrant's upgrading functionality.
2012-06-23 11:33:53 -07:00
Mitchell Hashimoto
a23fee4848 Remove old configuration classes 2012-04-18 17:16:03 -07:00
Mitchell Hashimoto
b38fb5e974 Loader uses the new configuration classes 2012-04-18 17:03:34 -07:00
Mitchell Hashimoto
c0ee3b06ff Config merging 2012-04-17 10:22:24 -07:00
Mitchell Hashimoto
92ee042fc2 V1 config loading using plugins as a source for config keys 2012-04-16 22:26:38 -07:00
Bob Van Zant
ae62c9bd68 Convert example host only IPs to RFC1918 2012-02-08 14:50:33 -08:00
Mitchell Hashimoto
d1e78f791d Remove test warnings, add ANSI escape code remover 2012-01-23 19:24:32 -08:00
Mitchell Hashimoto
d487e286f4 Don't merge config keys that start with __.
This allows config classes to store internal state somehow.
2012-01-19 20:54:09 -08:00
Mitchell Hashimoto
bdb591bc0f Tests that boolean configs are merged up properly [GH-651] 2012-01-18 18:51:15 -08:00
Mitchell Hashimoto
863ebe2d2f Custom merging for VM config 2012-01-11 22:12:49 -08:00
Mitchell Hashimoto
51353d51fc Test base merge 2012-01-11 21:31:19 -08:00
Mitchell Hashimoto
bfb52ba7dc Top merges things in each key one by one by calling merge 2012-01-11 21:22:55 -08:00
Mitchell Hashimoto
d13dd482b5 Some Config::Top class tests 2012-01-11 21:09:52 -08:00
Mitchell Hashimoto
008132b3cb Run each config proc only once 2012-01-11 20:59:21 -08:00