Module: Puppet::FileServing::TerminusSelector Private

Included in:
Indirector::FileContent::Selector, Indirector::FileMetadata::Selector
Defined in:
lib/puppet/file_serving/terminus_selector.rb

Overview

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

This module is used to pick the appropriate terminus in file-serving indirections. This is necessary because the terminus varies based on the URI asked for.

Instance Method Summary collapse

Instance Method Details

#select(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.


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/puppet/file_serving/terminus_selector.rb', line 7

def select(request)
  # We rely on the request's parsing of the URI.

  case request.protocol
  when "file"
    :file
  when "puppet"
    if request.server
      :rest
    else
      Puppet[:default_file_terminus]
    end
  when "http","https"
    :http
  when nil
    if Puppet::Util.absolute_path?(request.key)
      :file
    else
      :file_server
    end
  else
    raise ArgumentError, _("URI protocol '%{protocol}' is not currently supported for file serving") % { protocol: request.protocol }
  end
end