Class: Puppet::FileServing::Mount::File
- Inherits:
-
Puppet::FileServing::Mount
- Object
- Network::AuthStore
- Puppet::FileServing::Mount
- Puppet::FileServing::Mount::File
- Extended by:
- Util::Cacher
- Defined in:
- lib/puppet/file_serving/mount/file.rb
Instance Attribute Summary
Attributes included from Util::Cacher::Expirer
Attributes inherited from Puppet::FileServing::Mount
Instance Method Summary collapse
- #complete_path(relative_path, node) ⇒ Object
-
#find(short_file, request) ⇒ Object
Return an instance of the appropriate class.
-
#path(node = nil) ⇒ Object
Return the path as appropriate, expanding as necessary.
-
#path=(path) ⇒ Object
Set the path.
- #search(path, request) ⇒ Object
-
#validate ⇒ Object
Verify our configuration is valid.
Methods included from Util::Cacher
Methods included from Util::Cacher::Expirer
#dependent_data_expired?, #expire
Methods inherited from Puppet::FileServing::Mount
Methods included from Util::Logging
Methods inherited from Network::AuthStore
#allow, #allowed?, #deny, #empty?, #globalallow?, #initialize, #interpolate, #reset_interpolation, #to_s
Constructor Details
This class inherits a constructor from Puppet::FileServing::Mount
Instance Method Details
#complete_path(relative_path, node) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puppet/file_serving/mount/file.rb', line 18 def complete_path(relative_path, node) full_path = path(node) raise ArgumentError.new("Mounts without paths are not usable") unless full_path # If there's no relative path name, then we're serving the mount itself. return full_path unless relative_path file = ::File.join(full_path, relative_path) if !(FileTest.exist?(file) or FileTest.symlink?(file)) Puppet.info("File does not exist or is not accessible: #{file}") return nil end file end |
#find(short_file, request) ⇒ Object
Return an instance of the appropriate class.
37 38 39 |
# File 'lib/puppet/file_serving/mount/file.rb', line 37 def find(short_file, request) complete_path(short_file, request.node) end |
#path(node = nil) ⇒ Object
Return the path as appropriate, expanding as necessary.
42 43 44 45 46 47 48 |
# File 'lib/puppet/file_serving/mount/file.rb', line 42 def path(node = nil) if return (@path, node) else return @path end end |
#path=(path) ⇒ Object
Set the path.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/puppet/file_serving/mount/file.rb', line 51 def path=(path) # FIXME: For now, just don't validate paths with replacement # patterns in them. if path =~ /%./ # Mark that we're expandable. @expandable = true else raise ArgumentError, "#{path} does not exist or is not a directory" unless FileTest.directory?(path) raise ArgumentError, "#{path} is not readable" unless FileTest.readable?(path) @expandable = false end @path = path end |
#search(path, request) ⇒ Object
65 66 67 68 |
# File 'lib/puppet/file_serving/mount/file.rb', line 65 def search(path, request) return nil unless path = complete_path(path, request.node) [path] end |
#validate ⇒ Object
Verify our configuration is valid. This should really check to make sure at least someone will be allowed, but, eh.
72 73 74 |
# File 'lib/puppet/file_serving/mount/file.rb', line 72 def validate raise ArgumentError.new("Mounts without paths are not usable") if @path.nil? end |