Sha256: c0b33a253d4c5db2fe694a8463c4beec4f097ddd8498b57b4b5f6a8721993019

Contents?: true

Size: 1.23 KB

Versions: 19

Compression:

Stored size: 1.23 KB

Contents

require 'uri'
require 'puppet/file_serving'
require 'puppet/util'

# 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.
module Puppet::FileServing::IndirectionHooks
  PROTOCOL_MAP = {"puppet" => :rest, "file" => :file}

  # Pick an appropriate terminus based on the protocol.
  def select_terminus(request)
    # We rely on the request's parsing of the URI.

    # Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol.
    return PROTOCOL_MAP["file"] if Puppet::Util.absolute_path?(request.key)
    return PROTOCOL_MAP["file"] if request.protocol == "file"

    # 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'
    if request.protocol == "puppet" and (request.server or !["puppet","apply"].include?(Puppet.settings[:name]))
      return PROTOCOL_MAP["puppet"]
    end

    if request.protocol and PROTOCOL_MAP[request.protocol].nil?
      raise(ArgumentError, "URI protocol '#{request.protocol}' is not currently supported for file serving")
    end

    # If we're still here, we're using the file_server or modules.
    :file_server
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.17 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.16 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.14 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.13 lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.12 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.11 lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.9 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.8 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.6 lib/puppet/file_serving/indirection_hooks.rb