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

Document chefdk.* settings #54

Open
jblaine opened this issue Apr 12, 2016 · 6 comments
Open

Document chefdk.* settings #54

jblaine opened this issue Apr 12, 2016 · 6 comments
Labels
Aspect: UX How users feel interacting with the project, focusing on function, ease-of-use and accessibility. documentation How do we use this project? Triage: Confirmed Indicates and issue has been confirmed as described. Type: Enhancement Adds new functionality.

Comments

@jblaine
Copy link
Contributor

jblaine commented Apr 12, 2016

UPDATE: See end of thread first. This was originally an issue requesting the following.

Since 'knife cookbook create' is largely (or will be) deprecated, this is my plea for traditional behavior to be restored where one can use commands that take their default values from $HOME/.some_chef_file (a-la 'knife cookbook create' and knife.rb settings).

$HOME/.chef_cli.rb and something like:

cookbook_email = 'me@myorg.com'
cookbook_license = 'our_chosen_license'
cookbook_copyright = 'whatever'

Or... some way to set attributes and sanely reference include_recipe "#{chefdk_stock_code_generator}"

@smacfarlane
Copy link
Contributor

I had the same problem recently, and found that you could set the following in ~/.chef/config.rb

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

I wrapped it in if defined?(ChefDK) because I have some older knife plugins that puke on that syntax. I also pasted all my knife.rb settings into that file, and set it to be a symlink to config.rb. Not sure if this is the right solution, but so far I haven't hit any problems. There's also a chefdk.generator_cookbook option you can set.

Hope this helps!

@jblaine
Copy link
Contributor Author

jblaine commented Apr 12, 2016

@smacfarlane Thanks for the information. What ChefDK version are you using? I get an exception after adding that block with 0.12.0 from the stable release page.

if defined?(ChefDK)
  chefdk.generator.license = 'reserved'
  chefdk.generator.copyright_holder = 'OURORG'
  chefdk.generator.email = 'jblaine@our.org'
end

chef generate cookbook noodle:

  * template[/afs/rcf/user/jblaine/rcf-chef/noodle/spec/unit/recipes/default_spec.rb] action create_if_missing

    ================================================================================
    Error executing action `create_if_missing` on resource 'template[/afs/rcf/user/jblaine/rcf-chef/noodle/spec/unit/recipes/default_spec.rb]'
    ================================================================================

    Chef::Mixin::Template::TemplateError
    ------------------------------------
    undefined method `gsub' for nil:NilClass

    Resource Declaration:
    ---------------------
    # In /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.12.0/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb

     88: template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
     89:   source "recipe_spec.rb.erb"
     90:   helpers(ChefDK::Generator::TemplateHelper)
     91:   action :create_if_missing
     92: end
     93:

@smacfarlane
Copy link
Contributor

I think I'm on 0.12.0 (not at my workstation atm).

That error is probably caused by not setting the license to one of the licenses defined here: https://github.com/chef/chef-dk/blob/master/lib/chef-dk/generator.rb#L73-L152

@jblaine
Copy link
Contributor Author

jblaine commented Apr 12, 2016

Yup. Changing it to all_rights fixed things. Looks like a blog post is in my future tonight to share this buried information (with attribution to you).

@jblaine jblaine changed the title Support simple setting of copyright, email and license w/o needing to fork+diverge whole code_generator cookbook Document chefdk.* settings Apr 12, 2016
@smacfarlane
Copy link
Contributor

Great! Glad I could help.

@tyler-ball tyler-ball transferred this issue from chef-boneyard/chef-dk Nov 1, 2019
@tyler-ball tyler-ball added Aspect: Documentation Aspect: UX How users feel interacting with the project, focusing on function, ease-of-use and accessibility. Triage: Confirmed Indicates and issue has been confirmed as described. Type: Enhancement Adds new functionality. labels Nov 1, 2019
@gregkare
Copy link

gregkare commented Dec 27, 2019

On ChefDK version 4.6.35 (as well as previous versions) I can only make this work by having the chefdk.generator values set in a config.rb at the root of the current directory. Having them in .chef/config.rb or ~/.chef/config.rb makes chef generate cookbook COOKBOOK_NAME use the default values in the generated cookbook's metadata.rb

chefdk.generator.copyright_holder 'Copyright Holder'
chefdk.generator.license          'mit'
chefdk.generator.email            'mail@example.com`

Should I create a separate issue about this?

@tas50 tas50 added documentation How do we use this project? and removed Aspect: Documentation labels May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: UX How users feel interacting with the project, focusing on function, ease-of-use and accessibility. documentation How do we use this project? Triage: Confirmed Indicates and issue has been confirmed as described. Type: Enhancement Adds new functionality.
Projects
None yet
Development

No branches or pull requests

5 participants