Class: Berkshelf::Config
- Inherits:
-
Buff::Config::JSON
- Object
- Buff::Config::JSON
- Berkshelf::Config
- Defined in:
- lib/berkshelf/config.rb
Class Method Summary collapse
-
.coerce_ssl ⇒ Config
force proper X509 types from any configuration strings.
-
.file ⇒ String?
The contents of the file.
-
.instance ⇒ Config
Instantiate and return or just return the currently instantiated Berkshelf configuration.
- .local_location ⇒ String
- .path ⇒ String
-
.reload ⇒ Config
Reload the currently instantiated Berkshelf configuration.
- .set_config(config) ⇒ Object
- .set_path(new_path) ⇒ Object
- .store_location ⇒ String
Instance Method Summary collapse
-
#initialize(path = self.class.path, options = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path = self.class.path, options = {}) ⇒ Config
Returns a new instance of Config.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/berkshelf/config.rb', line 76 def initialize(path = self.class.path, = {}) super(path, ).tap do # Deprecation if !self.vagrant.omnibus.enabled.nil? Berkshelf.ui.warn "`vagrant.omnibus.enabled' is deprecated and " \ "will be removed in a future release. Please remove the " \ "`enabled' attribute from your Berkshelf config." end if !self.vagrant.vm.box_url.nil? Berkshelf.ui.warn "`vagrant.vm.box_url' is deprecated and " \ "will be removed in a future release. Please remove the " \ "`box_url' attribute from your Berkshelf config." end end end |
Class Method Details
.coerce_ssl ⇒ Config
force proper X509 types from any configuration strings
64 65 66 67 68 69 70 |
# File 'lib/berkshelf/config.rb', line 64 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 |
.file ⇒ String?
Returns the contents of the file.
35 36 37 |
# File 'lib/berkshelf/config.rb', line 35 def file File.read(path) if File.exists?(path) end |
.instance ⇒ Config
Instantiate and return or just return the currently instantiated Berkshelf configuration
43 44 45 46 47 48 49 50 51 |
# File 'lib/berkshelf/config.rb', line 43 def instance @instance ||= if file from_json file else new end coerce_ssl end |
.local_location ⇒ String
13 14 15 |
# File 'lib/berkshelf/config.rb', line 13 def local_location ENV["BERKSHELF_CONFIG"] || File.join(".", ".berkshelf", "config.json") end |
.path ⇒ String
18 19 20 21 |
# File 'lib/berkshelf/config.rb', line 18 def path path = File.exists?(local_location) ? local_location : store_location File.(path) end |
.reload ⇒ Config
Reload the currently instantiated Berkshelf configuration
56 57 58 59 |
# File 'lib/berkshelf/config.rb', line 56 def reload @instance = nil self.instance end |
.set_config(config) ⇒ Object
24 25 26 |
# File 'lib/berkshelf/config.rb', line 24 def set_config(config) @instance = config end |
.set_path(new_path) ⇒ Object
29 30 31 |
# File 'lib/berkshelf/config.rb', line 29 def set_path(new_path) @instance = nil end |
.store_location ⇒ String
8 9 10 |
# File 'lib/berkshelf/config.rb', line 8 def store_location File.join(Berkshelf.berkshelf_path, "config.json") end |