Skip to content

Commit a783242

Browse files
committed
(PUP-10922) Copy fqdn fact before mutating it
It's not possible to mutate the fqdn fact, because facts are frozen when added to topscope[1], so make a copy when downcasing and update the test. [1] https://github.com/puppetlabs/puppet/blob/7.6.1/lib/puppet/parser/scope.rb#L811
1 parent f89697a commit a783242

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/puppet/parser/functions/fqdn_rand.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
downcase = !!args.shift
2525

2626
fqdn = self['::fqdn']
27-
fqdn.downcase! if downcase
27+
fqdn = fqdn.downcase if downcase
2828

2929
# Puppet 5.4's fqdn_rand function produces a different value than earlier versions
3030
# for the same set of inputs.

spec/unit/parser/functions/fqdn_rand_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def fqdn_rand(max, args = {})
8080
extra = args[:extra_identifier] || []
8181

8282
scope = create_test_scope_for_node('localhost')
83-
allow(scope).to receive(:[]).with("::fqdn").and_return(host)
83+
scope.compiler.topscope['fqdn'] = host.freeze
8484

8585
scope.function_fqdn_rand([max] + extra)
8686
end

0 commit comments

Comments
 (0)