summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-03 18:20:04 -0500
committerLuke Kanies <luke@madstop.com>2007-09-03 18:20:04 -0500
commit9d70b9746c09f648efd6a315b3ea088da38ecd1e (patch)
treea8e7335d58008e1e24ed854703b1b9d54cc5a68d
parentb021587e309f237bd16bd4f5cc51e79266cbd222 (diff)
downloadpuppet-9d70b9746c09f648efd6a315b3ea088da38ecd1e.tar.gz
puppet-9d70b9746c09f648efd6a315b3ea088da38ecd1e.tar.xz
puppet-9d70b9746c09f648efd6a315b3ea088da38ecd1e.zip
Removing the Scope#setresource method, since it was essentially redundant. The work is done in either AST::ResourceDef#evaluate or Compile#store_resource.
-rw-r--r--lib/puppet/parser/ast/resourcedef.rb6
-rw-r--r--lib/puppet/parser/scope.rb15
-rwxr-xr-xtest/language/collector.rb14
-rwxr-xr-xtest/language/functions.rb6
4 files changed, 12 insertions, 29 deletions
diff --git a/lib/puppet/parser/ast/resourcedef.rb b/lib/puppet/parser/ast/resourcedef.rb
index dfd7c447e..7a43f6b32 100644
--- a/lib/puppet/parser/ast/resourcedef.rb
+++ b/lib/puppet/parser/ast/resourcedef.rb
@@ -90,13 +90,13 @@ class ResourceDef < AST::Branch
# many times.
objtitles.collect { |objtitle|
exceptwrap :type => Puppet::ParseError do
- exp = self.exported || scope.exported
+ exp = self.exported || scope.exported?
# We want virtual to be true if exported is true. We can't
# just set :virtual => self.virtual in the initialization,
# because sometimes the :virtual attribute is set *after*
# :exported, in which case it clobbers :exported if :exported
# is true. Argh, this was a very tough one to track down.
- virt = self.virtual || exported
+ virt = self.virtual || scope.virtual? || exported
obj = Puppet::Parser::Resource.new(
:type => objtype,
:title => objtitle,
@@ -112,7 +112,7 @@ class ResourceDef < AST::Branch
# And then store the resource in the scope.
# XXX At some point, we need to switch all of this to return
# objects instead of storing them like this.
- scope.setresource(obj)
+ scope.compile.store_resource(scope, obj)
obj
end
}.reject { |obj| obj.nil? }
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 396cce888..635a471df 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -255,21 +255,6 @@ class Puppet::Parser::Scope
nil
end
- # Add a new object to our object table and the global list, and do any necessary
- # checks.
- def setresource(resource)
- @compile.store_resource(self, resource)
-
- # Mark the resource as virtual or exported, as necessary.
- if self.exported?
- resource.exported = true
- elsif self.virtual?
- resource.virtual = true
- end
-
- return resource
- end
-
# Override a parameter in an existing object. If the object does not yet
# exist, then cache the override in a global table, so it can be flushed
# at the end.
diff --git a/test/language/collector.rb b/test/language/collector.rb
index 18d88a2c4..55c93c2d5 100755
--- a/test/language/collector.rb
+++ b/test/language/collector.rb
@@ -46,8 +46,8 @@ class TestCollector < Test::Unit::TestCase
:virtual => true, :params => {:owner => "root"})
two = mkresource(:type => "file", :title => "/tmp/virtual2",
:virtual => true, :params => {:owner => "root"})
- @scope.setresource one
- @scope.setresource two
+ @scope.compile.store_resource @scope, one
+ @scope.compile.store_resource @scope, two
# Now run the collector again and make sure it finds our resource
assert_nothing_raised do
@@ -68,7 +68,7 @@ class TestCollector < Test::Unit::TestCase
# Now add our third resource
three = mkresource(:type => "file", :title => "/tmp/virtual3",
:virtual => true, :params => {:owner => "root"})
- @scope.setresource three
+ @scope.compile.store_resource @scope, three
# Run the collection
assert_nothing_raised do
@@ -84,12 +84,12 @@ class TestCollector < Test::Unit::TestCase
# Make a virtual resource
virtual = mkresource(:type => "file", :title => "/tmp/virtual",
:virtual => true, :params => {:owner => "root"})
- @scope.setresource virtual
+ @scope.compile.store_resource @scope, virtual
# And a non-virtual
real = mkresource(:type => "file", :title => "/tmp/real",
:params => {:owner => "root"})
- @scope.setresource real
+ @scope.compile.store_resource @scope, real
# Now make a collector
coll = nil
@@ -163,7 +163,7 @@ class TestCollector < Test::Unit::TestCase
# Make a resource
one = mkresource(:type => "file", :title => "/tmp/virtual1",
:virtual => true, :params => {:owner => "root"})
- @scope.setresource one
+ @scope.compile.store_resource @scope, one
# Now perform the collection again, and it should still be there
assert_nothing_raised do
@@ -176,5 +176,3 @@ class TestCollector < Test::Unit::TestCase
assert_equal(false, one.virtual?, "One was not realized")
end
end
-
-# $Id$
diff --git a/test/language/functions.rb b/test/language/functions.rb
index dbb66e95e..6cea89066 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -320,7 +320,7 @@ class TestLangFunctions < Test::Unit::TestCase
virtual = mkresource(:type => type, :title => title,
:virtual => true, :params => {})
- scope.setresource virtual
+ scope.compile.store_resource(scope, virtual)
ref = Puppet::Parser::Resource::Reference.new(
:type => type, :title => title,
@@ -387,9 +387,9 @@ class TestLangFunctions < Test::Unit::TestCase
"Multiple falses were somehow true")
# Now make sure we can test resources
- scope.setresource mkresource(:type => "file", :title => "/tmp/rahness",
+ scope.compile.store_resource(scope, mkresource(:type => "file", :title => "/tmp/rahness",
:scope => scope, :source => scope.source,
- :params => {:owner => "root"})
+ :params => {:owner => "root"}))
yep = Puppet::Parser::Resource::Reference.new(:type => "file", :title => "/tmp/rahness")
nope = Puppet::Parser::Resource::Reference.new(:type => "file", :title => "/tmp/fooness")