Commit Graph

127 Commits

Author SHA1 Message Date
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 de78a3637a Plugin activation
Vagrant is only guaranteeing that the plugin definition superclass (the
Vagrant.plugin("1") part) is backwards compatible. Anything else, such
as Vagrant::Command::Base and so on, will likely change in future
versions. Beacuse of this, plugins should only immediately expose their
definition.

In order to support loading the other classes, plugins should defer
loading to the "activation" phase of a plugin. This can be done using
the `activated` block:

    class MyPlugin < Vagrant.plugin("1")
      name "my plugin"

      activated do
        require "myplugin/my_command"
      end

      command("foo") { MyCommand }
    end

Plugin activation is done at two specific times:

  * Right when a Vagrant::Environment is created and the global plugins
    (such as from ~.vagrantrc) are loaded.
  * Right before loading configuration, but after the Vagrantfiles have
    been evaluated. This allows plugins to be defined within these files
    as well.
2012-05-21 22:23:50 -07:00
Mitchell Hashimoto 3204b3a580 Vagrant.configure and versioned configuration
Vagrant.configure is now how configuration is done in Vagrantfiles
(previously it was Vagrant::Config.run). This function takes a single
argument which is the version of configuration to use.

Various internals were updated for this new versioned configuration.

Note that multiple versions of configuration aren't yet used so aren't
fully supported by Vagrant, but the foundation is being set here.
2012-05-21 21:47:01 -07:00
Mitchell Hashimoto 8c6f3edf2d Single-VM mode still allows target name in vagrant commands 2012-05-06 14:33:47 -07:00
Mitchell Hashimoto bc0643613a Vagrant.require_plugin [GH-916] 2012-05-06 14:01:10 -07:00
Mitchell Hashimoto 0d6248394c Tests for the Easy command base 2012-05-06 10:01:50 -07:00
Ryan LeCompte 2355a4b9a6 fix support for multiple unique easy commands 2012-05-06 01:47:43 -07:00
Mitchell Hashimoto 4cc3fb05df Passing unit tests 2012-05-05 22:32:19 -07:00
Mitchell Hashimoto 3d147f1d96 Raise exception if the insert_before middleware is not found 2012-05-05 22:10:26 -07:00
Mitchell Hashimoto 879f98b5d5 Action builder supports indexing middlewares by name 2012-05-05 22:01:53 -07:00
Mitchell Hashimoto c2649074c3 Test command name validation and fix up some bugs 2012-05-05 20:11:26 -07:00
Mitchell Hashimoto 00aba5ac03 Plugin easy commands.
Easy commands are well... easy! They don't offer the full power of
creating a completely custom command class, but they let you do the
basics (what almost everyone needs) with minimal fuss. Example:

class MyPlugin < Vagrant.plugin("1")
  name "my-plugin"

  easy_command "foo" do |action|
    puts "HELLO!"
  end
end

NOTE: The "action" stuff isn't done yet, but will be soon!
2012-05-05 18:57:29 -07:00
Mitchell Hashimoto 8850c086b1 Plugins can now have action_hooks 2012-05-05 18:28:07 -07:00
Mitchell Hashimoto 13a27eb723 More test cleanups 2012-05-01 22:10:10 -07:00
Mitchell Hashimoto 9b20173dfb Clean up some of the SSH key tests 2012-05-01 22:08:30 -07:00
Sean Wolfe 024f492cb3 Added spec to test the ssh key file permission changing. 2012-05-01 14:05:22 -07:00
Mitchell Hashimoto 1489854d70 Move commands into plugins 2012-04-19 13:59:48 -07:00
Mitchell Hashimoto 661f20bb91 Move hosts to a plugin system 2012-04-18 22:20:45 -07:00
Mitchell Hashimoto 1cbac3167f Move provisioners into plugins 2012-04-18 21:53:19 -07:00
Mitchell Hashimoto 1b2fa748f9 Move all guests to plugins, even the distros 2012-04-18 21:23:25 -07:00
Mitchell Hashimoto 7766eb6098 Major guests have been moved to plugins 2012-04-18 21:03:03 -07:00
Mitchell Hashimoto dd459170dd Start moving guest configuration out into plugins 2012-04-18 17:38:20 -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
Mitchell Hashimoto b46daa82bc Ability to define configuration classes on plugins 2012-04-15 16:04:54 -05:00
Mitchell Hashimoto 2eebc2cb68 Basic Plugin class 2012-04-15 15:34:44 -05:00
Mitchell Hashimoto d08a65e7f7 IsPortOpen utility 2012-03-23 10:26:29 -04:00
Mitchell Hashimoto 1b0a6a0895 Make unit tests pass from the safe_puts changes 2012-03-22 13:42:41 -07:00
Mitchell Hashimoto f8fa859b5f Raise an error if the CWD is incorrect 2012-03-08 16:57:17 -08:00
Mitchell Hashimoto 6969f791ad VAGRANT_CWD can be set to set the CWD of `vagrant`. 2012-03-08 16:45:19 -08:00
Mitchell Hashimoto ce00a56ecb Even with a custom vagrantfile name, use defaults [GH-778] 2012-03-08 13:24:04 -08:00
Mitchell Hashimoto 7b9f64f577 Allow data store to work even if file path is nil 2012-02-25 10:41:06 -08:00
Mitchell Hashimoto 2c823e98bd Fix crashing bug with `primary_vm` on Environment 2012-02-24 10:27:34 -08:00
Mitchell Hashimoto ba42fffed0 Convert line endings to Unix-style [GH-727] 2012-02-10 18:07:59 -08:00
Bob Van Zant ae62c9bd68 Convert example host only IPs to RFC1918 2012-02-08 14:50:33 -08:00
Mitchell Hashimoto 3eff28ac0d Don't strip color codes with ANSI escape code remover 2012-02-05 13:30:21 +01:00
Mitchell Hashimoto 912e4974db Registry will now cache result values.
This is actually required so that we can do things like this
in plugins:

Vagrant.actions[:up].insert(Foo, Bar)
2012-01-28 17:31:50 -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 4cfabc690b Fix a failing unit test 2012-01-11 23:57:19 -08:00
Mitchell Hashimoto f0b77d2f30 Additional fixes + tests for shell expansion [GH-633] 2012-01-11 22:56: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