Sha256: f887007a23a5a79dd7d4a7b011a32397171249fb5aea5de557cdd43a50441380

Contents?: true

Size: 1.51 KB

Versions: 164

Compression:

Stored size: 1.51 KB

Contents

require 'puppet/file_serving/configuration'
require 'puppet/file_serving/fileset'
require 'puppet/file_serving/terminus_helper'
require 'puppet/indirector/terminus'

# Look files up using the file server.
class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus
  include Puppet::FileServing::TerminusHelper

  # Is the client authorized to perform this action?
  def authorized?(request)
    return false unless [:find, :search].include?(request.method)

    mount, file_path = configuration.split_path(request)

    # If we're not serving this mount, then access is denied.
    return false unless mount
    mount.allowed?(request.node, request.ip)
  end

  # Find our key using the fileserver.
  def find(request)
    mount, relative_path = configuration.split_path(request)

    return nil unless mount

    # The mount checks to see if the file exists, and returns nil
    # if not.
    return nil unless path = mount.find(relative_path, request)
    path2instance(request, path)
  end

  # Search for files.  This returns an array rather than a single
  # file.
  def search(request)
    mount, relative_path = configuration.split_path(request)

    unless mount and paths = mount.search(relative_path, request)
      Puppet.info "Could not find filesystem info for file '#{request.key}' in environment #{request.environment}"
      return nil
    end
    path2instances(request, *paths)
  end

  private

  # Our fileserver configuration, if needed.
  def configuration
    Puppet::FileServing::Configuration.configuration
  end
end

Version data entries

164 entries across 164 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/indirector/file_server.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/indirector/file_server.rb
puppet-4.10.12 lib/puppet/indirector/file_server.rb
puppet-4.10.12-x86-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.12-x64-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.12-universal-darwin lib/puppet/indirector/file_server.rb
puppet-4.10.11 lib/puppet/indirector/file_server.rb
puppet-4.10.11-x86-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.11-x64-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.11-universal-darwin lib/puppet/indirector/file_server.rb
puppet-4.10.10 lib/puppet/indirector/file_server.rb
puppet-4.10.10-x86-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.10-x64-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.10-universal-darwin lib/puppet/indirector/file_server.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/indirector/file_server.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/indirector/file_server.rb
puppet-4.10.9 lib/puppet/indirector/file_server.rb
puppet-4.10.9-x86-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.9-x64-mingw32 lib/puppet/indirector/file_server.rb
puppet-4.10.9-universal-darwin lib/puppet/indirector/file_server.rb