Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-6174

"Copy" variables from a class in the current scope

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.5.0
    • Component/s: Language
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide
      • That multiple variables can be set at once from the corresponding variables in a class (which must have been already included).
      • That an error is raised if a non existing variable/parameter is referenced, and that this error message shows the name of what is missing
      • That it is ok to reference existing variables that have undef value
      Show
      That multiple variables can be set at once from the corresponding variables in a class (which must have been already included). That an error is raised if a non existing variable/parameter is referenced, and that this error message shows the name of what is missing That it is ok to reference existing variables that have undef value
    • Epic Link:
    • Story Points:
      1
    • Sprint:
      Language 2016-05-04, Language 2016-05-18
    • Release Notes:
      New Feature
    • Release Notes Summary:
      Hide
      It is now possible to assign to multiple variables at once from the corresponding variables in a class scope by using the syntax:

      [ $var1, $var2 ] = Class['classfoo::params']

      which has the same effect as:

      $var1 = $clasfoo::params::var1
      $var2 = $clasfoo::params::var2

      An error is raised if the referenced variables does not exist as a variable or parameter in the referenced class.
      Show
      It is now possible to assign to multiple variables at once from the corresponding variables in a class scope by using the syntax: [ $var1, $var2 ] = Class['classfoo::params'] which has the same effect as: $var1 = $clasfoo::params::var1 $var2 = $clasfoo::params::var2 An error is raised if the referenced variables does not exist as a variable or parameter in the referenced class.

      Description

      It could be nice to be able to "copy" (sorry I don't find the correct expression) some variables from a class in the current scope with something like that:

      # We assume that $var1 and $var2 are defined in the class
      # classfoo::params (as parameters _or_ in its body).
      [ $var1, $var2 ] = Class['Classfoo::Params']
      

      In this case, It would be similar to the syntax:

      [ $a, $b ] = { "a" => "value1", "b" => "value2, "c" => "value3" }
      

      Here some points:

      • The code should fail if $var1 or var2 are not defined in the class classfoo::params (in its body or as parameters of the class).
      • It could be possible to "import" only a part of the variables from classfoo::params.
      • Point that is not clear for me: what should be the behavior of the code if the class classfoo::params is not yet included in the catalog at this moment? A fail?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                qa qa
                Reporter:
                flaf Francois Lafont
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support