chef / chef-cli

The 'chef' command line tool included in Chef Workstation
Apache License 2.0
16 stars 24 forks source link

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

Open cstewart87 opened 10 years ago

cstewart87 commented 10 years ago

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?

sersut commented 10 years ago

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?

mcquin commented 10 years ago

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.

elliott-davis commented 9 years ago

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

mengesb commented 6 years ago

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
tyler-ball commented 5 years ago

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.

marcparadise commented 5 years ago

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