class Berkshelf::Config
def coerce_ssl
-
(Config)
-
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
def from_file(path)
def from_file(path) new(path) end
def initialize(path = self.class.path)
-
path
(String
) --
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
def instance
-
(Config)
-
def instance @instance ||= new(path) coerce_ssl end
def local_location
-
(String)
-
def local_location ENV["BERKSHELF_CONFIG"] || File.join(".", ".berkshelf", "config.json") end
def method_missing(method, *args, &block)
def method_missing(method, *args, &block) @klass.send(method, *args, &block) end
def path
-
(String)
-
def path path = File.exist?(local_location) ? local_location : store_location File.expand_path(path) end
def reload
-
(Config)
-
def reload @instance = nil instance end
def set_config(config)
-
config
(Berkshelf::Config
) --
def set_config(config) @instance = config end
def set_path(new_path)
-
new_path
(String
) --
def set_path(new_path) @instance = nil end
def store_location
-
(String)
-
def store_location File.join(Berkshelf.berkshelf_path, "config.json") end