Properly prepare the path configs for Chef

This commit is contained in:
Mitchell Hashimoto 2013-03-05 11:53:57 -08:00
parent dc5196454e
commit e06af4e2b9
1 changed files with 24 additions and 11 deletions

View File

@ -29,24 +29,20 @@ module VagrantPlugins
@cookbooks_path = [[:host, "cookbooks"], [:vm, "cookbooks"]]
end
# Make sure the path is an array.
@cookbooks_path = [@cookbooks_path] if \
!@cookbooks_path.is_a?(Array) || @cookbooks_path.first.is_a?(Symbol)
# Make sure all the paths are the proper format
@cookbooks_path.map! do |path|
path = [:host, path] if !path.is_a?(Array)
path
end
@data_bags_path = [] if @data_bags_path == UNSET_VALUE
@roles_path = [] if @roles_path == UNSET_VALUE
# Make sure the path is an array.
@cookbooks_path = prepare_folders_config(@cookbooks_path)
@data_bags_path = prepare_folders_config(@data_bags_path)
@roles_path = prepare_folders_config(@roles_path)
@encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret" if \
@encrypted_data_bag_secret == UNSET_VALUE
@encrypted_data_bag_secret_key_path = nil if \
@encrypted_data_bag_secret_key_path == UNSET_VALUE
@nfs = false if @nfs == UNSET_VALUE
@recipe_url = nil if @recipe_url == UNSET_VALUE
@roles_path = [] if @roles_path == UNSET_VALUE
end
def validate(machine)
@ -68,6 +64,23 @@ module VagrantPlugins
{ "chef solo provisioner" => errors }
end
protected
# This takes any of the configurations that take a path or
# array of paths and turns it into the proper format.
#
# @return [Array]
def prepare_folders_config(config)
# Make sure the path is an array
config = [config] if !config.is_a?(Array) || config.first.is_a?(Symbol)
# Make sure all the paths are in the proper format
config.map do |path|
path = [:host, path] if !path.is_a?(Array)
path
end
end
end
end
end