Method: Berkshelf::Source#initialize
- Defined in:
- lib/berkshelf/source.rb
#initialize(berksfile, source, **options) ⇒ Source
Returns a new instance of Source.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/berkshelf/source.rb', line 16 def initialize(berksfile, source, **) @options = { timeout: api_timeout, open_timeout: [(api_timeout / 10), 3].max, ssl: {} } @options.update() case source when String # source "https://supermarket.chef.io/" @type = :supermarket @uri_string = source when :chef_server # source :chef_server @type = :chef_server @uri_string = [:url] || Berkshelf::Config.instance.chef.chef_server_url when Hash # source type: uri, option: value, option: value source = source.dup @type, @uri_string = source.shift @options.update(source) end # Default options for some source types. case @type when :chef_server @options[:client_name] ||= Berkshelf::Config.instance.chef.node_name @options[:client_key] ||= Berkshelf::Config.instance.chef.client_key when :artifactory @options[:api_key] ||= Berkshelf::Config.instance.chef.artifactory_api_key || ENV["ARTIFACTORY_API_KEY"] when :chef_repo @options[:path] = uri_string # If given a relative path, expand it against the Berksfile's folder. @options[:path] = File.(@options[:path], File.dirname(berksfile ? berksfile.filepath : Dir.pwd)) # Lie because this won't actually parse as a URI. @uri_string = "file://#{@options[:path]}" end # Set some default SSL options. Berkshelf::Config.instance.ssl.each do |key, value| @options[:ssl][key.to_sym] = value unless @options[:ssl].include?(key.to_sym) end @options[:ssl][:cert_store] = ssl_policy.store if ssl_policy.store @universe = nil end |