Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support path in git and github sources for cookbook in Policyfile.rb #191

Open
nrgetik opened this issue Sep 3, 2021 · 0 comments
Open

Comments

@nrgetik
Copy link

nrgetik commented Sep 3, 2021

Describe the Enhancement:

I have a cookbook in a git repository that resides in a subfolder hierarchy below the top level of the repository. I want to refer to this location in a cookbook source line in Policyfile.rb, similarly to how a Policyfile.lock.json can be targeted in an include_policy source. This is not supported right now.

Describe the Need:

Anyone who is storing cookbook content in git which doesn't reside at the top level of a repository.

Current Alternative

Clone the repository locally, provide a local path. This is easy enough in most cases, but in some it may be less preferable.

Et cetera

In Policyfile.rb, include_policy can do something like this:

include_policy 'base_cookbook', git: 'https://github.com/chef-cft/chef-examples.git', branch: 'tg-include-policy', path: 'examples/include-policy/base_cookbook/Policyfile.lock.json'

But cookbook can't:

cookbook 'base_cookbook', git: 'https://github.com/chef-cft/chef-examples.git', branch: 'tg-include-policy', path: 'examples/include-policy/base_cookbook'
---- Begin output of /usr/local/bin/chef-cli update /Users/tom/gh/chef-examples/examples/include-policy/dependendent_cookbook/Policyfile.rb ----
STDOUT: Building policy dependendent_cookbook
Expanded run list: recipe[base_cookbook::default], recipe[dependendent_cookbook::default]
Caching Cookbooks...
Installing dependendent_cookbook >= 0.0.0 from path
Installing base_cookbook         >= 0.0.0 from git
STDERR: Error: Failed to generate Policyfile.lock
Reason: (CookbookOmnifetch::NotACookbook) The resource at '/var/folders/lr/_nvzwc7x3hjb9_09bh0wnpdm0000gn/T/d20210902-28012-13wmwb' does not appear to be a valid cookbook. Does it have a metadata.rb?
---- End output of /usr/local/bin/chef-cli update /Users/tom/gh/chef-examples/examples/include-policy/dependendent_cookbook/Policyfile.rb ----

Also, as an aside, parameters that are specified for either of these don't seem to get validated at all. path: isn't supported for cookbook, but why don't we see an error about this at some point prior? I can add anything: 'whatever' to this line, and I don't see any complaints/warnings.

@nrgetik nrgetik changed the title Support paths in git and github sources for cookbook in Policyfile.rb Support path in git and github sources for cookbook in Policyfile.rb Sep 3, 2021
@tas50 tas50 transferred this issue from chef/chef Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant