puppet-resource_api 1.8.8 → 1.8.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d14e2bf3972db6032efa89ba6051d141c97f0e68a8977f6f667650051a06bdf4
4
- data.tar.gz: 4a1609c8cf63542580ad8145ccaa971991b354266496b8f1067a91bf141b66af
3
+ metadata.gz: d66c960b7ed4b6ed6123bdf2c8cc158320354f32fb15499b09b92a8a3942d36d
4
+ data.tar.gz: 1ba82297b72a4df466c2084feaeb02ed6e883b19d3ee6c913581b5edecd2ca69
5
5
  SHA512:
6
- metadata.gz: 88e11a56b4494310be4e5912f9e48f0cb845bcc693f8e16888704db464e3e989c051afe2aece82ec393b3b1237eed002606a8c1600f396b42a54294669e14447
7
- data.tar.gz: cf6597f4ef293e46ae1791b693a344dc7e7624cec153a86983c6199db311280a706a5b3efae2aa30739e2631e107ff44d3ba493ca6226f24246ae1e1f7a086b8
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
- @autoloader ||= Puppet::Util::Autoload.new(self, 'puppet/transport/schema')
48
- @autoloader.loadall(current_environment)
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
- env = current_environment
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
@@ -1,5 +1,5 @@
1
1
  module Puppet
2
2
  module ResourceApi
3
- VERSION = '1.8.8'.freeze
3
+ VERSION = '1.8.9'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-resource_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.8
4
+ version: 1.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Schmitt