bolt-modules/boltlib/lib/puppet/functions/set_var.rb in bolt-0.17.2 vs bolt-modules/boltlib/lib/puppet/functions/set_var.rb in bolt-0.18.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'bolt/error' # Sets a variable { key => value } for a target. # # This function takes 3 parameters: @@ -21,9 +23,15 @@ Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, operation: 'set_var' ) end inventory = Puppet.lookup(:bolt_inventory) { nil } + + unless inventory + raise Puppet::ParseErrorWithIssue.from_issue_and_stack( + Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('set a var on a target') + ) + end inventory.set_var(target, key, value) end end