Class: Puppet::Pops::Loaders

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/loaders.rb

Defined Under Namespace

Classes: LoaderError, LoaderModuleData, ModuleResolver

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Loaders

Returns a new instance of Loaders.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet/pops/loaders.rb', line 9

def initialize(environment)
  # The static loader can only be changed after a reboot
  @@static_loader ||= Puppet::Pops::Loader::StaticLoader.new()

  # Create the set of loaders
  # 1. Puppet, loads from the "running" puppet - i.e. bundled functions, types, extension points and extensions
  #    These cannot be cached since a  loaded instance will be bound to its closure scope which holds on to
  #    a compiler and all loaded types. Subsequent request would find remains of the environment that loaded
  #    the content. PUP-4461.
  #
  @puppet_system_loader = create_puppet_system_loader()

  # 2. Environment loader - i.e. what is bound across the environment, may change for each setup
  #    TODO: loaders need to work when also running in an agent doing catalog application. There is no
  #    concept of environment the same way as when running as a master (except when doing apply).
  #    The creation mechanisms should probably differ between the two.
  #
  @private_environment_loader = create_environment_loader(environment)

  # 3. module loaders are set up from the create_environment_loader, they register themselves
end

Instance Attribute Details

#private_environment_loaderObject (readonly)



7
8
9
# File 'lib/puppet/pops/loaders.rb', line 7

def private_environment_loader
  @private_environment_loader
end

#public_environment_loaderObject (readonly)



6
7
8
# File 'lib/puppet/pops/loaders.rb', line 6

def public_environment_loader
  @public_environment_loader
end

#puppet_system_loaderObject (readonly)



5
6
7
# File 'lib/puppet/pops/loaders.rb', line 5

def puppet_system_loader
  @puppet_system_loader
end

#static_loaderObject (readonly)



4
5
6
# File 'lib/puppet/pops/loaders.rb', line 4

def static_loader
  @static_loader
end

Class Method Details

.clearObject

Clears the cached static and puppet_system loaders (to enable testing)



33
34
35
36
# File 'lib/puppet/pops/loaders.rb', line 33

def self.clear
  @@static_loader = nil
  @puppet_system_loader = nil
end

Instance Method Details

#private_loader_for_module(module_name) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/puppet/pops/loaders.rb', line 55

def private_loader_for_module(module_name)
  md = @module_resolver[module_name] || (return nil)
  # Since there is interest in the visibility from the perspective of entities contained in the
  # module, it must be resolved (to provide this visibility).
  # See {#configure_loaders_for_modules}
  unless md.resolved?
    @module_resolver.resolve(md)
  end
  md.private_loader
end

#public_loader_for_module(module_name) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/puppet/pops/loaders.rb', line 46

def public_loader_for_module(module_name)
  md = @module_resolver[module_name] || (return nil)
  # Note, this loader is not resolved until there is interest in the visibility of entities from the
  # perspective of something contained in the module. (Many request may pass through a module loader
  # without it loading anything.
  # See {#private_loader_for_module}, and not in {#configure_loaders_for_modules}
  md.public_loader
end