class Berkshelf::Config
Attributes
path[RW]
Public Class Methods
coerce_ssl()
click to toggle source
force proper X509 types from any configuration strings
@return [Config]
# File lib/berkshelf/config.rb, line 63 def coerce_ssl ssl = @instance[:ssl] ssl[:ca_cert] = OpenSSL::X509::Certificate.new(File.read(ssl[:ca_cert])) if ssl[:ca_cert] && ssl[:ca_cert].is_a?(String) ssl[:client_cert] = OpenSSL::X509::Certificate.new(File.read(ssl[:client_cert])) if ssl[:client_cert] && ssl[:client_cert].is_a?(String) ssl[:client_key] = OpenSSL::PKey::RSA.new(File.read(ssl[:client_key])) if ssl[:client_key] && ssl[:client_key].is_a?(String) @instance end
from_file(path)
click to toggle source
# File lib/berkshelf/config.rb, line 71 def from_file(path) new(path) end
instance()
click to toggle source
Instantiate and return or just return the currently instantiated Berkshelf
configuration
@return [Config]
# File lib/berkshelf/config.rb, line 47 def instance @instance ||= new(path) coerce_ssl end
local_location()
click to toggle source
@return [String]
# File lib/berkshelf/config.rb, line 23 def local_location ENV["BERKSHELF_CONFIG"] || File.join(".", ".berkshelf", "config.json") end
new(path = self.class.path)
click to toggle source
@param [String] path
# File lib/berkshelf/config.rb, line 79 def initialize(path = self.class.path) # this is a bit tricky, mixlib-config wants to extend a class and create effectively a global config object while # what we want to do is use an instance, so we create an anonymous class and shove it into an instance variable. # this is actually similar to what mixlib-config itself does to create config contexts. @klass = Class.new @klass.extend(Mixlib::Config) @klass.extend(BerksConfig) @path = File.expand_path(path) @klass.from_file(@path) if File.exist?(@path) # yeah, if !File.exist?() you just get back an empty config object Berkshelf.ui.warn "The `cookbook.copyright' config is deprecated and will be removed in a future release." unless cookbook.copyright.nil? Berkshelf.ui.warn "The `cookbook.email' config is deprecated and will be removed in a future release." unless cookbook.email.nil? Berkshelf.ui.warn "The `cookbook.license' config is deprecated and will be removed in a future release." unless cookbook.license.nil? Berkshelf.ui.warn "The `vagrant.vm.box' config is deprecated and will be removed in a future release." unless vagrant.vm.box.nil? Berkshelf.ui.warn "The `vagrant.vm.forward_port' config is deprecated and will be removed in a future release." unless vagrant.vm.forward_port.nil? Berkshelf.ui.warn "The `vagrant.vm.provision' config is deprecated and will be removed in a future release." unless vagrant.vm.provision.nil? Berkshelf.ui.warn "The `vagrant.vm.omnibus.version' config is deprecated and will be removed in a future release." unless vagrant.vm.omnibus.version.nil? end
path()
click to toggle source
@return [String]
# File lib/berkshelf/config.rb, line 28 def path path = File.exist?(local_location) ? local_location : store_location File.expand_path(path) end
reload()
click to toggle source
Reload the currently instantiated Berkshelf
configuration
@return [Config]
# File lib/berkshelf/config.rb, line 55 def reload @instance = nil instance end
set_config(config)
click to toggle source
@param [Berkshelf::Config] config
# File lib/berkshelf/config.rb, line 34 def set_config(config) @instance = config end
set_path(new_path)
click to toggle source
@param [String] new_path
# File lib/berkshelf/config.rb, line 39 def set_path(new_path) @instance = nil end
store_location()
click to toggle source
@return [String]
# File lib/berkshelf/config.rb, line 18 def store_location File.join(Berkshelf.berkshelf_path, "config.json") end
Public Instance Methods
method_missing(method, *args, &block)
click to toggle source
# File lib/berkshelf/config.rb, line 100 def method_missing(method, *args, &block) @klass.send(method, *args, &block) end