Machine objects are passed into validate instead of env

This commit is contained in:
Mitchell Hashimoto 2013-01-18 12:42:49 -08:00
parent 3e9e422ce0
commit 3f3c7027aa
3 changed files with 8 additions and 9 deletions

View File

@ -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?

View File

@ -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

View File

@ -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",