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

chef generate fails with code_generator from Chef #29

Closed
zmaupin opened this issue Sep 12, 2019 · 1 comment
Closed

chef generate fails with code_generator from Chef #29

zmaupin opened this issue Sep 12, 2019 · 1 comment
Labels
Triage: Duplicate Indicates an issue is a duplicate of other open issue.

Comments

@zmaupin
Copy link

zmaupin commented Sep 12, 2019

Version:

 $ chef --version
ChefDK version: 4.4.1
Chef Infra Client version: 15.2.20
Chef InSpec version: 4.12.0
Test Kitchen version: 2.2.5
Foodcritic version: 16.1.1
Cookstyle version: 5.2.17

Environment:

macOS Mojave 10.14.6
Downloaded the code_generator from https://github.com/chef/chef-dk/tree/master/lib/chef-dk/skeletons/code_generator
I also tried using https://github.com/chef/chef-dk/tree/master/lib/chef-dk/skeletons/code_generator with the same errors.

Scenario:

I want to use chef generate cookbook my_cookbook -g code_generator/

Steps to Reproduce:

  • Build the code_generator with chef generate generator
  • Try to use the code_generator cookbook to generate a new cookbook chef generate cookbook my_cookbook -g code_generator/

Expected Result:

I expected a new cookbook built with the generator cookbook.

Actual Result:

 $ chef generate cookbook testcookbook1 -b -g code_generator/
Generating cookbook testcookbook1
- Ensuring correct cookbook content
[2019-09-12T10:57:56-04:00] WARN: Found a directory testcookbook1 in the cookbook path, but it contains no cookbook files. skipping.

================================================================================
Error executing action `create_if_missing` on resource 'template[/Users/zm/github/infraconfig/testcookbook1/metadata.rb]'
================================================================================

NoMethodError
-------------
undefined method `metadata' for nil:NilClass

Resource Declaration:
---------------------
# In /Users/zm/github/infraconfig/code_generator/recipes/cookbook.rb

 25: template "#{cookbook_dir}/metadata.rb" do
 26:   helpers(ChefDK::Generator::TemplateHelper)
 27:   variables(
 28:     spdx_license: spdx_license
 29:   )
 30:   action :create_if_missing
 31: end
 32:

Compiled Resource:
------------------
# Declared in /Users/zm/github/infraconfig/code_generator/recipes/cookbook.rb:25:in `from_file'

template("/Users/zm/github/infraconfig/testcookbook1/metadata.rb") do
  action [:create_if_missing]
  default_guard_interpreter :default
  source "metadata.rb.erb"
  helper_modules [ChefDK::Generator::TemplateHelper]
  declared_type :template
  cookbook_name :code_generator
  recipe_name "cookbook"
  variables {:spdx_license=>"All Rights Reserved"}
  path "/Users/zm/github/infraconfig/testcookbook1/metadata.rb"
  owner nil
  group nil
  mode nil
  verifications []
end

System Info:
------------
chef_version=15.2.20
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin16]
program_name=/usr/local/bin/chef
executable=/opt/chefdk/bin/chef

ERROR: Chef Infra failed to converge: template[/Users/zm/github/infraconfig/testcookbook1/metadata.rb] (code_generator::cookbook line 25) had an error: NoMethodError: undefined method `metadata' for nil:NilClass from file /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/chef-15.2.20/lib/chef/cookbook_loader.rb:99:in `load_cookbook'
Caused by: (NoMethodError) template[/Users/zm/github/infraconfig/testcookbook1/metadata.rb] (code_generator::cookbook line 25) had an error: NoMethodError: undefined method `metadata' for nil:NilClass
@zmaupin zmaupin added the Status: Untriaged An issue that has yet to be triaged. label Sep 12, 2019
@zmaupin
Copy link
Author

zmaupin commented Sep 12, 2019

dupe of #8

@zmaupin zmaupin closed this as completed Sep 12, 2019
@afiune afiune added Triage: Duplicate Indicates an issue is a duplicate of other open issue. and removed Status: Untriaged An issue that has yet to be triaged. labels Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

2 participants