diff options
author | Tim Smith <tsmith@chef.io> | 2018-05-31 14:27:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 14:27:36 -0700 |
commit | 4e2e9777fafedfbebb447dcd2e5021f222cb1581 (patch) | |
tree | 3345953954899988e725a11dde7436cf2ab3f5da /lib | |
parent | b270e5b4e95a516ddefec1c9f9c863bdcf0b523f (diff) | |
parent | 22332c8d68aafe27eb230b3f59b535a1cc908423 (diff) | |
download | chef-4e2e9777fafedfbebb447dcd2e5021f222cb1581.tar.gz |
Merge pull request #7300 from chef/tm/ri_defaults
resource_inspector: Add default values for properties
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource_inspector.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb index f4c745c080..bbec03ffd6 100644 --- a/lib/chef/resource_inspector.rb +++ b/lib/chef/resource_inspector.rb @@ -24,6 +24,17 @@ require "chef/resources" require "chef/json_compat" module ResourceInspector + def self.get_default(default) + if default.kind_of?(Chef::DelayedEvaluator) + # ideally we'd get the block we pass to `lazy`, but the best we can do + # is to get the source location, which then results in reparsing the source + # code for the resource ourselves and just no + "lazy default" + else + default + end + end + def self.extract_resource(resource, complete = false) data = {} data[:description] = resource.description @@ -44,6 +55,7 @@ module ResourceInspector acc << { name: n, description: opts[:description], introduced: opts[:introduced], is: opts[:is], deprecated: opts[:deprecated] || false, + default: get_default(opts[:default]), name_property: opts[:name_property] || false } end data |