chef-cli icon indicating copy to clipboard operation
chef-cli copied to clipboard

Infer author_name, email, license from knife.rb if it exists when generating a new cookbook.

Open cstewart87 opened this issue 11 years ago • 6 comments

I see templates are used for metadata.rb, README, etc. for the cookbook generator, however, I'm not sure how to specify author_name, *email, licence, etc. Is there any way to read those from knife.rb?

cstewart87 avatar May 21 '14 21:05 cstewart87

Looks like we can set them up in the setup_context for the cookbook generator class:

https://github.com/opscode/chef-dk/blob/master/lib/chef-dk/command/generator_commands.rb#L204

One of the open questions is about the config though. I think we didn't finalize on if Chef DK should have a dedicated config other than existing Chef config. I think for now we can utilize Chef::Config if it exists. Thoughts?

sersut avatar May 21 '14 23:05 sersut

It looks like a lot of the information these files use would come from someone's metadata.rb, which would make sense since that's where that kind of information seems to go. I don't see that we could get much of that information from client.rb or knife.rb as they exist currently. I think some kind of separate Chef DK config would be a good idea.

mcquin avatar Jun 13 '14 01:06 mcquin

PR for reference: https://github.com/chef/chef-dk/pull/330

elliott-davis avatar Mar 03 '15 20:03 elliott-davis

I think https://github.com/chef/chef-dk/issues/792 applies here whereby these settings can be performed this way:

if defined?(ChefDK)
  chefdk.generator.license 'LICENSE'
  chefdk.generator.email 'EMAIL'
  chefdk.generator.copyright_holder 'ME'
end

mengesb avatar Sep 07 '17 22:09 mengesb

Elliott's PR (chef/chef-dk#330) would work to solve this issue but we're wondering if thats the best way to fix it. Defaulting chef command line flags from merged knife config is weird. It is less weird now that the suggested config file name is config.rb and we have the concept of the WorkstationConfigLoader.

But the existing PR would work and would mean saving time for all cookbook authors, so an imperfect solution is probably a good idea.

tyler-ball avatar Jul 22 '19 20:07 tyler-ball

Given that we're working on new flow for Workstation, I want to be very careful in what patterns we keep from ChefDK. DK shared configuration with Chef Infra. This offers a lot of convenience,but also resulted in a .chef/config.rb containing values that its application (Chef Infra Client) can't use.

Under Workstation, I would like to keep configurations separate unless the operator says otherwise via .chef-workstation/config.rb or CLI flag. Workstation should avoid silently finding and pulling in available Chef Infra configuration by default. This leads to inconsistent behaviors for the application, depending on what configurations are present.

As we expand the capabilities of workstation in ways that are only tangentially related to Infra Client, I expect we'll have to support additional configuration options - keeping Workstation configuration in its own space now will help reduce confusion (customer and developer) in the future.

edit: accidentally said that the config was kept in .chef/client.rb - should have been config.rb

marcparadise avatar Jul 23 '19 14:07 marcparadise