diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource.rb | 21 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 |
2 files changed, 18 insertions, 5 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 36538b6e7a..0335b6f903 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -667,21 +667,34 @@ class Chef def to_text return "suppressed sensitive resource output" if sensitive - ivars = instance_variables.map { |ivar| ivar.to_sym } - HIDDEN_IVARS text = "# Declared in #{@source_line}\n\n" text << "#{resource_name}(\"#{name}\") do\n" + + all_props = {} + self.class.state_properties.map do |p| + all_props[p.name.to_s] = p.sensitive? ? '"*sensitive value suppressed*"' : value_to_text(p.get(self)) + end + + ivars = instance_variables.map { |ivar| ivar.to_sym } - HIDDEN_IVARS ivars.each do |ivar| - if (value = instance_variable_get(ivar)) && !(value.respond_to?(:empty?) && value.empty?) - value_string = value.respond_to?(:to_text) ? value.to_text : value.inspect - text << " #{ivar.to_s.sub(/^@/, '')} #{value_string}\n" + iv = ivar.to_s.sub(/^@/, "") + if all_props.keys.include?(iv) + text << " #{iv} #{all_props[iv]}\n" + elsif (value = instance_variable_get(ivar)) && !(value.respond_to?(:empty?) && value.empty?) + text << " #{iv} #{value_to_text(value)}\n" end end + [@not_if, @only_if].flatten.each do |conditional| text << " #{conditional.to_text}\n" end text << "end\n" end + def value_to_text(value) + value.respond_to?(:to_text) ? value.to_text : value.inspect + end + def inspect ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS ivars.inject("<#{self}") do |str, ivar| diff --git a/lib/chef/version.rb b/lib/chef/version.rb index c16ddbd795..4573e2ea7a 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -21,7 +21,7 @@ class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = "12.19.20" + VERSION = "12.19.24" end # |