From 3f3c7027aa92ca4866acc052ad7a0ef7ee46097e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 18 Jan 2013 12:42:49 -0800 Subject: [PATCH] Machine objects are passed into validate instead of env --- lib/vagrant/config/v2/root.rb | 4 ++-- plugins/kernel_v2/config/ssh.rb | 5 +++-- plugins/kernel_v2/config/vm.rb | 8 +++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/vagrant/config/v2/root.rb b/lib/vagrant/config/v2/root.rb index b2a6bf4f0..d35b5f2f4 100644 --- a/lib/vagrant/config/v2/root.rb +++ b/lib/vagrant/config/v2/root.rb @@ -45,14 +45,14 @@ module Vagrant # # @param [Environment] env # @return [Hash] - def validate(env) + def validate(machine) # Go through each of the configuration keys and validate errors = {} @keys.each do |_key, instance| if instance.respond_to?(:validate) # Validate this single item, and if we have errors then # we merge them into our total errors list. - result = instance.validate(env) + result = instance.validate(machine) if result && !result.empty? result.each do |key, value| if !value.empty? diff --git a/plugins/kernel_v2/config/ssh.rb b/plugins/kernel_v2/config/ssh.rb index a296c83fd..eff0f8481 100644 --- a/plugins/kernel_v2/config/ssh.rb +++ b/plugins/kernel_v2/config/ssh.rb @@ -15,7 +15,7 @@ module VagrantPlugins attr_accessor :forward_x11 attr_accessor :shell - def validate(env) + def validate(machine) errors = [] [:username, :max_tries, :timeout].each do |field| @@ -23,7 +23,8 @@ module VagrantPlugins errors << I18n.t("vagrant.config.common.error_empty", :field => field) if !value end - if private_key_path && !File.file?(File.expand_path(private_key_path, env.root_path)) + if private_key_path && \ + !File.file?(File.expand_path(private_key_path, machine.env.root_path)) errors << I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path) end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 3c340c014..7a33c4e80 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -122,16 +122,14 @@ module VagrantPlugins define(DEFAULT_VM_NAME) if defined_vm_keys.empty? end - def validate(env) + def validate(machine) errors = [] errors << I18n.t("vagrant.config.vm.box_missing") if !box errors << I18n.t("vagrant.config.vm.box_not_found", :name => box) if \ - box && !box_url && !env.boxes.find(box, :virtualbox) - errors << I18n.t("vagrant.config.vm.base_mac_invalid") if \ - env.boxes.find(box, :virtualbox) && !base_mac + box && !box_url && !machine.box shared_folders.each do |name, options| - hostpath = Pathname.new(options[:hostpath]).expand_path(env.root_path) + hostpath = Pathname.new(options[:hostpath]).expand_path(machine.env.root_path) if !hostpath.directory? && !options[:create] errors << I18n.t("vagrant.config.vm.shared_folder_hostpath_missing",