summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-11 00:36:44 -0600
committerLuke Kanies <luke@madstop.com>2007-12-11 00:36:44 -0600
commit02b64ab3bc9ce29fd5d482a78781c341ba791ba6 (patch)
tree0f3898968b3cece4da51b1d18645c2dd90a265f1 /lib/puppet
parent584127c71352dfa1b13eb4e948a93d5078eff73f (diff)
downloadpuppet-02b64ab3bc9ce29fd5d482a78781c341ba791ba6.tar.gz
puppet-02b64ab3bc9ce29fd5d482a78781c341ba791ba6.tar.xz
puppet-02b64ab3bc9ce29fd5d482a78781c341ba791ba6.zip
Applying patch by josb in #884 to provide pattern
matching in the tidy type.
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/type/tidy.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index 27456f7d6..dacf037ac 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -1,7 +1,3 @@
-
-require 'etc'
-require 'puppet/type/pfile'
-
module Puppet
newtype(:tidy, Puppet.type(:file)) do
@doc = "Remove unwanted files based on specific criteria. Multiple
@@ -14,11 +10,17 @@ module Puppet
isnamevar
end
+ newparam(:matches) do
+ desc "One or more file glob patterns, which restrict the list of
+ files to be tidied to those whose basenames match at least one
+ of the patterns specified. Multiple patterns can be specified
+ using an array."
+ end
+
copyparam(Puppet.type(:file), :backup)
newproperty(:ensure) do
desc "An internal attribute used to determine which files should be removed."
- require 'etc'
@nodoc = true
@@ -47,6 +49,14 @@ module Puppet
end
else
@out = []
+ if @resource[:matches]
+ basename = File.basename(@resource[:path])
+ flags = File::FNM_DOTMATCH | File::FNM_PATHNAME
+ unless @resource[:matches].any? {|pattern| File.fnmatch(pattern, basename, flags) }
+ self.debug "No patterns specified match basename, skipping"
+ return true
+ end
+ end
TATTRS.each do |param|
if property = @resource.property(param)
self.debug "No is value for %s", [param] if is[property].nil?