From 6d31b26d960c8decd5dda31ba353b31ba0bc5208 Mon Sep 17 00:00:00 2001 From: Justin Stoller Date: Tue, 3 Sep 2024 15:47:56 -0700 Subject: [PATCH] [#9470] Respect environment/settings in base context rich_data value --- lib/puppet.rb | 2 +- spec/unit/resource_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/puppet.rb b/lib/puppet.rb index 484fda4c4ef..e80248b86c9 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -237,7 +237,7 @@ def self.base_context(settings) :ssl_context => proc { Puppet.runtime[:http].default_ssl_context }, :http_session => proc { Puppet.runtime[:http].create_session }, :plugins => proc { Puppet::Plugins::Configuration.load_plugins }, - :rich_data => false + :rich_data => proc { Puppet.lookup(:current_environment).rich_data? } } end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index c527358e3f6..a351b23cae2 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -906,6 +906,12 @@ def inject_and_set_defaults(resource, scope) # Note: to_stringified_spec.rb has tests for all other data types end + # Try something like + # include PuppetSpec::Compiler + # Puppet[:rich_data] = true|false + # resource (?) = evaluate('Deferred("func", ["a", "b", "c"])') + # resource.to_data_hash() + describe "when converting from json" do before do @data = {