Module: Puppet::Indirector

Included in:
DataBinding, FileBucket::File, FileServing::Content, FileServing::Metadata, Node, Node::Facts, Resource, Resource::Catalog, Transaction::Report
Defined in:
lib/puppet/indirector.rb,
lib/puppet/indirector/errors.rb

Overview

Manage indirections to termini. They are organized in terms of indirections -

  • e.g., configuration, node, file, certificate – and each indirection has one

or more terminus types defined. The indirection is configured via the indirects method, which will be called by the class extending itself with this module.

Defined Under Namespace

Modules: ClassMethods, Envelope, FactSearch Classes: Code, DirectFileServer, Exec, Face, FileContent, FileMetadata, FileServer, GenericHttp, Hiera, Indirection, JSON, Memory, Msgpack, None, Plain, REST, Request, StoreConfigs, Terminus, ValidationError, Yaml

Constant Summary collapse

BadNameRegexp =

Helper definition for indirections that handle filenames.

Regexp.union(/^\.\./,
%r{[\\/]},
"\0",
/(?i)^[a-z]:/)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure_routes(application_routes) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet/indirector.rb', line 18

def self.configure_routes(application_routes)
  application_routes.each do |indirection_name, termini|
    indirection_name = indirection_name.to_sym
    terminus_name = termini["terminus"]
    cache_name    = termini["cache"]

    Puppet::Indirector::Terminus.terminus_class(indirection_name, terminus_name || cache_name)

    indirection = Puppet::Indirector::Indirection.instance(indirection_name)
    raise _("Indirection %{indirection_name} does not exist") % { indirection_name: indirection_name } unless indirection

    indirection.set_global_setting(:terminus_class, terminus_name) if terminus_name
    indirection.set_global_setting(:cache_class, cache_name) if cache_name
  end
end

Instance Method Details

#indirects(indirection, options = {}) ⇒ Object

Declare that the including class indirects its methods to this terminus. The terminus name must be the name of a Puppet default, not the value – if it’s the value, then it gets evaluated at parse time, which is before the user has had a chance to override it.

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puppet/indirector.rb', line 39

def indirects(indirection, options = {})
  raise(ArgumentError, _("Already handling indirection for %{current}; cannot also handle %{next}") % { current: @indirection.name, next: indirection }) if @indirection

  # populate this class with the various new methods
  extend ClassMethods
  include Puppet::Indirector::Envelope
  include Puppet::Network::FormatSupport

  # record the indirected class name for documentation purposes
  options[:indirected_class] = name

  # instantiate the actual Terminus for that type and this name (:ldap, w/ args :node)
  # & hook the instantiated Terminus into this class (Node: @indirection = terminus)
  @indirection = Puppet::Indirector::Indirection.new(self, indirection, **options)
end