class ChefCLI::Policyfile::IncludedPoliciesCookbookSource
def ==(other)
def ==(other) other.is_a?(self.class) && other.included_policy_location_specs == included_policy_location_specs end
def build_source_options
def build_source_options included_policy_location_specs.inject({}) do |acc, policy_spec| lock = policy_spec.policyfile_lock lock.cookbook_locks.each do |(name, cookbook_lock)| version = cookbook_lock.version if acc[name] if acc[name][version] if acc[name][version] != cookbook_lock.source_options raise ConflictingCookbookSources.new("Conflicting sources provided for cookbook #{name}") end else raise ConflictingCookbookVersions.new("Multiple sources provided for cookbook #{name}") end else acc[name] = {} acc[name][version] = cookbook_lock.source_options end end acc end end
def build_universe
def build_universe included_policy_location_specs.inject({}) do |acc, policy_spec| lock = policy_spec.policyfile_lock cookbook_dependencies = lock.solution_dependencies.cookbook_dependencies cookbook_dependencies.each do |(cookbook, deps)| name = cookbook.name version = cookbook.version mapped_deps = deps.map do |dep| [dep[0], dep[1].to_s] end if acc[name] if acc[name][version] if acc[name][version] != mapped_deps raise ConflictingCookbookDependencies.new("Conflicting dependencies provided for cookbook #{name}") end else raise ConflictingCookbookVersions.new("Multiple versions provided for cookbook #{name}") end else acc[name] = {} acc[name][version] = mapped_deps end end acc end end
def check_for_conflicts!
def check_for_conflicts! source_options universe_graph end
def default_source_args
def default_source_args [:included_policies, []] end
def desc
def desc "included_policies()" end
def initialize(included_policy_location_specs)
Constructor
def initialize(included_policy_location_specs) @included_policy_location_specs = included_policy_location_specs @ui = UI.new @preferred_cookbooks = [] yield self if block_given? end
def null?
def null? false end
def preferred_cookbooks
def preferred_cookbooks universe_graph.keys end
def preferred_source_for?(cookbook_name)
def preferred_source_for?(cookbook_name) universe_graph.include?(cookbook_name) end
def source_options
def source_options @source_options ||= build_source_options end
def source_options_for(cookbook_name, cookbook_version)
-
(Hash)
- metadata for a single cookbook version
def source_options_for(cookbook_name, cookbook_version) source_options[cookbook_name][cookbook_version] end
def universe_graph
-
(Hash)
- universe_graph
def universe_graph @universe_graph ||= build_universe end