blob: ad779add152c564362b3cc139554ef644f3b2475 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# The Puppet Extensions Module.
#
# Submodules of this module should be named after the publisher (e.g. 'user' part of a Puppet Module name).
# The submodule {Puppetx::Puppet} contains the puppet extension points.
#
# This module also contains constants that are used when defining extensions.
#
# @api public
#
module Puppetx
# The lookup **key** for the multibind containing syntax checkers used to syntax check embedded string in non
# puppet DSL syntax.
# @api public
SYNTAX_CHECKERS = 'puppetx::puppet::syntaxcheckers'
# The lookup **type** for the multibind containing syntax checkers used to syntax check embedded string in non
# puppet DSL syntax.
# @api public
SYNTAX_CHECKERS_TYPE = 'Puppetx::Puppet::SyntaxChecker'
# The lookup **key** for the multibind containing a map from scheme name to scheme handler class for bindings schemes.
# @api public
BINDINGS_SCHEMES = 'puppetx::puppet::bindings::schemes'
# The lookup **type** for the multibind containing a map from scheme name to scheme handler class for bindings schemes.
# @api public
BINDINGS_SCHEMES_TYPE = 'Puppetx::Puppet::BindingsSchemeHandler'
# This module is the name space for extension points
# @api public
module Puppet
if ::Puppet[:binder] || ::Puppet[:parser] == 'future'
# Extension-points are registered here:
# - If in a Ruby submodule it is best to create it here
# - The class does not have to be required; it will be auto required when the binder
# needs it.
# - If the extension is a multibind, it can be registered here; either with a required
# class or a class reference in string form.
# Register extension points
# -------------------------
system_bindings = ::Puppet::Pops::Binder::SystemBindings
extensions = system_bindings.extensions()
extensions.multibind(SYNTAX_CHECKERS).name(SYNTAX_CHECKERS).hash_of(SYNTAX_CHECKERS_TYPE)
extensions.multibind(BINDINGS_SCHEMES).name(BINDINGS_SCHEMES).hash_of(BINDINGS_SCHEMES_TYPE)
# Register injector boot bindings
# -------------------------------
boot_bindings = system_bindings.injector_boot_bindings()
# Register the default bindings scheme handlers
require 'puppetx/puppet/bindings_scheme_handler'
{ 'module' => 'ModuleScheme',
'confdir' => 'ConfdirScheme',
}.each do |scheme, class_name|
boot_bindings.bind.name(scheme).instance_of(BINDINGS_SCHEMES_TYPE).in_multibind(BINDINGS_SCHEMES).
to_instance("Puppet::Pops::Binder::SchemeHandler::#{class_name}")
end
end
end
# Module with implementations of various extensions
# @api public
module Puppetlabs
# Default extensions delivered in Puppet Core are included here
# @api public
module SyntaxCheckers
if ::Puppet[:binder] || ::Puppet[:parser] == 'future'
# Classes in this name-space are lazily loaded as they may be overridden and/or never used
# (Lazy loading is done by binding to the name of a class instead of a Class instance).
# Register extensions
# -------------------
system_bindings = ::Puppet::Pops::Binder::SystemBindings
bindings = system_bindings.default_bindings()
bindings.bind do
name('json')
instance_of(SYNTAX_CHECKERS_TYPE)
in_multibind(SYNTAX_CHECKERS)
to_instance('Puppetx::Puppetlabs::SyntaxCheckers::Json')
end
end
end
end
end
|