1
require 'puppet/file_serving'
3
# This module is used to pick the appropriate terminus
4
# in file-serving indirections. This is necessary because
5
# the terminus varies based on the URI asked for.
6
module Puppet::FileServing::TerminusSelector
7
PROTOCOL_MAP = {"puppet" => :rest, "file" => :file}
10
# We rely on the request's parsing of the URI.
12
# Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol.
13
return PROTOCOL_MAP["file"] if Puppet::Util.absolute_path?(request.key)
14
return PROTOCOL_MAP["file"] if request.protocol == "file"
16
# We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'apply' or 'puppet'
17
if request.protocol == "puppet" and (request.server or !["puppet","apply"].include?(Puppet.settings[:name]))
18
return PROTOCOL_MAP["puppet"]
21
if request.protocol and PROTOCOL_MAP[request.protocol].nil?
22
raise(ArgumentError, "URI protocol '#{request.protocol}' is not currently supported for file serving")
25
# If we're still here, we're using the file_server or modules.