puppet-resource_api 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -4
- data/CHANGELOG.md +22 -0
- data/contrib/README.md +7 -0
- data/contrib/pre-commit +23 -0
- data/lib/puppet/resource_api.rb +60 -27
- data/lib/puppet/resource_api/base_context.rb +11 -9
- data/lib/puppet/resource_api/glue.rb +1 -1
- data/lib/puppet/resource_api/io_context.rb +2 -2
- data/lib/puppet/resource_api/simple_provider.rb +4 -1
- data/lib/puppet/resource_api/type_definition.rb +28 -0
- data/lib/puppet/resource_api/version.rb +1 -1
- data/misc/ANNOUNCEMENT_TEMPLATE.md +41 -0
- data/puppet-resource_api.gemspec +2 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd035e8b155f1bf4307be10cd13021a16f91aae8d8ef3bfd652f5a77a67a3556
|
4
|
+
data.tar.gz: 43d002ab24ab5e320357684b297c8e01f6f79f661f7ed062410619ed37146a94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c316e50d658c0c65501defdf61392f7d2ee586e0ebf4b1b78f9a1da98b3a289d65b6265f2ba68a8fdf3d23f2ab612591c280a7ca25846d1db66d6e530228ab9f
|
7
|
+
data.tar.gz: e4f60efe74b30a0770e07acb9e98024f0bcbaf6ea3d5bc5214b59835510c8c0edd757c3da50e88ab7bf65947c63a9fb9f0ea97315ae3051fb063af6ecf18f44f
|
data/.travis.yml
CHANGED
@@ -12,10 +12,18 @@ matrix:
|
|
12
12
|
include:
|
13
13
|
- rvm: 2.4.3
|
14
14
|
env: PUPPET_GEM_VERSION='~> 5' # 5.5
|
15
|
-
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
- env: RVM="jruby-1.7.26" PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug"
|
16
|
+
before_cache: pushd ~/.rvm && rm -rf archives rubies/ruby-2.2.7 rubies/ruby-2.3.4 && popd
|
17
|
+
cache:
|
18
|
+
bundler: true
|
19
|
+
directories: ~/.rvm
|
20
|
+
before_install: rvm use jruby-1.7.26 --install --binary --fuzzy
|
21
|
+
- env: RVM="jruby-9.1.9.0" PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug"
|
22
|
+
before_cache: pushd ~/.rvm && rm -rf archives rubies/ruby-2.2.7 rubies/ruby-2.3.4 && popd
|
23
|
+
cache:
|
24
|
+
bundler: true
|
25
|
+
directories: ~/.rvm
|
26
|
+
before_install: rvm use jruby-9.1.9.0 --install --binary --fuzzy
|
19
27
|
- rvm: 2.4.3
|
20
28
|
env: CHECK=rubocop
|
21
29
|
- rvm: 2.4.3
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,28 @@
|
|
3
3
|
All significant changes to this repo will be summarized in this file.
|
4
4
|
|
5
5
|
|
6
|
+
## [v1.2.0](https://github.com/puppetlabs/puppet-resource_api/tree/v1.2.0) (2018-05-08)
|
7
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.1.0...v1.2.0)
|
8
|
+
|
9
|
+
**Implemented enhancements:**
|
10
|
+
|
11
|
+
- \(PDK-924\) Throw when SimpleProvider is used with unensurable type [\#73](https://github.com/puppetlabs/puppet-resource_api/pull/73) ([da-ar](https://github.com/da-ar))
|
12
|
+
- \(PDK-955\) Provide access to the type definition from the provider [\#72](https://github.com/puppetlabs/puppet-resource_api/pull/72) ([da-ar](https://github.com/da-ar))
|
13
|
+
|
14
|
+
**Fixed bugs:**
|
15
|
+
|
16
|
+
- \(PDK-946\) Passes ensure values to puppet as symbols. [\#74](https://github.com/puppetlabs/puppet-resource_api/pull/74) ([da-ar](https://github.com/da-ar))
|
17
|
+
- \(PDK-929\) Ignore validation for absent resources [\#69](https://github.com/puppetlabs/puppet-resource_api/pull/69) ([da-ar](https://github.com/da-ar))
|
18
|
+
- Make ruby files individually loadable without puppet [\#65](https://github.com/puppetlabs/puppet-resource_api/pull/65) ([DavidS](https://github.com/DavidS))
|
19
|
+
- \(PDK-526\) fix test for git [\#63](https://github.com/puppetlabs/puppet-resource_api/pull/63) ([DavidS](https://github.com/DavidS))
|
20
|
+
|
21
|
+
**Merged pull requests:**
|
22
|
+
|
23
|
+
- Add pre-commit hook for rubocop [\#70](https://github.com/puppetlabs/puppet-resource_api/pull/70) ([da-ar](https://github.com/da-ar))
|
24
|
+
- Add a template for release announcements [\#67](https://github.com/puppetlabs/puppet-resource_api/pull/67) ([DavidS](https://github.com/DavidS))
|
25
|
+
- Cache ~/.rvm for jruby jobs [\#66](https://github.com/puppetlabs/puppet-resource_api/pull/66) ([cotsog](https://github.com/cotsog))
|
26
|
+
- Release prep for v1.1.0 [\#64](https://github.com/puppetlabs/puppet-resource_api/pull/64) ([DavidS](https://github.com/DavidS))
|
27
|
+
|
6
28
|
## [v1.1.0](https://github.com/puppetlabs/puppet-resource_api/tree/v1.1.0) (2018-04-12)
|
7
29
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.0.3...v1.1.0)
|
8
30
|
|
data/contrib/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Git pre-commit hook
|
2
|
+
This directory contains the file `pre-commit`. When enabled the hook is called when you attempt to commit changes locally. The hook will run the bundled `rubocop` with auto correct function on files that you have changed.
|
3
|
+
|
4
|
+
* If rubocop is successful in correcting errors detected in the changed files it will stage the changes and proceed with the commit.
|
5
|
+
* If rubocop is unsuccessful in correcting errors detected in the changed files the commit will fail and the rubocop output will be displayed. Manual changes will need to be made before proceeding.
|
6
|
+
|
7
|
+
To enable the pre-commit hook, either create a symlink to this file or copy the file to `.git/hooks`
|
data/contrib/pre-commit
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Code modified from: https://gist.github.com/hanloong/9849098
|
3
|
+
require 'English'
|
4
|
+
|
5
|
+
ADDED = %r{A|AM}
|
6
|
+
|
7
|
+
changed_files = `git status --porcelain`.split(%r{\n})
|
8
|
+
changed_files = changed_files.select do |file_name_with_status|
|
9
|
+
file_name_with_status =~ ADDED
|
10
|
+
end
|
11
|
+
changed_files = changed_files.map do |file_name_with_status|
|
12
|
+
file_name_with_status.split(' ')[1]
|
13
|
+
end
|
14
|
+
changed_files = changed_files.select { |file_name|
|
15
|
+
File.extname(file_name) == '.rb'
|
16
|
+
}.join(' ')
|
17
|
+
|
18
|
+
system("bundle exec rubocop -a #{changed_files}") unless changed_files.empty?
|
19
|
+
|
20
|
+
if $CHILD_STATUS.to_s[-1].to_i.zero? && !changed_files.empty?
|
21
|
+
system("git add #{changed_files}")
|
22
|
+
end
|
23
|
+
exit $CHILD_STATUS.to_s[-1].to_i
|
data/lib/puppet/resource_api.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'puppet/resource_api/glue'
|
3
3
|
require 'puppet/resource_api/puppet_context' unless RUBY_PLATFORM == 'java'
|
4
|
+
require 'puppet/resource_api/type_definition'
|
4
5
|
require 'puppet/resource_api/version'
|
5
6
|
require 'puppet/type'
|
6
7
|
|
@@ -9,6 +10,7 @@ module Puppet::ResourceApi
|
|
9
10
|
raise Puppet::DevError, 'requires a Hash as definition, not %{other_type}' % { other_type: definition.class } unless definition.is_a? Hash
|
10
11
|
raise Puppet::DevError, 'requires a name' unless definition.key? :name
|
11
12
|
raise Puppet::DevError, 'requires attributes' unless definition.key? :attributes
|
13
|
+
validate_ensure(definition)
|
12
14
|
|
13
15
|
definition[:features] ||= []
|
14
16
|
supported_features = %w[supports_noop canonicalize remote_resource simple_get_filter].freeze
|
@@ -48,15 +50,15 @@ module Puppet::ResourceApi
|
|
48
50
|
self.class.my_provider
|
49
51
|
end
|
50
52
|
|
51
|
-
define_singleton_method(:
|
52
|
-
|
53
|
+
define_singleton_method(:type_definition) do
|
54
|
+
@type_definition ||= TypeDefinition.new(definition)
|
53
55
|
end
|
54
56
|
|
55
|
-
def
|
56
|
-
self.class.
|
57
|
+
def type_definition
|
58
|
+
self.class.type_definition
|
57
59
|
end
|
58
60
|
|
59
|
-
if
|
61
|
+
if type_definition.feature?('remote_resource')
|
60
62
|
apply_to_device
|
61
63
|
end
|
62
64
|
|
@@ -68,7 +70,7 @@ module Puppet::ResourceApi
|
|
68
70
|
@called_from_resource = true
|
69
71
|
end
|
70
72
|
# $stderr.puts "B: #{attributes.inspect}"
|
71
|
-
if
|
73
|
+
if type_definition.feature?('canonicalize')
|
72
74
|
attributes = my_provider.canonicalize(context, [attributes])[0]
|
73
75
|
end
|
74
76
|
# $stderr.puts "C: #{attributes.inspect}"
|
@@ -77,9 +79,11 @@ module Puppet::ResourceApi
|
|
77
79
|
|
78
80
|
validate do
|
79
81
|
# enforce mandatory attributes
|
80
|
-
missing_attrs = []
|
82
|
+
@missing_attrs = []
|
83
|
+
@missing_params = []
|
81
84
|
definition[:attributes].each do |name, options|
|
82
85
|
type = Puppet::Pops::Types::TypeParser.singleton.parse(options[:type])
|
86
|
+
|
83
87
|
# skip read only vars and the namevar
|
84
88
|
next if [:read_only, :namevar].include? options[:behaviour]
|
85
89
|
|
@@ -89,16 +93,14 @@ module Puppet::ResourceApi
|
|
89
93
|
options[:behaviour].nil?
|
90
94
|
|
91
95
|
if value(name).nil? && !(type.instance_of? Puppet::Pops::Types::POptionalType)
|
92
|
-
missing_attrs << name
|
96
|
+
@missing_attrs << name
|
97
|
+
@missing_params << name if options[:behaviour] == :parameter
|
93
98
|
end
|
94
99
|
end
|
95
100
|
|
96
|
-
missing_attrs -= [:ensure] if @called_from_resource
|
101
|
+
@missing_attrs -= [:ensure] if @called_from_resource
|
97
102
|
|
98
|
-
if
|
99
|
-
error_msg = "The following mandatory attributes were not provided:\n * " + missing_attrs.join(", \n * ")
|
100
|
-
raise Puppet::ResourceError, error_msg
|
101
|
-
end
|
103
|
+
raise_missing_params if @missing_params.any?
|
102
104
|
end
|
103
105
|
|
104
106
|
definition[:attributes].each do |name, options|
|
@@ -118,6 +120,7 @@ module Puppet::ResourceApi
|
|
118
120
|
else
|
119
121
|
:newproperty
|
120
122
|
end
|
123
|
+
|
121
124
|
send(param_or_property, name.to_sym) do
|
122
125
|
unless options[:type]
|
123
126
|
raise Puppet::DevError, "#{definition[:name]}.#{name} has no type"
|
@@ -144,12 +147,20 @@ module Puppet::ResourceApi
|
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
150
|
+
if name == :ensure
|
151
|
+
def insync?(is)
|
152
|
+
rs_value.to_s == is.to_s
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
147
156
|
type = Puppet::Pops::Types::TypeParser.singleton.parse(options[:type])
|
148
157
|
if param_or_property == :newproperty
|
149
158
|
define_method(:should) do
|
150
159
|
if type.is_a? Puppet::Pops::Types::PBooleanType
|
151
160
|
# work around https://tickets.puppetlabs.com/browse/PUP-2368
|
152
161
|
rs_value ? :true : :false # rubocop:disable Lint/BooleanSymbol
|
162
|
+
elsif name == :ensure && rs_value.is_a?(String)
|
163
|
+
rs_value.to_sym
|
153
164
|
else
|
154
165
|
rs_value
|
155
166
|
end
|
@@ -204,12 +215,11 @@ module Puppet::ResourceApi
|
|
204
215
|
Puppet::ResourceApi.def_newvalues(self, param_or_property, %r{})
|
205
216
|
when Puppet::Pops::Types::PBooleanType
|
206
217
|
Puppet::ResourceApi.def_newvalues(self, param_or_property, 'true', 'false')
|
207
|
-
# rubocop:disable Lint/BooleanSymbol
|
208
218
|
aliasvalue true, 'true'
|
209
219
|
aliasvalue false, 'false'
|
210
|
-
aliasvalue :true, 'true'
|
211
|
-
aliasvalue :false, 'false'
|
212
|
-
|
220
|
+
aliasvalue :true, 'true' # rubocop:disable Lint/BooleanSymbol
|
221
|
+
aliasvalue :false, 'false' # rubocop:disable Lint/BooleanSymbol
|
222
|
+
|
213
223
|
when Puppet::Pops::Types::PIntegerType
|
214
224
|
Puppet::ResourceApi.def_newvalues(self, param_or_property, %r{^-?\d+$})
|
215
225
|
when Puppet::Pops::Types::PFloatType, Puppet::Pops::Types::PNumericType
|
@@ -251,15 +261,13 @@ module Puppet::ResourceApi
|
|
251
261
|
# puts "retrieve(#{title.inspect})"
|
252
262
|
result = Puppet::Resource.new(self.class, title)
|
253
263
|
|
254
|
-
current_state = if
|
264
|
+
current_state = if type_definition.feature?('simple_get_filter')
|
255
265
|
my_provider.get(context, [title]).first
|
256
266
|
else
|
257
267
|
my_provider.get(context).find { |h| h[namevar_name] == title }
|
258
268
|
end
|
259
269
|
|
260
|
-
strict_check(current_state) if current_state &&
|
261
|
-
|
262
|
-
# require 'pry'; binding.pry
|
270
|
+
strict_check(current_state) if current_state && type_definition.feature?('canonicalize')
|
263
271
|
|
264
272
|
if current_state
|
265
273
|
current_state.each do |k, v|
|
@@ -267,23 +275,29 @@ module Puppet::ResourceApi
|
|
267
275
|
end
|
268
276
|
else
|
269
277
|
result[namevar_name] = title
|
270
|
-
result[:ensure] =
|
278
|
+
result[:ensure] = :absent if type_definition.ensurable?
|
271
279
|
end
|
272
280
|
|
281
|
+
# puppet needs ensure to be a symbol
|
282
|
+
result[:ensure] = result[:ensure].to_sym if type_definition.ensurable? && result[:ensure].is_a?(String)
|
283
|
+
|
284
|
+
raise_missing_attrs
|
285
|
+
|
273
286
|
@rapi_current_state = current_state
|
274
287
|
Puppet.debug("Current State: #{@rapi_current_state.inspect}")
|
275
288
|
result
|
276
289
|
end
|
277
290
|
|
278
291
|
define_method(:flush) do
|
292
|
+
raise_missing_attrs
|
293
|
+
|
279
294
|
# puts 'flush'
|
280
295
|
# skip puppet's injected metaparams
|
281
296
|
target_state = Hash[@parameters.reject { |k, _v| [:loglevel, :noop].include? k }.map { |k, v| [k, v.rs_value] }]
|
282
|
-
target_state = my_provider.canonicalize(context, [target_state]).first if
|
297
|
+
target_state = my_provider.canonicalize(context, [target_state]).first if type_definition.feature?('canonicalize')
|
283
298
|
|
284
299
|
retrieve unless @rapi_current_state
|
285
300
|
|
286
|
-
# require 'pry'; binding.pry
|
287
301
|
return if @rapi_current_state == target_state
|
288
302
|
|
289
303
|
Puppet.debug("Target State: #{target_state.inspect}")
|
@@ -302,7 +316,7 @@ module Puppet::ResourceApi
|
|
302
316
|
end
|
303
317
|
end
|
304
318
|
|
305
|
-
if
|
319
|
+
if type_definition.feature?('supports_noop')
|
306
320
|
my_provider.set(context, { title => { is: @rapi_current_state, should: target_state } }, noop: noop?)
|
307
321
|
else
|
308
322
|
my_provider.set(context, title => { is: @rapi_current_state, should: target_state }) unless noop?
|
@@ -310,6 +324,16 @@ module Puppet::ResourceApi
|
|
310
324
|
raise 'Execution encountered an error' if context.failed?
|
311
325
|
end
|
312
326
|
|
327
|
+
define_method(:raise_missing_attrs) do
|
328
|
+
error_msg = "The following mandatory attributes were not provided:\n * " + @missing_attrs.join(", \n * ")
|
329
|
+
raise Puppet::ResourceError, error_msg if @missing_attrs.any? && (value(:ensure) != :absent && !value(:ensure).nil?)
|
330
|
+
end
|
331
|
+
|
332
|
+
define_method(:raise_missing_params) do
|
333
|
+
error_msg = "The following mandatory parameters were not provided:\n * " + @missing_params.join(", \n * ")
|
334
|
+
raise Puppet::ResourceError, error_msg
|
335
|
+
end
|
336
|
+
|
313
337
|
define_method(:strict_check) do |current_state|
|
314
338
|
return if Puppet.settings[:strict] == :off
|
315
339
|
|
@@ -341,7 +365,7 @@ MESSAGE
|
|
341
365
|
end
|
342
366
|
|
343
367
|
define_singleton_method(:context) do
|
344
|
-
@context ||= PuppetContext.new(definition
|
368
|
+
@context ||= PuppetContext.new(definition)
|
345
369
|
end
|
346
370
|
|
347
371
|
def context
|
@@ -476,6 +500,15 @@ MESSAGE
|
|
476
500
|
# an error :-(
|
477
501
|
inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value)
|
478
502
|
error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch(error_msg_prefix, type, inferred_type)
|
479
|
-
|
503
|
+
[nil, error_msg]
|
504
|
+
end
|
505
|
+
|
506
|
+
def self.validate_ensure(definition)
|
507
|
+
return unless definition[:attributes].key? :ensure
|
508
|
+
options = definition[:attributes][:ensure]
|
509
|
+
type = Puppet::Pops::Types::TypeParser.singleton.parse(options[:type])
|
510
|
+
|
511
|
+
return if type.is_a?(Puppet::Pops::Types::PEnumType) && type.values.sort == %w[absent present].sort
|
512
|
+
raise Puppet::DevError, '`:ensure` attribute must have a type of: `Enum[present, absent]`'
|
480
513
|
end
|
481
514
|
end
|
@@ -1,9 +1,16 @@
|
|
1
1
|
require 'puppet/util'
|
2
2
|
require 'puppet/util/network_device'
|
3
|
+
require 'puppet/resource_api/type_definition'
|
3
4
|
|
5
|
+
module Puppet; end
|
6
|
+
module Puppet::ResourceApi; end
|
4
7
|
class Puppet::ResourceApi::BaseContext
|
5
|
-
|
6
|
-
|
8
|
+
attr_reader :type
|
9
|
+
|
10
|
+
def initialize(definition)
|
11
|
+
raise Puppet::DevError, 'BaseContext requires definition to be a Hash' unless definition.is_a?(Hash)
|
12
|
+
@typename = definition[:name]
|
13
|
+
@type = Puppet::ResourceApi::TypeDefinition.new(definition)
|
7
14
|
end
|
8
15
|
|
9
16
|
def device
|
@@ -17,13 +24,8 @@ class Puppet::ResourceApi::BaseContext
|
|
17
24
|
end
|
18
25
|
|
19
26
|
def feature_support?(feature)
|
20
|
-
|
21
|
-
|
22
|
-
Puppet.debug("#{@typename} supports `#{feature}`")
|
23
|
-
else
|
24
|
-
Puppet.debug("#{@typename} does not support `#{feature}`")
|
25
|
-
end
|
26
|
-
supported
|
27
|
+
Puppet.deprecation_warning('context.feature_support? is deprecated. Please use context.type.feature? instead.')
|
28
|
+
type.feature?(feature)
|
27
29
|
end
|
28
30
|
|
29
31
|
[:debug, :info, :notice, :warning, :err].each do |level|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'puppet/resource_api/base_context'
|
2
2
|
|
3
3
|
class Puppet::ResourceApi::IOContext < Puppet::ResourceApi::BaseContext
|
4
|
-
def initialize(
|
5
|
-
super(
|
4
|
+
def initialize(definition, target = $stderr)
|
5
|
+
super(definition)
|
6
6
|
@target = target
|
7
7
|
end
|
8
8
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
module Puppet; end # rubocop:disable Style/Documentation
|
1
2
|
module Puppet::ResourceApi
|
2
3
|
# This class provides a default implementation for set(), when your resource does not benefit from batching.
|
3
4
|
# Instead of processing changes yourself, the `create`, `update`, and `delete` functions, are called for you,
|
@@ -7,7 +8,7 @@ module Puppet::ResourceApi
|
|
7
8
|
class SimpleProvider
|
8
9
|
def set(context, changes)
|
9
10
|
changes.each do |name, change|
|
10
|
-
is = if context.
|
11
|
+
is = if context.type.feature?('simple_get_filter')
|
11
12
|
change.key?(:is) ? change[:is] : (get(context, [name]) || []).find { |r| r[:name] == name }
|
12
13
|
else
|
13
14
|
change.key?(:is) ? change[:is] : (get(context) || []).find { |r| r[:name] == name }
|
@@ -15,6 +16,8 @@ module Puppet::ResourceApi
|
|
15
16
|
|
16
17
|
should = change[:should]
|
17
18
|
|
19
|
+
raise 'SimpleProvider cannot be used with a Type that is not ensurable' unless context.type.ensurable?
|
20
|
+
|
18
21
|
is = { name: name, ensure: 'absent' } if is.nil?
|
19
22
|
should = { name: name, ensure: 'absent' } if should.nil?
|
20
23
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Provides accessor methods for the type being provided
|
2
|
+
class Puppet::ResourceApi::TypeDefinition
|
3
|
+
attr_reader :definition
|
4
|
+
|
5
|
+
def initialize(definition)
|
6
|
+
raise Puppet::DevError, 'TypeDefinition requires definition to be a Hash' unless definition.is_a?(Hash)
|
7
|
+
@definition = definition
|
8
|
+
end
|
9
|
+
|
10
|
+
def attributes
|
11
|
+
@definition[:attributes]
|
12
|
+
end
|
13
|
+
|
14
|
+
def ensurable?
|
15
|
+
@definition[:attributes].key?(:ensure)
|
16
|
+
end
|
17
|
+
|
18
|
+
# rubocop complains when this is named has_feature?
|
19
|
+
def feature?(feature)
|
20
|
+
supported = (definition[:features] && definition[:features].include?(feature))
|
21
|
+
if supported
|
22
|
+
Puppet.debug("#{definition[:name]} supports `#{feature}`")
|
23
|
+
else
|
24
|
+
Puppet.debug("#{definition[:name]} does not support `#{feature}`")
|
25
|
+
end
|
26
|
+
supported
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Send out announcements for major new feature releases, and high-impact bugfixes to puppet-dev@googlegroups.com, puppet-users@googlegroups.com, voxpupuli@groups.io, and the puppet internal mailing lists.
|
2
|
+
|
3
|
+
Before sending, do check that all links are still valid. Feel free to adjust the text to match better with the circumstances of the release, or add other news that are relevant at the time. If you make changes, consider committing them here, for the benefit of future-you.
|
4
|
+
|
5
|
+
The github rendering of the markdown seems to copy&paste acceptably into Google Inbox.
|
6
|
+
|
7
|
+
The [CHANGELOG](https://github.com/puppetlabs/puppet-resource_api/blob/master/CHANGELOG.md) is a good starting point for finding enhancements and bug-fixes.
|
8
|
+
|
9
|
+
See [this post](https://groups.google.com/d/msg/puppet-dev/1R9gwkEIxHU/adWXJ0NfCAAJ) for an example.
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
Subject: [ANN] Resource API vX.Y.Z Release
|
14
|
+
|
15
|
+
Hi all,
|
16
|
+
|
17
|
+
We're pleased to announce that version X.Y.Z of the Resource API is being released today.
|
18
|
+
|
19
|
+
The Resource API provides a simple way to create new native resources in the form of types and providers for Puppet. It is provided as a Ruby gem to be referenced within modules. Support for it has been included as an experimental feature in version 1.4 of the Puppet Development Kit (`pdk new provider`). Use the [resource_api module](https://forge.puppet.com/puppetlabs/resource_api) to deploy it in your infrastructure.
|
20
|
+
|
21
|
+
The new release of the Resource API provides the following enhancements:
|
22
|
+
|
23
|
+
* A
|
24
|
+
* B
|
25
|
+
* C
|
26
|
+
|
27
|
+
The new release also contains the following notable bugfixes:
|
28
|
+
|
29
|
+
* D
|
30
|
+
* E
|
31
|
+
* F
|
32
|
+
|
33
|
+
See the [CHANGELOG](https://github.com/puppetlabs/puppet-resource_api/blob/master/CHANGELOG.md) for a full list of changes
|
34
|
+
|
35
|
+
We encourage all module developers to review the Resource API and use it when creating types and providers. For reference, there is an example of its usage in a [branch](https://github.com/DavidS/puppetlabs-apt/blob/resource-api-experiments/lib/puppet/provider/apt_key2/apt_key2.rb) of the apt module.
|
36
|
+
|
37
|
+
Please let us know of your experiences with the Resource API, either here, on [Slack](https://slack.puppet.com/) (#forge-modules), or on the [github repo](https://github.com/puppetlabs/puppet-resource_api).
|
38
|
+
|
39
|
+
|
40
|
+
Thanks,
|
41
|
+
YOUR NAME
|
data/puppet-resource_api.gemspec
CHANGED
@@ -11,8 +11,8 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = 'This library provides a simple way to write new native resources for puppet.'
|
12
12
|
spec.homepage = 'https://github.com/puppetlabs/puppet-resource_api'
|
13
13
|
|
14
|
-
# on out internal jenkins, there is no
|
15
|
-
spec.files = if
|
14
|
+
# on out internal jenkins, there is no git, but since it is a clean machine, we don't need to worry about anything else
|
15
|
+
spec.files = if system('git --help > /dev/null')
|
16
16
|
`git ls-files -z`.split("\x0")
|
17
17
|
else
|
18
18
|
Dir.glob('**/*')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-resource_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Schmitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hocon
|
@@ -49,14 +49,18 @@ files:
|
|
49
49
|
- bin/console
|
50
50
|
- bin/setup
|
51
51
|
- codecov.yml
|
52
|
+
- contrib/README.md
|
53
|
+
- contrib/pre-commit
|
52
54
|
- lib/puppet/resource_api.rb
|
53
55
|
- lib/puppet/resource_api/base_context.rb
|
54
56
|
- lib/puppet/resource_api/glue.rb
|
55
57
|
- lib/puppet/resource_api/io_context.rb
|
56
58
|
- lib/puppet/resource_api/puppet_context.rb
|
57
59
|
- lib/puppet/resource_api/simple_provider.rb
|
60
|
+
- lib/puppet/resource_api/type_definition.rb
|
58
61
|
- lib/puppet/resource_api/version.rb
|
59
62
|
- lib/puppet/util/network_device/simple/device.rb
|
63
|
+
- misc/ANNOUNCEMENT_TEMPLATE.md
|
60
64
|
- puppet-resource_api.gemspec
|
61
65
|
homepage: https://github.com/puppetlabs/puppet-resource_api
|
62
66
|
licenses: []
|