diff options
author | Jacob Helwig <jacob@puppetlabs.com> | 2011-04-15 09:52:56 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-04-19 11:03:40 -0700 |
commit | 656eff821bec534a23e3e81e86ddbe3fc28f10ed (patch) | |
tree | c38ace649b9488a40d46dc3db07b9bc9eb790ab8 /lib/puppet/parser/resource.rb | |
parent | bee1ef73e5c83541edcf1249f062ba832618da48 (diff) | |
download | puppet-656eff821bec534a23e3e81e86ddbe3fc28f10ed.tar.gz puppet-656eff821bec534a23e3e81e86ddbe3fc28f10ed.tar.xz puppet-656eff821bec534a23e3e81e86ddbe3fc28f10ed.zip |
(#4655) Allow stage to be set using a default class parameter
For example:
stage{ pre: before => Stage[main] }
class someclass ($stage=pre ) { ... }
class { someclass: }
This transplants adding the edge from the resource to the stage from
the compiler into when the resource is evaluated. This moves adding
the stage edges to after when the defaults are copied into the
resources, making them available.
Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Diffstat (limited to 'lib/puppet/parser/resource.rb')
-rw-r--r-- | lib/puppet/parser/resource.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index c007d4dbe..b98bc0b80 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -62,13 +62,28 @@ class Puppet::Parser::Resource < Puppet::Resource scope.environment end + # Process the stage metaparameter for a class. A containment edge + # is drawn from the class to the stage. The stage for containment + # defaults to main, if none is specified. + def add_edge_to_stage + unless stage = catalog.resource(:stage, self[:stage] || (scope && scope.resource && scope.resource[:stage]) || :main) + raise ArgumentError, "Could not find stage #{self[:stage] || :main} specified by #{self}" + end + + self[:stage] ||= stage.title unless stage.title == :main + catalog.add_edge(stage, self) + end + # Retrieve the associated definition and evaluate it. def evaluate return if evaluated? @evaluated = true if klass = resource_type and ! builtin_type? finish - return klass.evaluate_code(self) + evaluated_code = klass.evaluate_code(self) + add_edge_to_stage + + return evaluated_code elsif builtin? devfail "Cannot evaluate a builtin type (#{type})" else |