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

knife cookbook doc fails if node attributes are referenced in light-weight resources. #24

Open
RobertNorthard opened this issue Jun 29, 2015 · 5 comments

Comments

@RobertNorthard
Copy link

Knife cookbook doc fails if node attributes are referenced in light-weight resources.

attribute :attribute_name, :kind_of => value, :default => node['org_cb']['attr']

@philoserf
Copy link

@RobertNorthard Are you willing to give us a Gist with a bit more detail. Perhaps the result of knife -v, a snippet from your resources/[filename].rb, and the command line you use to invoke knife cookbook doc.

@smedefind
Copy link

I'm running into this too.

Knife Output:

knife cookbook doc . -VV
/Users/smedefind/.rvm/gems/ruby-2.1.5/gems/chef-11.18.6/lib/chef/resource/lwrp_base.rb:141:in `node': undefined method `node' for nil:NilClass (NoMethodError)
        from /Users/smedefind/src/cookbooks/optoro_nagios/resources/s3_file.rb:36:in `build_native_from_file'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/resource_model.rb:98:in `class_eval'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/resource_model.rb:98:in `build_native_from_file'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/resource_model.rb:8:in `initialize'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/readme_model.rb:27:in `new'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/readme_model.rb:27:in `block in initialize'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/readme_model.rb:26:in `each'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/knife_cookbook_doc/readme_model.rb:26:in `initialize'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/chef/knife/cookbook_doc.rb:47:in `new'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/knife-cookbook-doc-0.14.0/lib/chef/knife/cookbook_doc.rb:47:in `run'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/chef-11.18.6/lib/chef/knife.rb:493:in `run_with_pretty_exceptions'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/chef-11.18.6/lib/chef/knife.rb:174:in `run'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/chef-11.18.6/lib/chef/application/knife.rb:139:in `run'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/gems/chef-11.18.6/bin/knife:25:in `<top (required)>'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/bin/knife:23:in `load'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/bin/knife:23:in `<main>'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
        from /Users/smedefind/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'

Relevant section of code:

34 attribute :checksum, kind_of: [String, NilClass], default: nil
35 attribute :backup, kind_of: [Integer, FalseClass], default: 5
36 if node['platform_family'] == 'windows'
37   attribute :inherits, kind_of: [TrueClass, FalseClass], default: true
38   attribute :rights, kind_of: Hash, default: nil
39 end
40
41  version = Chef::Version.new(Chef::VERSION[/^(\d+\.\d+\.\d+)/, 1])

RobertNorthard added a commit to RobertNorthard/knife-cookbook-doc that referenced this issue Sep 19, 2015
@RobertNorthard
Copy link
Author

Pull request, #29 should resolve the initial issue with the node object being undefined. However as the run_context is nill it won't be able to resolve any of the node's attributes and hence node.hi or node['hi'] will throw a nil class exception.

@bryan-buckland
Copy link

Any updates on handle node object in resources for documentation ?

@realityforge
Copy link
Owner

Not had time to work on this sorry 🙁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants