class ChefDK::Policyfile::ChefServerCookbookSource
Attributes
chef_config[R]
preferred_cookbooks[R]
uri[R]
Public Class Methods
new(uri, chef_config: nil) { |self| ... }
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 30 def initialize(uri, chef_config: nil) @uri = SourceURI.parse(uri) @http_connections = {} @chef_config = chef_config @preferred_cookbooks = [] yield self if block_given? end
Public Instance Methods
==(other)
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 42 def ==(other) other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks end
default_source_args()
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 38 def default_source_args [:chef_server, uri] end
desc()
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 78 def desc "chef_server(#{uri})" end
null?()
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 74 def null? false end
preferred_for(*cookbook_names)
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 46 def preferred_for(*cookbook_names) preferred_cookbooks.concat(cookbook_names) end
preferred_source_for?(cookbook_name)
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 50 def preferred_source_for?(cookbook_name) preferred_cookbooks.include?(cookbook_name) end
source_options_for(cookbook_name, cookbook_version)
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 66 def source_options_for(cookbook_name, cookbook_version) { chef_server: uri.to_s, version: cookbook_version, http_client: http_connection_for(uri.to_s), } end
universe_graph()
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 54 def universe_graph @universe_graph ||= begin full_chef_server_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)| normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)| deps_by_version[version] = metadata["dependencies"] deps_by_version end normalized_graph end end end
Private Instance Methods
full_chef_server_graph()
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 91 def full_chef_server_graph @full_chef_server_graph ||= begin http_connection_for(uri.to_s).get("/universe") end end
http_connection_for(base_url)
click to toggle source
# File lib/chef-dk/policyfile/chef_server_cookbook_source.rb, line 84 def http_connection_for(base_url) @http_connections[base_url] ||= ChefServerAPIMulti.new(base_url, signing_key_filename: chef_config.client_key, client_name: chef_config.node_name) end