diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-11 15:30:19 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-11 15:30:19 +0000 |
| commit | 4d750418d00bdd39118493003d60481a35212ed1 (patch) | |
| tree | 4b2e74ff66e9a0f5f2a69529986595c2dcccc95f | |
| parent | 201aa023dd279d2d968a97732db11a1933665562 (diff) | |
| download | puppet-4d750418d00bdd39118493003d60481a35212ed1.tar.gz puppet-4d750418d00bdd39118493003d60481a35212ed1.tar.xz puppet-4d750418d00bdd39118493003d60481a35212ed1.zip | |
Adding a "tag" metaparam
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1099 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | lib/puppet/type.rb | 23 | ||||
| -rw-r--r-- | test/tagging/tagging.rb | 33 |
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 8ce39ce29..afea4dfa6 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -2229,6 +2229,29 @@ class Type < Puppet::Element end end end + + newmetaparam(:tag) do + desc "Add the specified tags to the associated element. While all elements + are automatically tagged with as much information as possible + (e.g., each class and component containing the element), it can + be useful to add your own tags to a given element. + + Tags are currently useful for things like applying a subset of a + host's configuration: + + puppetd -v --tag mytag --onetime + + This way, when you're testing a configuration you can run just the + portion you're testing." + + munge do |tags| + tags = [tags] unless tags.is_a? Array + + tags.each do |tag| + @parent.tag(tag) + end + end + end end # Puppet::Type end diff --git a/test/tagging/tagging.rb b/test/tagging/tagging.rb index 312016792..434ef6e69 100644 --- a/test/tagging/tagging.rb +++ b/test/tagging/tagging.rb @@ -141,6 +141,39 @@ class TestTagging < Test::Unit::TestCase File.unlink(a) end + + def test_metaparamtag + path = tempfile() + + start = %w{some tags} + tags = %w{a list of tags} + + obj = nil + assert_nothing_raised do + obj = Puppet.type(:file).create( + :path => path, + :ensure => "file", + :tag => start + ) + end + + + assert(obj, "Did not make object") + + start.each do |tag| + assert(obj.tagged?(tag), "Object was not tagged with %s" % tag) + end + + tags.each do |tag| + assert_nothing_raised { + obj[:tag] = tag + } + end + + tags.each do |tag| + assert(obj.tagged?(tag), "Object was not tagged with %s" % tag) + end + end end # $Id$ |
