puppet-resource_api 1.8.8 → 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/puppet/resource_api/transport.rb +23 -24
- data/lib/puppet/resource_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d66c960b7ed4b6ed6123bdf2c8cc158320354f32fb15499b09b92a8a3942d36d
|
4
|
+
data.tar.gz: 1ba82297b72a4df466c2084feaeb02ed6e883b19d3ee6c913581b5edecd2ca69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b22b37590ff1ac73fdf22d5d0012cd8ac6b46a0e2541ba4b3096a6ede49c12bdaa37e895746194cc1257744dec6403f6428610f5e4b29742fe624f3c505ff211
|
7
|
+
data.tar.gz: 2f44e9690a905edd1eafaad645f62c82bfe035c7f4f9ace31620b47d56d2eb963cf117edb4652f8b3c0feecea98e8f7cf13ae90993c1d7b291d8343b32741924
|
@@ -8,6 +8,11 @@ module Puppet::ResourceApi::Transport
|
|
8
8
|
raise Puppet::DevError, 'requires `:desc`' unless schema.key? :desc
|
9
9
|
raise Puppet::DevError, 'requires `:connection_info`' unless schema.key? :connection_info
|
10
10
|
raise Puppet::DevError, '`:connection_info` must be a hash, not `%{other_type}`' % { other_type: schema[:connection_info].class } unless schema[:connection_info].is_a?(Hash)
|
11
|
+
if schema[:connection_info_order].nil?
|
12
|
+
schema[:connection_info_order] = schema[:connection_info].keys
|
13
|
+
else
|
14
|
+
raise Puppet::DevError, '`:connection_info_order` must be an array, not `%{other_type}`' % { other_type: schema[:connection_info_order].class } unless schema[:connection_info_order].is_a?(Array)
|
15
|
+
end
|
11
16
|
|
12
17
|
unless transports[schema[:name]].nil?
|
13
18
|
raise Puppet::DevError, 'Transport `%{name}` is already registered for `%{environment}`' % {
|
@@ -21,6 +26,8 @@ module Puppet::ResourceApi::Transport
|
|
21
26
|
|
22
27
|
# retrieve a Hash of transport schemas, keyed by their name.
|
23
28
|
# Only already loaded transports are returned.
|
29
|
+
# use Puppet::Util::Autoload.new(self, 'puppet/transport/schema').loadall(current_environment) to load all transport schemas
|
30
|
+
# note that loadall uses `require` and thus does not re-load changed files, nor does it re-populate the internal cache
|
24
31
|
def list
|
25
32
|
Marshal.load(Marshal.dump(transports))
|
26
33
|
end
|
@@ -39,13 +46,25 @@ module Puppet::ResourceApi::Transport
|
|
39
46
|
end
|
40
47
|
module_function :list_all_transports # rubocop:disable Style/AccessModifierDeclarations
|
41
48
|
|
42
|
-
# Loads all schemas using the Puppet Autoloader.
|
49
|
+
# Loads all schemas using the Puppet Autoloader. This method is clearing the cache and forcing `Kernel.load`, so that the cache is up-to-date.
|
43
50
|
def self.load_all_schemas
|
44
51
|
require 'puppet'
|
45
52
|
require 'puppet/settings'
|
46
53
|
require 'puppet/util/autoload'
|
47
|
-
|
48
|
-
|
54
|
+
|
55
|
+
# Since we're force-loading all schemas below, we can replace the cache here completely
|
56
|
+
@transports = {}
|
57
|
+
|
58
|
+
loader = Puppet::Util::Autoload
|
59
|
+
# from puppetlabs/puppet:lib/puppet/util/autoload.rb
|
60
|
+
# Puppet::Util::Autoload.loadall('puppet/transport/schema', current_environment)
|
61
|
+
path = 'puppet/transport/schema'
|
62
|
+
env = current_environment
|
63
|
+
# Load every instance of everything we can find.
|
64
|
+
loader.files_to_load(path, env).each do |file|
|
65
|
+
name = file.chomp('.rb')
|
66
|
+
loader.load_file(name, env)
|
67
|
+
end
|
49
68
|
end
|
50
69
|
private_class_method :load_all_schemas
|
51
70
|
|
@@ -108,12 +127,7 @@ module Puppet::ResourceApi::Transport
|
|
108
127
|
private_class_method :wrap_sensitive
|
109
128
|
|
110
129
|
def self.transports
|
111
|
-
|
112
|
-
if env
|
113
|
-
ObjectIdCacheAdapter.adapt(env).retrieve(:rsapi_transport_cache)
|
114
|
-
else
|
115
|
-
@transports_default ||= {}
|
116
|
-
end
|
130
|
+
@transports ||= {}
|
117
131
|
end
|
118
132
|
private_class_method :transports
|
119
133
|
|
@@ -159,19 +173,4 @@ module Puppet::ResourceApi::Transport
|
|
159
173
|
nil
|
160
174
|
end
|
161
175
|
private_class_method :clean_bolt_attributes
|
162
|
-
|
163
|
-
# copy from https://github.com/puppetlabs/puppet/blob/8cae8a17dbac08d2db0238d5bce2f1e4d1898d65/lib/puppet/pops/adapters.rb#L6-L17
|
164
|
-
# to keep backwards compatibility with puppet4 and 5, which don't have this yet.
|
165
|
-
class ObjectIdCacheAdapter < Puppet::Pops::Adaptable::Adapter
|
166
|
-
attr_accessor :cache
|
167
|
-
|
168
|
-
def initialize
|
169
|
-
@cache = {}
|
170
|
-
end
|
171
|
-
|
172
|
-
# Retrieves a mutable hash with all stored values
|
173
|
-
def retrieve(obj)
|
174
|
-
@cache[obj.__id__] ||= {}
|
175
|
-
end
|
176
|
-
end
|
177
176
|
end
|