Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Multiple policyfile sources #450

Merged
merged 6 commits into from
Jul 8, 2015
Merged

Conversation

danielsdeleo
Copy link
Contributor

Addresses #430

This allows you to have multiple default_source lines in your policyfile.rb, so you can have a chef_repo with all your org-specific stuff, but pull cookbooks from the public supermarket easily. The way it's designed right now, the cookbook sets need to be disjoint (i.e., there cannot be cookbooks with the same name in both locations). If you manually specify a cookbook's source with a cookbook "foo", source_option: "place" line, though it will be respected. One downside of that is, if there is a conflict between your two sources, and the cookbook is totally irrelevant (wouldn't be in the dependency solution), it'll end up in your policy anyway, because adding the cookbook line tells chef-dk you want that cookbook around. That said, the 80% case we're targeting here is where there shouldn't be any overlap between, say, supermarket and your chef repo (or internal supermarket), and if there is a conflicting cookbook, it's a mistake.

@lamont-granquist
Copy link
Contributor

cool 👍

@@ -123,7 +126,11 @@ def install
end

def create_spec_for_cookbook(cookbook_name, version)
source_options = default_source.source_options_for(cookbook_name, version)
matching_source = default_source.find { |s|
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this ever be nil (say because default_source is the null source)? Would you want to grab default_source.first in case that happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so from looking at the code, but you can only get here via #install after #graph_solution is called. There's no way to set up a Policyfile so that #graph_solution doesn't fail and also there is no source for the cookbook. In any case, I added some tests to demonstrate this.

@ksubrama
Copy link

ksubrama commented Jul 8, 2015

Yay! 👍 🚢

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants