Puppet: System Administration Automated

Support

Ticket #723 (closed enhancement: wontfix)

Opened 1 year ago

Last modified 1 year ago

functions that are statements should be evaluated later to receive all defined variables

Reported by: DavidS Assigned to: luke
Priority: low Milestone: beaker
Component: language Version: 0.23.0
Severity: minor Keywords: functions, variables, evaluation order
Cc: Triage Stage: Accepted
Attached Patches: Code Complexity: Trivial

Description

As discussed on the mailing list, starting at http://mail.madstop.com/pipermail/puppet-dev/2007-July/003605.html , functions that are no rvalues should be deferred so that they receive all variables from the "calling" scope.

This is especially helpful for class inclusion and logging statements.

Attached are a patch to implement this and a file to test the behaviour (delete the template statement to see the successful stuff)

Attachments

fix-functions-to-be-statements.patch (0.5 kB) - added by DavidS on 07/17/07 22:29:00.
patch to override the settor? method
test.pp (240 bytes) - added by DavidS on 07/17/07 22:30:54.
the test manifest
test.erb (37 bytes) - added by DavidS on 07/17/07 22:31:19.
the used test template

Change History

07/17/07 22:29:00 changed by DavidS

  • attachment fix-functions-to-be-statements.patch added.

patch to override the settor? method

07/17/07 22:30:13 changed by DavidS

  • severity changed from normal to minor.
  • specification changed from Unnecessary to Complete.
  • summary changed from functions that are {{{:statement}}}s should be evaluated later to receive all defined variables to functions that are statements should be evaluated later to receive all defined variables.
  • priority changed from normal to low.
  • complexity changed from Unknown to Trivial.
  • approval changed from Unnecessary to Approved.
  • stage changed from Unreviewed to Accepted.

a bit triage

07/17/07 22:30:54 changed by DavidS

  • attachment test.pp added.

the test manifest

07/17/07 22:31:19 changed by DavidS

  • attachment test.erb added.

the used test template

07/18/07 19:29:38 changed by luke

  • milestone set to beaker.

07/18/07 22:12:02 changed by luke

  • status changed from new to closed.
  • resolution set to wontfix.

Unfortunately, in looking more closely at the system, this doesn't really work, because some statement functions (e.g., tag) perform setting functions.

I think it's possible to make the 'include' function do lazy evaluation by storing the list of classes to be evaluated and then only evaluating them after the rest of the block is evaluated, which will get you the behaviour that you want, but I was wrong about how simple this is.