Skip to content

Commit 320bf8b

Browse files
committed
(PUP-5395) Fix failing test, debug using blocks, and remove nil check
In this commit: Fix data_binding_spec.rb which was failing in an order sensitive way. Enclose formatted debug statement in Indirector in block. Remove redundant nil check for environment config. Added ticket PUP-5434 so we don't forget to remove deprecated methods.
1 parent b3e0c6a commit 320bf8b

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

Diff for: lib/puppet/data_providers/lookup_adapter.rb

+2-8
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,8 @@ def initialize_env_provider
172172
# Support running tests without an injector being configured == using a null implementation
173173
return EnvironmentDataProvider.new() unless injector
174174

175-
# Get the environment's configuration since we need to know which data provider
176-
# should be used (includes 'none' which gets a null implementation).
177-
#
178-
env_conf = @env.configuration
179-
180-
# Get the data provider and find the bound implementation
181-
# TODO: PUP-1640, drop the nil check when legacy env support is dropped
182-
provider_name = env_conf.nil? ? 'none' : env_conf.environment_data_provider
175+
# Get the name of the data provider from the environment's configuration and find the bound implementation
176+
provider_name = @env.configuration.environment_data_provider
183177
service_type = Registry.hash_of_environment_data_providers
184178
service_name = ENV_DATA_PROVIDERS_KEY
185179

Diff for: lib/puppet/indirector/hiera.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(*args)
1818
def find(request)
1919
not_found = Object.new
2020
options = request.options
21-
Puppet.debug "Performing a hiera indirector lookup of #{request.key} with options #{options.inspect}"
21+
Puppet.debug { "Performing a hiera indirector lookup of #{request.key} with options #{options.inspect}" }
2222
value = hiera.lookup(request.key, not_found, Hiera::Scope.new(options[:variables]), nil, convert_merge(options[:merge]))
2323
throw :no_such_key if value.equal?(not_found)
2424
value

Diff for: spec/integration/data_binding_spec.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@
5050
}
5151
}}
5252

53-
5453
before do
55-
Puppet[:data_binding_terminus] = "hiera"
54+
# Drop all occurances of cached hiera instances. This will reset @hiera in Puppet::Indirector::Hiera, Testing::DataBinding::Hiera,
55+
# and Puppet::DataBinding::Hiera. Different classes are active as indirection depending on configuration
56+
ObjectSpace.each_object(Class).select {|klass| klass <= Puppet::Indirector::Hiera }.each { |klass| klass.instance_variable_set(:@hiera, nil) }
57+
Puppet[:data_binding_terminus] = 'hiera'
5658
Puppet[:modulepath] = dir
5759
end
5860

0 commit comments

Comments
 (0)