puppet-resource_api 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -7
- data/CHANGELOG.md +17 -0
- data/Gemfile +1 -1
- data/README.md +9 -3
- data/lib/puppet/resource_api.rb +27 -3
- data/lib/puppet/resource_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8adaec9101c4bdf2bfaabfbb4ef87147d37c7360dd5008a8da7d0d653bd4071c
|
4
|
+
data.tar.gz: a81e2f4b6e643587b74e7ae4313e9b011f76aeec10b09abc292d9bb65083df2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f910f226a69685dcdadd6391b5ad4f2b5064f1861fdc06c8a7ed36d84f4da49d850983550809eb7053959d94799946c8c6109e0c3c848dbe9649d2bbc23f4f20
|
7
|
+
data.tar.gz: 47ba949ac49e663add1eed1d9648d5b4642346ac4ecbf944447670352e9aa8f75813d5964cab7fd9f2793e1ae49b41153b24d54b0e9bb5884484284d101bb0ca
|
data/.travis.yml
CHANGED
@@ -10,27 +10,38 @@ script:
|
|
10
10
|
cache: bundler
|
11
11
|
matrix:
|
12
12
|
include:
|
13
|
-
- rvm: 2.4.
|
14
|
-
env: PUPPET_GEM_VERSION='~> 5'
|
13
|
+
- rvm: 2.4.3
|
14
|
+
env: PUPPET_GEM_VERSION='~> 5' # 5.5
|
15
15
|
- rvm: jruby-1.7.26
|
16
16
|
env: PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug"
|
17
17
|
- rvm: jruby-9.1.9.0
|
18
18
|
env: PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug"
|
19
|
-
- rvm: 2.4.
|
19
|
+
- rvm: 2.4.3
|
20
20
|
env: CHECK=rubocop
|
21
|
+
- rvm: 2.4.3
|
22
|
+
env: CHECK=license_finder
|
23
|
+
bundler_args: ""
|
24
|
+
|
25
|
+
- rvm: 2.4.3
|
26
|
+
env: PUPPET_GEM_VERSION='~> 5.4.0'
|
27
|
+
- rvm: 2.4.2
|
28
|
+
env: PUPPET_GEM_VERSION='~> 5.3.0'
|
29
|
+
- rvm: 2.4.1
|
30
|
+
env: PUPPET_GEM_VERSION='~> 5.2.0'
|
31
|
+
- rvm: 2.4.1
|
32
|
+
env: PUPPET_GEM_VERSION='~> 5.1.0'
|
21
33
|
- rvm: 2.4.1
|
22
34
|
env: PUPPET_GEM_VERSION='~> 5.0.0'
|
23
35
|
- rvm: 2.1.9
|
24
|
-
env: PUPPET_GEM_VERSION='~> 4'
|
36
|
+
env: PUPPET_GEM_VERSION='~> 4' # 4.10
|
25
37
|
- rvm: 2.1.9
|
26
38
|
env: PUPPET_GEM_VERSION='~> 4.9.0'
|
27
39
|
- rvm: 2.1.9
|
28
40
|
env: PUPPET_GEM_VERSION='~> 4.8.0'
|
29
41
|
- rvm: 2.1.9
|
30
42
|
env: PUPPET_GEM_VERSION='~> 4.7.0'
|
31
|
-
- rvm: 2.4.
|
32
|
-
env:
|
33
|
-
bundler_args: ""
|
43
|
+
- rvm: 2.4.3
|
44
|
+
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#master'
|
34
45
|
notifications:
|
35
46
|
hipchat:
|
36
47
|
rooms:
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
All significant changes to this repo will be summarized in this file.
|
4
4
|
|
5
5
|
|
6
|
+
## [v1.0.2](https://github.com/puppetlabs/puppet-resource_api/tree/v1.0.2) (2018-03-26)
|
7
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.0.1...v1.0.2)
|
8
|
+
|
9
|
+
**Implemented enhancements:**
|
10
|
+
|
11
|
+
- \(PDK-875\) Validate behaviour values when registering a type [\#49](https://github.com/puppetlabs/puppet-resource_api/pull/49) ([da-ar](https://github.com/da-ar))
|
12
|
+
|
13
|
+
**Fixed bugs:**
|
14
|
+
|
15
|
+
- \(PDK-882,PDK-883\) validate only when needed [\#48](https://github.com/puppetlabs/puppet-resource_api/pull/48) ([DavidS](https://github.com/DavidS))
|
16
|
+
- \(PDK-884\) Handle missing namevars returned by providers [\#47](https://github.com/puppetlabs/puppet-resource_api/pull/47) ([da-ar](https://github.com/da-ar))
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- \(PDK-810\) run CI against all the versions [\#46](https://github.com/puppetlabs/puppet-resource_api/pull/46) ([DavidS](https://github.com/DavidS))
|
21
|
+
|
6
22
|
## [v1.0.1](https://github.com/puppetlabs/puppet-resource_api/tree/v1.0.1) (2018-03-23)
|
7
23
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.0.0...v1.0.1)
|
8
24
|
|
@@ -12,6 +28,7 @@ All significant changes to this repo will be summarized in this file.
|
|
12
28
|
|
13
29
|
**Merged pull requests:**
|
14
30
|
|
31
|
+
- Release prep for v1.0.1 [\#45](https://github.com/puppetlabs/puppet-resource_api/pull/45) ([DavidS](https://github.com/DavidS))
|
15
32
|
- Release prep for v1.0.0 [\#43](https://github.com/puppetlabs/puppet-resource_api/pull/43) ([da-ar](https://github.com/da-ar))
|
16
33
|
|
17
34
|
## [v1.0.0](https://github.com/puppetlabs/puppet-resource_api/tree/v1.0.0) (2018-03-23)
|
data/Gemfile
CHANGED
@@ -30,7 +30,7 @@ end
|
|
30
30
|
# `git://somewhere.git#branch`. You can also use a file source location, which
|
31
31
|
# is specified as `file://some/location/on/disk`.
|
32
32
|
def location_for(place_or_version, fake_version = nil)
|
33
|
-
if place_or_version =~ /^(git[:@][^#]*)#(.*)/
|
33
|
+
if place_or_version =~ /^((?:git|https)[:@][^#]*)#(.*)/
|
34
34
|
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
35
35
|
elsif place_or_version =~ /^file:\/\/(.*)/
|
36
36
|
['>= 0', { :path => File.expand_path($1), :require => false }]
|
data/README.md
CHANGED
@@ -198,10 +198,16 @@ Currently working:
|
|
198
198
|
|
199
199
|
There are still a few notable gaps between the implementation and the specification:
|
200
200
|
* Only a single runtime environment (the Puppet commands) is currently implemented.
|
201
|
+
* The `:init_only` behaviour is not yet implemented ([PDK-885](https://tickets.puppetlabs.com/browse/PDK-885))
|
201
202
|
|
202
203
|
Restrictions of running under puppet:
|
203
204
|
* `supports_noop` is not effective, as puppet doesn't call into the type under noop.
|
204
205
|
|
206
|
+
Future possibilities:
|
207
|
+
* [Composite Namevars](https://tickets.puppetlabs.com/browse/PDK-531)
|
208
|
+
* [Multiple Providers](https://tickets.puppetlabs.com/browse/PDK-530)
|
209
|
+
* [Commands API](https://tickets.puppetlabs.com/browse/PDK-847)
|
210
|
+
|
205
211
|
## Development
|
206
212
|
|
207
213
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -220,10 +226,10 @@ To cut a new release, from a current `master` checkout:
|
|
220
226
|
* Update the CHANGELOG
|
221
227
|
* Have a [CHANGELOG_GITHUB_TOKEN](https://github.com/skywinder/github-changelog-generator#github-token) set in your environment
|
222
228
|
* run `rake changelog`
|
223
|
-
* double check the PRs to make sure they're all tagged correctly
|
229
|
+
* double check the PRs to make sure they're all tagged correctly (using the new CHANGELOG for cross-checking)
|
224
230
|
* Check README and other materials for up-to-date-ness
|
225
231
|
* Commit changes with title "Release prep for v<VERSION>"
|
226
232
|
* Upload and PR the release prep to github as normal
|
227
233
|
* Check that CI is green and merge the PR
|
228
|
-
* Run `rake release[upstream]` to release
|
229
|
-
* make sure to use the name of
|
234
|
+
* Run `rake release[upstream]` to release from your checkout
|
235
|
+
* make sure to use the name of your git remote pointing to main repo instead of "upstream"
|
data/lib/puppet/resource_api.rb
CHANGED
@@ -62,7 +62,11 @@ module Puppet::ResourceApi
|
|
62
62
|
|
63
63
|
define_method(:initialize) do |attributes|
|
64
64
|
# $stderr.puts "A: #{attributes.inspect}"
|
65
|
-
|
65
|
+
if attributes.is_a? Puppet::Resource
|
66
|
+
attributes = attributes.to_hash
|
67
|
+
else
|
68
|
+
@called_from_resource = true
|
69
|
+
end
|
66
70
|
# $stderr.puts "B: #{attributes.inspect}"
|
67
71
|
if feature_support?('canonicalize')
|
68
72
|
attributes = my_provider.canonicalize(context, [attributes])[0]
|
@@ -76,10 +80,21 @@ module Puppet::ResourceApi
|
|
76
80
|
missing_attrs = []
|
77
81
|
definition[:attributes].each do |name, options|
|
78
82
|
type = Puppet::Pops::Types::TypeParser.singleton.parse(options[:type])
|
79
|
-
|
80
|
-
|
83
|
+
# skip read only vars and the namevar
|
84
|
+
next if [:read_only, :namevar].include? options[:behaviour]
|
85
|
+
|
86
|
+
# skip properties if the resource is being deleted
|
87
|
+
next if definition[:attributes][:ensure] &&
|
88
|
+
value(:ensure) == :absent &&
|
89
|
+
options[:behaviour].nil?
|
90
|
+
|
91
|
+
if value(name).nil? && !(type.instance_of? Puppet::Pops::Types::POptionalType)
|
92
|
+
missing_attrs << name
|
81
93
|
end
|
82
94
|
end
|
95
|
+
|
96
|
+
missing_attrs -= [:ensure] if @called_from_resource
|
97
|
+
|
83
98
|
if missing_attrs.any?
|
84
99
|
error_msg = "The following mandatory attributes where not provided:\n * " + missing_attrs.join(", \n * ")
|
85
100
|
raise Puppet::ResourceError, error_msg
|
@@ -89,6 +104,12 @@ module Puppet::ResourceApi
|
|
89
104
|
definition[:attributes].each do |name, options|
|
90
105
|
# puts "#{name}: #{options.inspect}"
|
91
106
|
|
107
|
+
if options[:behaviour]
|
108
|
+
unless [:read_only, :namevar, :parameter].include? options[:behaviour]
|
109
|
+
raise Puppet::ResourceError, "`#{options[:behaviour]}` is not a valid behaviour value"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
92
113
|
# TODO: using newparam everywhere would suppress change reporting
|
93
114
|
# that would allow more fine-grained reporting through context,
|
94
115
|
# but require more invest in hooking up the infrastructure to emulate existing data
|
@@ -200,6 +221,9 @@ module Puppet::ResourceApi
|
|
200
221
|
property = definition[:attributes][key.first]
|
201
222
|
attr_def[key.first] = property
|
202
223
|
end
|
224
|
+
if resource_hash[namevar_name].nil?
|
225
|
+
raise Puppet::ResourceError, "`#{name}.get` did not return a value for the `#{namevar_name}` namevar attribute"
|
226
|
+
end
|
203
227
|
Puppet::ResourceApi::TypeShim.new(resource_hash[namevar_name], resource_hash, name, namevar_name, attr_def)
|
204
228
|
end
|
205
229
|
end
|
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.0.
|
4
|
+
version: 1.0.2
|
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-03-
|
11
|
+
date: 2018-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hocon
|