class ChefCLI::PolicyfileCompiler
def handle_included_policies_preferred_cookbook_conflicts(included_policies_source)
def handle_included_policies_preferred_cookbook_conflicts(included_policies_source) # All cookbooks in the included policies are preferred. conflicting_source_messages = [] dsl.default_source.reject(&:null?).each do |source_b| conflicting_preferences = included_policies_source.preferred_cookbooks & source_b.preferred_cookbooks next if conflicting_preferences.empty? next if conflicting_preferences.all? do |cookbook_name| version = included_policies_source.universe_graph[cookbook_name].keys.first if included_policies_source.source_options_for(cookbook_name, version) == source_b.source_options_for(cookbook_name, version) true else false end end conflicting_source_messages << "#{source_b.desc} sets a preferred for cookbook(s) #{conflicting_preferences.join(", ")}. This conflicts with an included policy." end unless conflicting_source_messages.empty? msg = "You may not override the cookbook sources for any cookbooks required by included policies.\n" msg << conflicting_source_messages.join("\n") << "\n" raise IncludePolicyCookbookSourceConflict.new(msg) end end