Sha256: 89cc91a4922b6922deec3a8cea79b211550b6393389e33c0b65f8a49ffea2f87

Contents?: true

Size: 1.29 KB

Versions: 18

Compression:

Stored size: 1.29 KB

Contents

#
#  Created by Luke Kanies on 2007-10-18.
#  Copyright (c) 2007. All rights reserved.

require 'uri'
require 'puppet/file_serving'

# 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 request.key =~ /^#{::File::SEPARATOR}/
    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

18 entries across 18 versions & 1 rubygems

Version Path
puppet-2.6.16 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.15 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.14 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.13 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.12 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.11 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.10 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.3 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.7.1 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.9 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.8 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.7 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.6 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.5 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.4 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.3 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.2 lib/puppet/file_serving/indirection_hooks.rb
puppet-2.6.1 lib/puppet/file_serving/indirection_hooks.rb