This repository was archived by the owner on Jul 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 168
Better error messaging when license is invalid #1180
Merged
tduffield
merged 2 commits into
master
from
sclarson-add-license-error-for-invalid-licenses
Mar 1, 2017
Merged
Better error messaging when license is invalid #1180
tduffield
merged 2 commits into
master
from
sclarson-add-license-error-for-invalid-licenses
Mar 1, 2017
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This allows someone setting an invalid license parameter on the generator to receive an error and give a location to find valid values. I didn't find a good reference for the generator settings and when entering 'none' based on the config.rb talk it causes an undefined method error due to result not having a value. related docs: https://docs.chef.io/config_rb.html (shows none albeit for a different setting) https://docs.chef.io/ctl_chef.html#chef-generate-cookbook (shows all_rights as the default) Command output before change: ``` C:\Users\slarson\cookbooks λ chef generate cookbook dt_test Generating cookbook dt_test - Ensuring correct cookbook file content ================================================================================ Error executing action `create_if_missing` on resource 'template[C:/Users/slarson/cookbooks/dt_test/spec/unit/recipes/default_spec.rb]' ================================================================================ Chef::Mixin::Template::TemplateError ------------------------------------ undefined method `gsub' for nil:NilClass Resource Declaration: --------------------- 84: template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do 85: source "recipe_spec.rb.erb" 86: helpers(ChefDK::Generator::TemplateHelper) 87: action :create_if_missing 88: end 89: Compiled Resource: ------------------ template("C:/Users/slarson/cookbooks/dt_test/spec/unit/recipes/default_spec.rb") do action [:create_if_missing] retries 0 retry_delay 2 default_guard_interpreter :default source "recipe_spec.rb.erb" helper_modules [ChefDK::Generator::TemplateHelper] declared_type :template cookbook_name :dt_generator recipe_name "cookbook" path "C:/Users/slarson/cookbooks/dt_test/spec/unit/recipes/default_spec.rb" end Template Context: ----------------- on line #5 3: # Spec:: default 4: # 5: <%= license_description('#') %> 6: 7: require 'spec_helper' Platform: --------- i386-mingw32 ERROR: Chef failed to converge: Chef::Mixin::Template::TemplateError (undefined method `gsub' for nil:NilClass) on line #5: 3: # Spec:: default 4: # 5: <%= license_description('#') %> 6: 7: require 'spec_helper' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/generator.rb:155:in `license_description' (erubis):5:in `block in evaluate' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_eval' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `evaluate' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/mixin/template.rb:161:in`_render_templat C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/mixin/template.rb:147:in`render_template C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/template/content.rb:53:in `file_ C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/file_content_management/content_base.rb:4 C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:462:in `tempfile' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:339:in`do_generate_cont C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:150:in`action_create' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:162:in`action_create_if C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider.rb:145:in `run_action' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource.rb:591:in `run_action' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:69:in `run_action' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:97:in `block (2 levels) in conv C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:97:in `each' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:97:in `block in converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/resource_list.rb:94:ie_each_resource' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb: C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:tor_block' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb: C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb: C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:ndex' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/resource_list.rb:92:isource' C:/opscode/chefdk/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `execute_each_resource' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:96:in `converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/chef_runner.rb:43:in `converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/command/generator_commands/cookbook.rb:82:in`run' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/command/generate.rb:88:in `run' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/command/base.rb:58:in`run_with_default_options' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/cli.rb:73:in `run' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/bin/chef:25:in `<top (required)>' C:/opscode/chefdk/bin/chef:85:in `load' C:/opscode/chefdk/bin/chef:85:in `<main>' Caused by: (Chef::Mixin::Template::TemplateError) undefined method `gsub' for nil:NilClass ``` Output after: C:\Users\slarson\cookbooks λ rm -rf dt_test\ C:\Users\slarson\cookbooks λ chef generate cookbook dt_test Generating cookbook dt_test - Ensuring correct cookbook file content ================================================================================ Error executing action `create_if_missing` on resource 'template[C:/Users/slarson/cookbooks/dt_test/spec/unit/recipes/default_spec.rb]' ================================================================================ Chef::Mixin::Template::TemplateError ------------------------------------ Invalid generator.license setting: none. See available licenses at https://docs.chef.io/ctl_chef.html#chef-generate-cookbook Resource Declaration: --------------------- 84: template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do 85: source "recipe_spec.rb.erb" 86: helpers(ChefDK::Generator::TemplateHelper) 87: action :create_if_missing 88: end 89: Compiled Resource: ------------------ template("C:/Users/slarson/cookbooks/dt_test/spec/unit/recipes/default_spec.rb") do action [:create_if_missing] retries 0 retry_delay 2 default_guard_interpreter :default source "recipe_spec.rb.erb" helper_modules [ChefDK::Generator::TemplateHelper] declared_type :template cookbook_name :dt_generator recipe_name "cookbook" path "C:/Users/slarson/cookbooks/dt_test/spec/unit/recipes/default_spec.rb" end Template Context: ----------------- on line #5 3: # Spec:: default 4: # 5: <%= license_description('#') %> 6: 7: require 'spec_helper' Platform: --------- i386-mingw32 ERROR: Chef failed to converge: Chef::Mixin::Template::TemplateError (Invalid generator.license setting: none. See available licenses at https://docs.chef.io/ctl_chef.html#chef-generate-cookbook) on line #5: 3: # Spec:: default 4: # 5: <%= license_description('#') %> 6: 7: require 'spec_helper' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/generator.rb:153:in `license_description' (erubis):5:in `block in evaluate' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_eval' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `evaluate' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/mixin/template.rb:161:in `_render_template' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/mixin/template.rb:147:in `render_template' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/template/content.rb:53:in `file_for_provider' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/file_content_management/content_base.rb:40:in `tempfile' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:462:in`tempfile' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:339:in`do_generate_content' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:150:in`action_create' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider/file.rb:162:in`action_create_if_missing' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/provider.rb:145:in`run_action' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource.rb:591:in`run_action' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:69:in`run_action' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:97:in `block (2 levels) in converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:97:in `each' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:97:in `block in converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in `call' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:in `step' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource' C:/opscode/chefdk/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `execute_each_resource' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.12.15-universal-mingw32/lib/chef/runner.rb:96:in `converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/chef_runner.rb:43:in `converge' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/command/generator_commands/cookbook.rb:82:in`run' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/command/generate.rb:88:in`run' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/command/base.rb:58:in`run_with_default_options' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/lib/chef-dk/cli.rb:73:in`run' C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-dk-0.16.28/bin/chef:25:in `<top(required)>' C:/opscode/chefdk/bin/chef:85:in `load' C:/opscode/chefdk/bin/chef:85:in `<main>' Caused by: (Chef::Mixin::Template::TemplateError) Invalid generator.license setting: none. See available licenses at https://docs.chef.io/ctl_chef.html#chef-generate-cookbook ```
…ub.com/sclarson/chef-dk into sclarson-add-license-error-for-invalid-licenses Signed-off-by: Tom Duffield <tom@chef.io>
e27ffac
to
56c0f1e
Compare
tas50
approved these changes
Mar 1, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Rebase of #984
Issues Resolved
Fixes #983
Check List