Issue #884 has been updated by jamtur01.

Target version changed from unplanned to 0.24.0


----------------------------------------
Feature #884: Patch to tidy.rb to add file glob patterns to limit file tidying
http://reductivelabs.com/redmine/issues/show/884

Author: josb
Status: Closed
Priority: Normal
Assigned to: luke
Category: 
Target version: 0.24.0
Keywords: 
Complexity: Medium
Patch: Insufficient
Affected version: 


This patch against 0.23.2 adds a 'patterns' parameter to the tidy type. When 
specified, only files that match one of the glob patterns will be considered 
for tidying. This can be useful to limit tidying to a subset of files in a 
directory, e.g.

<pre>
   # Don't delete the 'default' file
   tidy { "/tftpboot/pxe/pxelinux.cfg":
        age => '1d',
        patterns => [[01-*]],
        recurse => true,
        backup => false;
    }
</pre>

The patch:

<pre>
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -14,6 +14,11 @@ module Puppet
             isnamevar
         end
 
+       newparam(:patterns) do
+            desc "File glob patterns. Restrict the list of files to be tidied 
to
+                 those whose basename matches any of the patterns specifed."
+       end
+
         copyparam(Puppet.type(:file), :backup)
         
         newproperty(:ensure) do
@@ -47,6 +52,14 @@ module Puppet
                     end
                 else
                     @out = []
+                    if @resource[:patterns]
+                        basename = File.basename(@resource[:path])
+                        flags = File::FNM_DOTMATCH | File::FNM_PATHNAME
+                        unless @resource[:patterns].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?
</pre>


----------------------------------------
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://reductivelabs.com/redmine/my/account

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to