Bug #12050

Use of metaparameters inside defines are incorrectly reported as dynamic variable lookups under certain conditions

Added by Tejas Viswanath 4 months ago. Updated 4 months ago.

Status:Accepted Start date:01/20/2012
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:parser
Target version:2.7.x
Affected Puppet version:2.7.6 Branch:
Keywords:parser deprecation
Votes: 0

Description

Consider this

I have a define:

define A($x) {
  ...
  if $require {
    SomeResource["name"] { require +> $require }
  }
}

and later use it in a class:

class B {
  A { "define_something":
    $x => ...
    # no require specified here
  }
}

This works fine.

However, if I now use Class B within a Class C, and have a require associated with Class B, like:

Class C {
  class { "D": 

  }

  class { "B":
    require => Class["D"],
  }
}

I would see:

warning: Dynamic lookup of $require at <script that has the define>:<line number of if $require> is deprecated.  Support will be removed in Puppet 2.8.  Use a fully-qualified variable name (e.g., $classname::variable) or parameterized classes.

So to summarize:

  1. Create a define that uses a metaparameter
  2. Use that define in a class. Don’t specify that metaparameter here
  3. Use this class in another class, while specifying the metaparameter

.. and you’ll see this warning.

History

Updated by Dominic Cleal 4 months ago

  • Category set to parser
  • Status changed from Unreviewed to Accepted
  • Target version set to 2.7.x
  • Keywords set to parser deprecation

Verified, example manifest: https://gist.github.com/1653197

Also available in: Atom PDF