summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-23 05:19:52 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-23 05:19:52 +0000
commit85b19c4815c4e605bcfa561298786ca3c1f68de0 (patch)
treeca334fa7064b7f4de660359da06e432f006c1708
parent311aba94792c2984d2944c9ac99a4ff5d79db697 (diff)
downloadpuppet-85b19c4815c4e605bcfa561298786ca3c1f68de0.tar.gz
puppet-85b19c4815c4e605bcfa561298786ca3c1f68de0.tar.xz
puppet-85b19c4815c4e605bcfa561298786ca3c1f68de0.zip
Fixing #349. Doing some hackery so defined types can now (again) be used as dependencies.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1966 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/metatype/metaparams.rb16
-rw-r--r--test/data/snippets/componentrequire.pp8
-rwxr-xr-xtest/language/snippets.rb7
-rwxr-xr-xtest/other/relationships.rb1
4 files changed, 25 insertions, 7 deletions
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb
index c9d3426ff..c9c3a694d 100644
--- a/lib/puppet/metatype/metaparams.rb
+++ b/lib/puppet/metatype/metaparams.rb
@@ -265,13 +265,17 @@ class Puppet::Type
# to an object...
tname, name = value
object = nil
- unless type = Puppet::Type.type(tname)
- self.fail "Could not find type %s" % tname.inspect
- end
- unless object = type[name]
- self.fail "Could not retrieve object '%s' of type '%s'" %
- [name,type]
+ if type = Puppet::Type.type(tname)
+ unless object = type[name]
+ self.fail "Could not retrieve object '%s' of type '%s'" %
+ [name,type]
+ end
+ else # try to treat it as a component
+ unless object = Puppet::Type::Component["#{tname}[#{name}]"]
+ self.fail "Could not find object %s[%s]" % [tname, name]
+ end
end
+
self.debug("subscribes to %s" % [object])
# Are we requiring them, or vice versa? See the builddepends
diff --git a/test/data/snippets/componentrequire.pp b/test/data/snippets/componentrequire.pp
new file mode 100644
index 000000000..a61d2050c
--- /dev/null
+++ b/test/data/snippets/componentrequire.pp
@@ -0,0 +1,8 @@
+define testfile($mode) {
+ file { $name: mode => $mode, ensure => present }
+}
+
+testfile { "/tmp/testing_component_requires2": mode => 755 }
+
+file { "/tmp/testing_component_requires1": mode => 755, ensure => present,
+ require => Testfile["/tmp/testing_component_requires2"] }
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index ccf8a3576..c0175301d 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -439,6 +439,13 @@ class TestSnippets < Test::Unit::TestCase
"Did not collect file #{num}")
end
end
+
+ def snippet_componentrequire
+ %w{1 2}.each do |num|
+ assert(FileTest.exists?("/tmp/testing_component_requires#{num}"),
+ "#{num} does not exist")
+ end
+ end
def disabled_snippet_dirchmod
dirs = %w{a b}.collect { |letter|
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index 7b321d821..45f6efc7a 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -205,7 +205,6 @@ class TestRelationships < Test::Unit::TestCase
file2[:notify] = file1
assert(file1.requires?(file2), "requires? failed to catch :notify relationship")
end
-
end
# $Id$