Class: Puppet::FileServing::Mount::File Private

Inherits:
Puppet::FileServing::Mount show all
Defined in:
lib/puppet/file_serving/mount/file.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary

Attributes inherited from Puppet::FileServing::Mount

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Puppet::FileServing::Mount

#initialize, #to_s

Methods included from Util::Logging

#clear_deprecation_warnings, #debug, #deprecation_warning, #format_backtrace, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception, #puppet_deprecation_warning, #send_log, setup_facter_logging!, #warn_once

Methods inherited from Network::AuthStore

#allow, #allow_ip, #allowed?, #deny, #deny_ip, #empty?, #globalallow?, #initialize, #interpolate, #reset_interpolation, #to_s

Constructor Details

This class inherits a constructor from Puppet::FileServing::Mount

Class Method Details

.localmapObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



4
5
6
7
8
9
10
11
12
13
# File 'lib/puppet/file_serving/mount/file.rb', line 4

def self.localmap
  @localmap ||= {
    "h" => Puppet.runtime[:facter].value("hostname"),
    "H" => [
             Puppet.runtime[:facter].value("hostname"),
             Puppet.runtime[:facter].value("domain")
           ].join("."),
    "d" => Puppet.runtime[:facter].value("domain")
  }
end

Instance Method Details

#complete_path(relative_path, node) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

API:

  • private



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/puppet/file_serving/mount/file.rb', line 15

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 !(Puppet::FileSystem.exist?(file) or Puppet::FileSystem.symlink?(file))
    Puppet.info(_("File does not exist or is not accessible: %{file}") % { file: file })
    return nil
  end

  file
end

#find(short_file, request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return an instance of the appropriate class.

API:

  • private



34
35
36
# File 'lib/puppet/file_serving/mount/file.rb', line 34

def find(short_file, request)
  complete_path(short_file, request.node)
end

#path(node = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the path as appropriate, expanding as necessary.

API:

  • private



39
40
41
42
43
44
45
# File 'lib/puppet/file_serving/mount/file.rb', line 39

def path(node = nil)
  if expandable?
    return expand(@path, node)
  else
    return @path
  end
end

#path=(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set the path.

API:

  • private



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/puppet/file_serving/mount/file.rb', line 48

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") % { path: path } unless FileTest.directory?(path)
    raise ArgumentError, _("%{path} is not readable") % { path: path } unless FileTest.readable?(path)
    @expandable = false
  end
  @path = path
end

#search(path, request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



62
63
64
65
66
# File 'lib/puppet/file_serving/mount/file.rb', line 62

def search(path, request)
  path = complete_path(path, request.node)
  return nil unless path
  [path]
end

#validateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Verify our configuration is valid. This should really check to make sure at least someone will be allowed, but, eh.

Raises:

API:

  • private



70
71
72
# File 'lib/puppet/file_serving/mount/file.rb', line 70

def validate
  raise ArgumentError.new(_("Mounts without paths are not usable")) if @path.nil?
end