Provide defaults in a proper way for Chef config

This commit is contained in:
Mitchell Hashimoto 2012-01-19 20:47:01 -08:00
parent 28eddafa56
commit f87c25bac8
3 changed files with 19 additions and 18 deletions

View File

@ -115,11 +115,11 @@ module Vagrant
attr_accessor :attempts attr_accessor :attempts
attr_writer :run_list attr_writer :run_list
def initialize # Provide defaults in such a way that they won't override the instance
@attempts = 1 # variable. This is so merging continues to work properly.
@json = {} def attempts; @attempts || 1; end
@log_level = :info def json; @json ||= {}; end
end def log_level; @log_level || :info; end
# This returns the json that is merged with the defaults and the # This returns the json that is merged with the defaults and the
# user set data. # user set data.

View File

@ -18,15 +18,13 @@ module Vagrant
attr_accessor :encrypted_data_bag_secret_key_path attr_accessor :encrypted_data_bag_secret_key_path
attr_accessor :encrypted_data_bag_secret attr_accessor :encrypted_data_bag_secret
def initialize # Provide defaults in such a way that they won't override the instance
super # variable. This is so merging continues to work properly.
def validation_client_name; @validation_client_name || "chef-validator"; end
@validation_client_name = "chef-validator" def client_key_path; @client_key_path || "/etc/chef/client.pem"; end
@client_key_path = "/etc/chef/client.pem" def file_cache_path; @file_cache_path || "/srv/chef/file_store"; end
@file_cache_path = "/srv/chef/file_store" def file_backup_path; @file_backup_path || "/srv/chef/cache"; end
@file_backup_path = "/srv/chef/cache" def encrypted_data_bag_secret; @encrypted_data_bag_secret || "/tmp/encrypted_data_bag_secret"; end
@encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret"
end
def validate(env, errors) def validate(env, errors)
super super

View File

@ -16,11 +16,14 @@ module Vagrant
attr_accessor :recipe_url attr_accessor :recipe_url
attr_accessor :nfs attr_accessor :nfs
def initialize # Provide defaults in such a way that they won't override the instance
super # variable. This is so merging continues to work properly.
def cookbooks_path
@cookbooks_path || ["cookbooks", [:vm, "cookbooks"]]
end
@cookbooks_path = ["cookbooks", [:vm, "cookbooks"]] def nfs
@nfs = false @nfs || false
end end
def validate(env, errors) def validate(env, errors)