summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-02 07:35:14 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-02 07:35:14 +0000
commit373f1770de9a6f3c741832cc86f0bcdc30a14bce (patch)
treed1ea7eb0edc3e07697bf58138619f6c496bcb554 /lib/puppet
parentcc05e8d97d233e698a5d70e7d5a288a78a942389 (diff)
downloadpuppet-373f1770de9a6f3c741832cc86f0bcdc30a14bce.tar.gz
puppet-373f1770de9a6f3c741832cc86f0bcdc30a14bce.tar.xz
puppet-373f1770de9a6f3c741832cc86f0bcdc30a14bce.zip
Adding sourcematch parameter to file.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2016 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type/pfile.rb26
-rwxr-xr-xlib/puppet/type/pfile/checksum.rb1
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 0bc817494..a9254e5ea 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -190,6 +190,14 @@ module Puppet
newvalues(:true, :false)
end
+
+ newparam(:sourcematch) do
+ desc "Whether to copy all valid sources, or just the first one."
+
+ defaultto :first
+
+ newvalues(:first, :all)
+ end
attr_accessor :bucket
@@ -612,6 +620,7 @@ module Puppet
args.each { |var,value|
next if var == :path
next if var == :name
+
# behave idempotently
unless child.should(var) == value
child[var] = value
@@ -829,6 +838,8 @@ module Puppet
ignore = self[:ignore]
+ result = []
+ found = []
@states[:source].should.each do |source|
sourceobj, path = uri2obj(source)
@@ -844,19 +855,30 @@ module Puppet
end
# Now create a new child for every file returned in the list.
- return desc.split("\n").collect { |line|
+ result += desc.split("\n").collect { |line|
file, type = line.split("\t")
next if file == "/" # skip the listing object
name = file.sub(/^\//, '')
+
+ # This makes sure that the first source *always* wins
+ # for conflicting files.
+ next if found.include?(name)
+
args = {:source => source + file}
if type == file
args[:recurse] = nil
end
+ found << name
+
self.newchild(name, false, args)
}.reject {|c| c.nil? }
+
+ if self[:sourcematch] == :first
+ return result
+ end
end
- return []
+ return result
end
# Set the checksum, from another state. There are multiple states that
diff --git a/lib/puppet/type/pfile/checksum.rb b/lib/puppet/type/pfile/checksum.rb
index c4ae6e8c3..af3161b9f 100755
--- a/lib/puppet/type/pfile/checksum.rb
+++ b/lib/puppet/type/pfile/checksum.rb
@@ -314,7 +314,6 @@ module Puppet
# end
if @is == sum
- info "Sums are already equal"
return false
end