From dd459170dd7bbbd9a9d66141ad786f1f562f1bbb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 18 Apr 2012 17:38:20 -0700 Subject: [PATCH] Start moving guest configuration out into plugins --- lib/vagrant.rb | 21 --------------------- lib/vagrant/guest/freebsd.rb | 14 -------------- lib/vagrant/guest/linux.rb | 1 - lib/vagrant/guest/linux/config.rb | 19 ------------------- lib/vagrant/guest/solaris.rb | 19 ------------------- plugins/guest_freebsd/config.rb | 13 +++++++++++++ plugins/guest_freebsd/plugin.rb | 13 +++++++++++++ plugins/guest_linux/config.rb | 13 +++++++++++++ plugins/guest_linux/plugin.rb | 13 +++++++++++++ plugins/guest_solaris/config.rb | 18 ++++++++++++++++++ plugins/guest_solaris/plugin.rb | 13 +++++++++++++ test/unit/vagrant_test.rb | 4 ---- 12 files changed, 83 insertions(+), 78 deletions(-) delete mode 100644 lib/vagrant/guest/linux/config.rb create mode 100644 plugins/guest_freebsd/config.rb create mode 100644 plugins/guest_freebsd/plugin.rb create mode 100644 plugins/guest_linux/config.rb create mode 100644 plugins/guest_linux/plugin.rb create mode 100644 plugins/guest_solaris/config.rb create mode 100644 plugins/guest_solaris/plugin.rb diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 00eb9eeee..c854103f2 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -115,15 +115,6 @@ module Vagrant @commands ||= Registry.new end - # Global registry of config keys that are available. - # - # This registry is used to look up the keys for `config` objects. - # For example, `config.vagrant` looks up the `:vagrant` config key - # for the configuration class to use. - def self.config_keys - @config_keys ||= Registry.new - end - # Global registry of available host classes and shortcut symbols # associated with them. # @@ -183,13 +174,6 @@ Vagrant.commands.register(:status) { Vagrant::Command::Status } Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend } Vagrant.commands.register(:up) { Vagrant::Command::Up } -# Register the built-in config keys -Vagrant.config_keys.register(:vagrant) { Vagrant::Config::VagrantConfig } -Vagrant.config_keys.register(:ssh) { Vagrant::Config::SSHConfig } -Vagrant.config_keys.register(:nfs) { Vagrant::Config::NFSConfig } -Vagrant.config_keys.register(:vm) { Vagrant::Config::VMConfig } -Vagrant.config_keys.register(:package) { Vagrant::Config::PackageConfig } - # Register the built-in hosts Vagrant.hosts.register(:arch) { Vagrant::Hosts::Arch } Vagrant.hosts.register(:bsd) { Vagrant::Hosts::BSD } @@ -219,8 +203,3 @@ Vagrant.provisioners.register(:chef_client) { Vagrant::Provisioners::ChefClien Vagrant.provisioners.register(:puppet) { Vagrant::Provisioners::Puppet } Vagrant.provisioners.register(:puppet_server) { Vagrant::Provisioners::PuppetServer } Vagrant.provisioners.register(:shell) { Vagrant::Provisioners::Shell } - -# Register the built-in systems -Vagrant.config_keys.register(:freebsd) { Vagrant::Guest::FreeBSD::FreeBSDConfig } -Vagrant.config_keys.register(:linux) { Vagrant::Guest::Linux::LinuxConfig } -Vagrant.config_keys.register(:solaris) { Vagrant::Guest::Solaris::SolarisConfig } diff --git a/lib/vagrant/guest/freebsd.rb b/lib/vagrant/guest/freebsd.rb index bb7149957..adf22b6a1 100644 --- a/lib/vagrant/guest/freebsd.rb +++ b/lib/vagrant/guest/freebsd.rb @@ -6,20 +6,6 @@ module Vagrant # # Contributed by Kenneth Vestergaard class FreeBSD < Base - # A custom config class which will be made accessible via `config.freebsd` - # This is not necessary for all system implementers, of course. However, - # generally, Vagrant tries to make almost every aspect of its execution - # configurable, and this assists that goal. - class FreeBSDConfig < Vagrant::Config::Base - attr_accessor :halt_timeout - attr_accessor :halt_check_interval - - def initialize - @halt_timeout = 30 - @halt_check_interval = 1 - end - end - # Here for whenever it may be used. class FreeBSDError < Errors::VagrantError error_namespace("vagrant.guest.freebsd") diff --git a/lib/vagrant/guest/linux.rb b/lib/vagrant/guest/linux.rb index e94af2db0..4730e4088 100644 --- a/lib/vagrant/guest/linux.rb +++ b/lib/vagrant/guest/linux.rb @@ -1,7 +1,6 @@ require 'log4r' require 'vagrant/guest/linux/error' -require 'vagrant/guest/linux/config' module Vagrant module Guest diff --git a/lib/vagrant/guest/linux/config.rb b/lib/vagrant/guest/linux/config.rb deleted file mode 100644 index 1e80c522d..000000000 --- a/lib/vagrant/guest/linux/config.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Vagrant - module Guest - class Linux < Vagrant::Guest::Base - # A custom config class which will be made accessible via `config.linux` - # This is not necessary for all system implementers, of course. However, - # generally, Vagrant tries to make almost every aspect of its execution - # configurable, and this assists that goal. - class LinuxConfig < Vagrant::Config::Base - attr_accessor :halt_timeout - attr_accessor :halt_check_interval - - def initialize - @halt_timeout = 30 - @halt_check_interval = 1 - end - end - end - end -end diff --git a/lib/vagrant/guest/solaris.rb b/lib/vagrant/guest/solaris.rb index db2afeb4d..626ac6910 100644 --- a/lib/vagrant/guest/solaris.rb +++ b/lib/vagrant/guest/solaris.rb @@ -4,25 +4,6 @@ module Vagrant # # Contributed by Blake Irvin class Solaris < Base - # A custom config class which will be made accessible via `config.solaris` - # This is not necessary for all system implementers, of course. However, - # generally, Vagrant tries to make almost every aspect of its execution - # configurable, and this assists that goal. - class SolarisConfig < Vagrant::Config::Base - attr_accessor :halt_timeout - attr_accessor :halt_check_interval - # This sets the command to use to execute items as a superuser. sudo is default - attr_accessor :suexec_cmd - attr_accessor :device - - def initialize - @halt_timeout = 30 - @halt_check_interval = 1 - @suexec_cmd = 'sudo' - @device = "e1000g" - end - end - # Here for whenever it may be used. class SolarisError < Errors::VagrantError error_namespace("vagrant.guest.solaris") diff --git a/plugins/guest_freebsd/config.rb b/plugins/guest_freebsd/config.rb new file mode 100644 index 000000000..d544bf7b6 --- /dev/null +++ b/plugins/guest_freebsd/config.rb @@ -0,0 +1,13 @@ +module VagrantPlugins + module GuestFreeBSD + class Config < Vagrant::Config::Base + attr_accessor :halt_timeout + attr_accessor :halt_check_interval + + def initialize + @halt_timeout = 30 + @halt_check_interval = 1 + end + end + end +end diff --git a/plugins/guest_freebsd/plugin.rb b/plugins/guest_freebsd/plugin.rb new file mode 100644 index 000000000..838028e2e --- /dev/null +++ b/plugins/guest_freebsd/plugin.rb @@ -0,0 +1,13 @@ +require "vagrant" + +module VagrantPlugins + module GuestFreeBSD + autoload :Config, File.expand_path("../config", __FILE__) + + class Plugin < Vagrant.plugin("1") + name "FreeBSD guest" + description "FreeBSD guest support." + config("freebsd") { Config } + end + end +end diff --git a/plugins/guest_linux/config.rb b/plugins/guest_linux/config.rb new file mode 100644 index 000000000..06e765ffb --- /dev/null +++ b/plugins/guest_linux/config.rb @@ -0,0 +1,13 @@ +module VagrantPlugins + module GuestLinux + class Config < Vagrant::Config::Base + attr_accessor :halt_timeout + attr_accessor :halt_check_interval + + def initialize + @halt_timeout = 30 + @halt_check_interval = 1 + end + end + end +end diff --git a/plugins/guest_linux/plugin.rb b/plugins/guest_linux/plugin.rb new file mode 100644 index 000000000..46d7380ab --- /dev/null +++ b/plugins/guest_linux/plugin.rb @@ -0,0 +1,13 @@ +require "vagrant" + +module VagrantPlugins + module GuestLinux + autoload :Config, File.expand_path("../config", __FILE__) + + class Plugin < Vagrant.plugin("1") + name "Linux guest." + description "Linux guest support." + config("linux") { Config } + end + end +end diff --git a/plugins/guest_solaris/config.rb b/plugins/guest_solaris/config.rb new file mode 100644 index 000000000..e26c8205d --- /dev/null +++ b/plugins/guest_solaris/config.rb @@ -0,0 +1,18 @@ +module VagrantPlugins + module GuestSolaris + class Config < Vagrant::Config::Base + attr_accessor :halt_timeout + attr_accessor :halt_check_interval + # This sets the command to use to execute items as a superuser. sudo is default + attr_accessor :suexec_cmd + attr_accessor :device + + def initialize + @halt_timeout = 30 + @halt_check_interval = 1 + @suexec_cmd = 'sudo' + @device = "e1000g" + end + end + end +end diff --git a/plugins/guest_solaris/plugin.rb b/plugins/guest_solaris/plugin.rb new file mode 100644 index 000000000..bf32eb762 --- /dev/null +++ b/plugins/guest_solaris/plugin.rb @@ -0,0 +1,13 @@ +require "vagrant" + +module VagrantPlugins + module GuestSolaris + autoload :Config, File.expand_path("../config", __FILE__) + + class Plugin < Vagrant.plugin("1") + name "Solaris guest." + description "Solaris guest support." + config("solaris") { Config } + end + end +end diff --git a/test/unit/vagrant_test.rb b/test/unit/vagrant_test.rb index 82aeb58ff..7fb572a39 100644 --- a/test/unit/vagrant_test.rb +++ b/test/unit/vagrant_test.rb @@ -9,10 +9,6 @@ describe Vagrant do described_class.commands.should be_a(Vagrant::Registry) end - it "has a registry for config keys" do - described_class.config_keys.should be_a(Vagrant::Registry) - end - it "has a registry for hosts" do described_class.hosts.should be_a(Vagrant::Registry) end