diff options
| author | Jacob Helwig <jacob@puppetlabs.com> | 2011-02-01 15:00:35 -0800 |
|---|---|---|
| committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-02-01 15:00:35 -0800 |
| commit | c78d5d1f671167260753fc0ea6b1bbd3212c6f8b (patch) | |
| tree | c5678f680b550213d60113ef2141a59716f6ffbc /lib | |
| parent | 1a78484a0d687914c146456f79aad857c5d243a0 (diff) | |
| parent | 76788f80aab15e5ef6487788132b87ecc6ddd9ac (diff) | |
| download | puppet-c78d5d1f671167260753fc0ea6b1bbd3212c6f8b.tar.gz puppet-c78d5d1f671167260753fc0ea6b1bbd3212c6f8b.tar.xz puppet-c78d5d1f671167260753fc0ea6b1bbd3212c6f8b.zip | |
Merge branch 'issues/2.6.next/5566' into 2.6.next
* issues/2.6.next/5566:
(#5566) Treat source only File checksums as syntax errors when used with content
Rename variable used in File type validation to be more clear
Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types.
Remove order dependency when specifying source and checksum on File type
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/type/file.rb | 15 | ||||
| -rwxr-xr-x | lib/puppet/type/file/checksum.rb | 2 | ||||
| -rwxr-xr-x | lib/puppet/type/file/source.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/util/checksums.rb | 14 |
4 files changed, 25 insertions, 7 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index a91e7a504..c66a53c5e 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -271,17 +271,24 @@ Puppet::Type.newtype(:file) do end CREATORS = [:content, :source, :target] + SOURCE_ONLY_CHECKSUMS = [:none, :ctime, :mtime] validate do - count = 0 + creator_count = 0 CREATORS.each do |param| - count += 1 if self.should(param) + creator_count += 1 if self.should(param) end - count += 1 if @parameters.include?(:source) - self.fail "You cannot specify more than one of #{CREATORS.collect { |p| p.to_s}.join(", ")}" if count > 1 + creator_count += 1 if @parameters.include?(:source) + self.fail "You cannot specify more than one of #{CREATORS.collect { |p| p.to_s}.join(", ")}" if creator_count > 1 self.fail "You cannot specify a remote recursion without a source" if !self[:source] and self[:recurse] == :remote + self.fail "You cannot specify source when using checksum 'none'" if self[:checksum] == :none && !self[:source].nil? + + SOURCE_ONLY_CHECKSUMS.each do |checksum_type| + self.fail "You cannot specify content when using checksum '#{checksum_type}'" if self[:checksum] == checksum_type && !self[:content].nil? + end + self.warning "Possible error: recurselimit is set but not recurse, no recursion will happen" if !self[:recurse] and self[:recurselimit] end diff --git a/lib/puppet/type/file/checksum.rb b/lib/puppet/type/file/checksum.rb index 732460738..5586b1383 100755 --- a/lib/puppet/type/file/checksum.rb +++ b/lib/puppet/type/file/checksum.rb @@ -9,7 +9,7 @@ Puppet::Type.type(:file).newparam(:checksum) do The default checksum parameter, if checksums are enabled, is md5." - newvalues "md5", "md5lite", "timestamp", "mtime", "time", "none" + newvalues "md5", "md5lite", "mtime", "ctime", "none" defaultto :md5 diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index 7d03de2b0..bc464e1c3 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -169,7 +169,6 @@ module Puppet checks.delete(:checksum) resource[:audit] = checks - resource[:checksum] = :md5 unless resource.property(:checksum) end def local? diff --git a/lib/puppet/util/checksums.rb b/lib/puppet/util/checksums.rb index 6fdf14ecf..e129301e6 100644 --- a/lib/puppet/util/checksums.rb +++ b/lib/puppet/util/checksums.rb @@ -68,7 +68,9 @@ module Puppet::Util::Checksums nil end - alias :ctime_stream :mtime_stream + def mtime(content) + "" + end # Calculate a checksum using Digest::SHA1. def sha1(content) @@ -108,6 +110,12 @@ module Puppet::Util::Checksums File.stat(filename).send(:ctime) end + alias :ctime_stream :mtime_stream + + def ctime(content) + "" + end + # Return a "no checksum" def none_file(filename) "" @@ -119,6 +127,10 @@ module Puppet::Util::Checksums "" end + def none(content) + "" + end + private # Perform an incremental checksum on a file. |
