diff options
| author | Andrew Shafer <andrew@reductivelabs.com> | 2008-07-04 08:24:14 -0600 |
|---|---|---|
| committer | Andrew Shafer <andrew@reductivelabs.com> | 2008-07-04 08:24:14 -0600 |
| commit | 8865bdf112b33660a3e41b03f57d2575809e3cb4 (patch) | |
| tree | 48f0b36953430a5073c4f0588df148ef79d84ff1 | |
| parent | 7a6ae299621a16fa7fd8ab0fbd2c05fe723cffa4 (diff) | |
| download | puppet-8865bdf112b33660a3e41b03f57d2575809e3cb4.tar.gz puppet-8865bdf112b33660a3e41b03f57d2575809e3cb4.tar.xz puppet-8865bdf112b33660a3e41b03f57d2575809e3cb4.zip | |
file object creation should fail if source is not present
removed described? logic from insync? in ensure.rb and source.rb
raise in source#retrieve if the source is not found
| -rwxr-xr-x | lib/puppet/type/file/ensure.rb | 5 | ||||
| -rwxr-xr-x | lib/puppet/type/file/source.rb | 20 | ||||
| -rwxr-xr-x | spec/unit/type/file.rb | 12 |
3 files changed, 19 insertions, 18 deletions
diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 0d2171216..a9ddc2dba 100755 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -138,11 +138,6 @@ module Puppet # We have to treat :present specially, because it works with any # type of file. def insync?(currentvalue) - if property = @resource.property(:source) and ! property.described? - warning "No specified sources exist" - return true - end - if self.should == :present if currentvalue.nil? or currentvalue == :absent return false diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index 1b0dd3141..f2704abb6 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -135,18 +135,8 @@ module Puppet return args end - # Have we successfully described the remote source? - def described? - ! @stats.nil? and ! @stats[:type].nil? #and @is != :notdescribed - end - # Use the info we get from describe() to check if we're in sync. def insync?(currentvalue) - unless described? - warning "No specified sources exist" - return true - end - if currentvalue == :nocopy return true end @@ -180,7 +170,11 @@ module Puppet def pinparams [:mode, :type, :owner, :group] end - + + def found? + ! (@stats.nil? or @stats[:type].nil?) + end + # This basically calls describe() on our file, and then sets all # of the local states appropriately. If the remote file is a normal # file then we set it to copy; if it's a directory, then we just mark @@ -202,8 +196,8 @@ module Puppet } end - if @stats.nil? or @stats[:type].nil? - return nil # :notdescribed + if !found? + raise Puppet::Error, "No specified source was found from" + @should.inject("") { |s, source| s + " #{source},"}.gsub(/,$/,"") end case @stats[:type] diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index 12b806d88..f0ae70cd0 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -31,6 +31,18 @@ describe Puppet::Type.type(:file) do end end + describe "when specifying a source" do + before do + @file[:source] = "/bar" + end + + it "should raise if source doesn't exist" do + @file.property(:source).expects(:found?).returns(false) + lambda { @file.retrieve }.should raise_error(Puppet::Error) + end + + end + describe "when retrieving remote files" do before do @filesource = Puppet::Type::File::FileSource.new |
