summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-13 23:10:46 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-13 23:10:46 +0000
commitcf5291a355dcdb92c0de4564633a30a4933f6b69 (patch)
tree66bfa074e92e6f1aa52d269dc9c00941653ea0d6
parentca6ac62824ddbb14d827687ade5235801b70383c (diff)
downloadpuppet-cf5291a355dcdb92c0de4564633a30a4933f6b69.tar.gz
puppet-cf5291a355dcdb92c0de4564633a30a4933f6b69.tar.xz
puppet-cf5291a355dcdb92c0de4564633a30a4933f6b69.zip
Fixing the interpreter to nodesearch across all listed names, just like is done in the manifests. Also fixing a comment in type.rb
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1586 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/parser/interpreter.rb24
-rw-r--r--lib/puppet/type.rb2
-rwxr-xr-xtest/language/interpreter.rb32
3 files changed, 46 insertions, 12 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index ee770d02e..19d61c276 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -143,7 +143,7 @@ module Puppet
# Search for our node in the various locations. This only searches
# locations external to the files; the scope is responsible for
# searching the parse tree.
- def nodesearch(node)
+ def nodesearch(*nodes)
# At this point, stop at the first source that defines
# the node
@nodesources.each do |source|
@@ -151,18 +151,20 @@ module Puppet
parent = nil
nodeclasses = nil
if self.respond_to? method
- parent, nodeclasses = self.send(method, node)
+ nodes.each do |node|
+ parent, nodeclasses = self.send(method, node)
- if parent or (nodeclasses and !nodeclasses.empty?)
- Puppet.info "Found %s in %s" % [node, source]
- return parent, nodeclasses
- else
- # Look for a default node.
- parent, nodeclasses = self.send(method, "default")
if parent or (nodeclasses and !nodeclasses.empty?)
- Puppet.info "Found default node for %s in %s" %
- [node, source]
+ Puppet.info "Found %s in %s" % [node, source]
return parent, nodeclasses
+ else
+ # Look for a default node.
+ parent, nodeclasses = self.send(method, "default")
+ if parent or (nodeclasses and !nodeclasses.empty?)
+ Puppet.info "Found default node for %s in %s" %
+ [node, source]
+ return parent, nodeclasses
+ end
end
end
end
@@ -306,7 +308,7 @@ module Puppet
args[:names] = names
- parent, nodeclasses = nodesearch(client)
+ parent, nodeclasses = nodesearch(*names)
args[:classes] += nodeclasses if nodeclasses
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 83920bf74..ad38cbeec 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -513,7 +513,7 @@ class Type < Puppet::Element
return provider
end
- # Make sure we have a :use parameter defined. Only gets called if there
+ # Make sure we have a :provider parameter defined. Only gets called if there
# are providers.
def self.providify
return if @paramhash.has_key? :provider
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb
index c22bb73ba..51ee1e5f4 100755
--- a/test/language/interpreter.rb
+++ b/test/language/interpreter.rb
@@ -317,4 +317,36 @@ class nothernode {}
end
end
end
+
+ # Make sure nodesearch uses all names, not just one.
+ def test_nodesearch_multiple_names
+ bucket = {}
+ Puppet::Parser::Interpreter.send(:define_method, "nodesearch_multifake") do |node|
+ if bucket[node]
+ return *bucket[node]
+ else
+ return nil, nil
+ end
+ end
+ manifest = tempfile()
+ File.open(manifest, "w") do |f| f.puts "" end
+ interp = nil
+ assert_nothing_raised {
+ interp = Puppet::Parser::Interpreter.new(
+ :Manifest => manifest,
+ :NodeSources => [:multifake]
+ )
+ }
+
+ bucket["name.domain.com"] = [:parent, [:classes]]
+
+ ret = nil
+
+ assert_nothing_raised do
+ assert_equal bucket["name.domain.com"],
+ interp.nodesearch("name", "name.domain.com")
+ end
+
+
+ end
end