Skip to content

Commit c2e2aaf

Browse files
committed
(maint) Reset "tasks" setting after with_script_compiler
The `Puppet::Pal.with_script_compiler` method sets the `Puppet[:tasks]` setting to true for the duration of the block, but never sets it back to its original state. This means that the mode of operation the process is in will be globally changed depending on whether this method has been called. The corresponding `with_catalog_compiler` method has similar behavior in setting `Puppet[:tasks]` to false, but it ensures that the setting is reset to its previous value when the method returns. We now copy that behavior in `with_script_compiler`.
1 parent bc5de2c commit c2e2aaf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/puppet/pal/pal_impl.rb

+5
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,18 @@ def self.with_script_compiler(
8383
end
8484
end
8585

86+
previous_tasks_value = Puppet[:tasks]
87+
previous_code_value = Puppet[:code]
8688
Puppet[:tasks] = true
8789
# After the assertions, if code_string is non nil - it has the highest precedence
8890
Puppet[:code] = code_string unless code_string.nil?
8991

9092
# If manifest_file is nil, the #main method will use the env configured manifest
9193
# to do things in the block while a Script Compiler is in effect
9294
main(manifest_file, facts, variables, :script, &block)
95+
ensure
96+
Puppet[:tasks] = previous_tasks_value
97+
Puppet[:code] = previous_code_value
9398
end
9499

95100
# Evaluates a Puppet Language script string.

0 commit comments

Comments
 (0)