summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/ast/component.rb7
-rw-r--r--lib/puppet/parser/resource.rb1
-rw-r--r--lib/puppet/parser/scope.rb17
3 files changed, 20 insertions, 5 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb
index a3d1fb026..43ca85e4a 100644
--- a/lib/puppet/parser/ast/component.rb
+++ b/lib/puppet/parser/ast/component.rb
@@ -16,7 +16,7 @@ class Puppet::Parser::AST
@name = :definition
attr_accessor :classname, :arguments, :code, :scope, :keyword
- attr_accessor :exported, :namespace, :interp
+ attr_accessor :exported, :namespace, :interp, :virtual
# These are retrieved when looking up the superclass
attr_accessor :name
@@ -35,10 +35,15 @@ class Puppet::Parser::AST
name = args[:name] || title
exported = hash[:exported]
+ virtual = hash[:virtual]
pscope = origscope
scope = subscope(pscope, title)
+ if virtual or origscope.virtual?
+ scope.virtual = true
+ end
+
if exported or origscope.exported?
scope.exported = true
end
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 6dcfd36c3..69a6439b3 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -94,6 +94,7 @@ class Puppet::Parser::Resource
:title => self.title,
:arguments => self.to_hash,
:scope => self.scope,
+ :virtual => self.virtual,
:exported => self.exported
)
elsif builtin?
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 2f4917bee..c67825bb3 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -17,7 +17,7 @@ class Puppet::Parser::Scope
include Puppet::Util::Errors
attr_accessor :parent, :level, :interp, :source, :host
attr_accessor :name, :type, :topscope, :base, :keyword
- attr_accessor :top, :translated, :exported
+ attr_accessor :top, :translated, :exported, :virtual
# Whether we behave declaratively. Note that it's a class variable,
# so all scopes behave the same.
@@ -371,9 +371,7 @@ class Puppet::Parser::Scope
return values
end
- # Look up all of the exported objects of a given type. Just like
- # lookupobject, this only searches up through parent classes, not
- # the whole scope tree.
+ # Look up all of the exported objects of a given type.
def lookupexported(type)
@definedtable.find_all do |name, r|
r.type == type and r.exported?
@@ -492,6 +490,13 @@ class Puppet::Parser::Scope
@children << obj
+ # Mark the resource as virtual or exported, as necessary.
+ if self.exported?
+ obj.exported = true
+ elsif self.virtual?
+ obj.virtual = true
+ end
+
# The global table
@definedtable[obj.ref] = obj
@@ -717,6 +722,10 @@ class Puppet::Parser::Scope
return ary
end
end
+
+ def virtual?
+ self.virtual || self.exported?
+ end
end
# $Id$