puppet-resource_api 0.10.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +17 -2
- data/lib/puppet/resource_api.rb +25 -1
- data/lib/puppet/resource_api/glue.rb +16 -6
- data/lib/puppet/resource_api/puppet_context.rb +1 -6
- data/lib/puppet/resource_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98bb3049dbee474c4797f9934cc522e2d563bc326429c7a01b5145e32fed0747
|
4
|
+
data.tar.gz: ecdcc16efa98548c619216631d9ad9c1392ecf134d25788bea7e9b6a8e94fb7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5479c197d0996a9bba3d0c4dea2c2d41a256f2fa1054236247a4c8066b75926021ffaada63286dbb81c812550e1a35807186929ad953347317cb2ace20685143
|
7
|
+
data.tar.gz: e6fe0d5304d2187b26cf940f880ca0714c843e47df3d5866355cd84467ea2ea13246352e0a74c4c385196e1702a18609400873d4470951848ccb6b30a4558ba1
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,23 @@
|
|
3
3
|
All significant changes to this repo will be summarized in this file.
|
4
4
|
|
5
5
|
|
6
|
+
## [v1.0.0](https://github.com/puppetlabs/puppet-resource_api/tree/v1.0.0) (2018-03-23)
|
7
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v0.10.0...v1.0.0)
|
8
|
+
|
9
|
+
**Implemented enhancements:**
|
10
|
+
|
11
|
+
- Improve logging output [\#42](https://github.com/puppetlabs/puppet-resource_api/pull/42) ([DavidS](https://github.com/DavidS))
|
12
|
+
- \(PDK-797\) Render read\_only values as comments in manifest output [\#41](https://github.com/puppetlabs/puppet-resource_api/pull/41) ([da-ar](https://github.com/da-ar))
|
13
|
+
|
14
|
+
**Fixed bugs:**
|
15
|
+
|
16
|
+
- \(PDK-819\) Ensure checks for mandatory type attributes [\#40](https://github.com/puppetlabs/puppet-resource_api/pull/40) ([da-ar](https://github.com/da-ar))
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- Notes on how to build a release [\#39](https://github.com/puppetlabs/puppet-resource_api/pull/39) ([DavidS](https://github.com/DavidS))
|
21
|
+
- Release prep for v0.10.0 [\#38](https://github.com/puppetlabs/puppet-resource_api/pull/38) ([DavidS](https://github.com/DavidS))
|
22
|
+
|
6
23
|
## [v0.10.0](https://github.com/puppetlabs/puppet-resource_api/tree/v0.10.0) (2018-03-21)
|
7
24
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v0.9.0...v0.10.0)
|
8
25
|
|
data/README.md
CHANGED
@@ -198,7 +198,6 @@ 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
|
-
* `auto*` definitions.
|
202
201
|
|
203
202
|
Restrictions of running under puppet:
|
204
203
|
* `supports_noop` is not effective, as puppet doesn't call into the type under noop.
|
@@ -211,4 +210,20 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
211
210
|
|
212
211
|
## Contributing
|
213
212
|
|
214
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
213
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/puppetlabs/puppet-resource_api.
|
214
|
+
|
215
|
+
### Cutting a release
|
216
|
+
|
217
|
+
To cut a new release, from a current `master` checkout:
|
218
|
+
|
219
|
+
* Update `lib/puppet/resource_api/version.rb` to the new version
|
220
|
+
* Update the CHANGELOG
|
221
|
+
* Have a [CHANGELOG_GITHUB_TOKEN](https://github.com/skywinder/github-changelog-generator#github-token) set in your environment
|
222
|
+
* run `rake changelog`
|
223
|
+
* double check the PRs to make sure they're all tagged correctly
|
224
|
+
* Check README and other materials for up-to-date-ness
|
225
|
+
* Commit changes
|
226
|
+
* Upload and PR the release prep to github as normal
|
227
|
+
* Check that CI is green and merge the PR
|
228
|
+
* Run `rake release[upstream]` to release what just passed CI
|
229
|
+
* make sure to use the name of the git remote to main repo instead of "upstream"
|
data/lib/puppet/resource_api.rb
CHANGED
@@ -61,6 +61,21 @@ module Puppet::ResourceApi
|
|
61
61
|
super(attributes)
|
62
62
|
end
|
63
63
|
|
64
|
+
validate do
|
65
|
+
# enforce mandatory attributes
|
66
|
+
missing_attrs = []
|
67
|
+
definition[:attributes].each do |name, options|
|
68
|
+
type = Puppet::Pops::Types::TypeParser.singleton.parse(options[:type])
|
69
|
+
unless [:read_only, :namevar].include? options[:behaviour]
|
70
|
+
missing_attrs << name if value(name).nil? && !(type.instance_of? Puppet::Pops::Types::POptionalType)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if missing_attrs.any?
|
74
|
+
error_msg = "The following mandatory attributes where not provided:\n * " + missing_attrs.join(", \n * ")
|
75
|
+
raise Puppet::ResourceError, error_msg
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
64
79
|
definition[:attributes].each do |name, options|
|
65
80
|
# puts "#{name}: #{options.inspect}"
|
66
81
|
|
@@ -117,6 +132,10 @@ module Puppet::ResourceApi
|
|
117
132
|
end
|
118
133
|
end
|
119
134
|
|
135
|
+
if type.instance_of? Puppet::Pops::Types::POptionalType
|
136
|
+
type = type.type
|
137
|
+
end
|
138
|
+
|
120
139
|
# provide better handling of the standard types
|
121
140
|
case type
|
122
141
|
when Puppet::Pops::Types::PStringType
|
@@ -165,8 +184,13 @@ module Puppet::ResourceApi
|
|
165
184
|
# puts 'instances'
|
166
185
|
# force autoloading of the provider
|
167
186
|
provider(name)
|
187
|
+
attr_def = {}
|
168
188
|
my_provider.get(context).map do |resource_hash|
|
169
|
-
|
189
|
+
resource_hash.each do |key|
|
190
|
+
property = definition[:attributes][key.first]
|
191
|
+
attr_def[key.first] = property
|
192
|
+
end
|
193
|
+
Puppet::ResourceApi::TypeShim.new(resource_hash[namevar_name], resource_hash, name, namevar_name, attr_def)
|
170
194
|
end
|
171
195
|
end
|
172
196
|
|
@@ -2,9 +2,9 @@
|
|
2
2
|
module Puppet::ResourceApi
|
3
3
|
# A trivial class to provide the functionality required to push data through the existing type/provider parts of puppet
|
4
4
|
class TypeShim
|
5
|
-
attr_reader :values, :typename, :namevar
|
5
|
+
attr_reader :values, :typename, :namevar, :attr_def
|
6
6
|
|
7
|
-
def initialize(title, resource_hash, typename, namevarname)
|
7
|
+
def initialize(title, resource_hash, typename, namevarname, attr_def)
|
8
8
|
# internalize and protect - needs to go deeper
|
9
9
|
@values = resource_hash.dup
|
10
10
|
# "name" is a privileged key
|
@@ -13,10 +13,11 @@ module Puppet::ResourceApi
|
|
13
13
|
|
14
14
|
@typename = typename
|
15
15
|
@namevar = namevarname
|
16
|
+
@attr_def = attr_def
|
16
17
|
end
|
17
18
|
|
18
19
|
def to_resource
|
19
|
-
ResourceShim.new(@values, @typename, @namevar)
|
20
|
+
ResourceShim.new(@values, @typename, @namevar, @attr_def)
|
20
21
|
end
|
21
22
|
|
22
23
|
def name
|
@@ -26,12 +27,13 @@ module Puppet::ResourceApi
|
|
26
27
|
|
27
28
|
# A trivial class to provide the functionality required to push data through the existing type/provider parts of puppet
|
28
29
|
class ResourceShim
|
29
|
-
attr_reader :values, :typename, :namevar
|
30
|
+
attr_reader :values, :typename, :namevar, :attr_def
|
30
31
|
|
31
|
-
def initialize(resource_hash, typename, namevarname)
|
32
|
+
def initialize(resource_hash, typename, namevarname, attr_def)
|
32
33
|
@values = resource_hash.dup.freeze # whatevs
|
33
34
|
@typename = typename
|
34
35
|
@namevar = namevarname
|
36
|
+
@attr_def = attr_def
|
35
37
|
end
|
36
38
|
|
37
39
|
def title
|
@@ -44,7 +46,15 @@ module Puppet::ResourceApi
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def to_manifest
|
47
|
-
(["#{@typename} { #{values[@namevar].inspect}: "] + values.keys.reject { |k| k == @namevar }.map
|
49
|
+
(["#{@typename} { #{values[@namevar].inspect}: "] + values.keys.reject { |k| k == @namevar }.map do |k|
|
50
|
+
cs = ' '
|
51
|
+
ce = ''
|
52
|
+
if attr_def[k][:behaviour] && attr_def[k][:behaviour] == :read_only
|
53
|
+
cs = '#'
|
54
|
+
ce = ' # Read Only'
|
55
|
+
end
|
56
|
+
"#{cs} #{k} => #{Puppet::Parameter.format_value_for_display(values[k])},#{ce}"
|
57
|
+
end + ['}']).join("\n")
|
48
58
|
end
|
49
59
|
|
50
60
|
# Convert our resource to yaml for Hiera purposes.
|
@@ -2,14 +2,9 @@ require 'puppet/resource_api/base_context'
|
|
2
2
|
require 'puppet/util/logging'
|
3
3
|
|
4
4
|
class Puppet::ResourceApi::PuppetContext < Puppet::ResourceApi::BaseContext
|
5
|
-
# declare a separate class to encapsulate Puppet's logging facilities
|
6
|
-
class PuppetLogger
|
7
|
-
extend Puppet::Util::Logging
|
8
|
-
end
|
9
|
-
|
10
5
|
protected
|
11
6
|
|
12
7
|
def send_log(level, message)
|
13
|
-
|
8
|
+
Puppet::Util::Log.create(level: level, message: message)
|
14
9
|
end
|
15
10
|
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: 0.
|
4
|
+
version: 1.0.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-03-
|
11
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hocon
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.7.
|
80
|
+
rubygems_version: 2.7.3
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: This library provides a simple way to write new native resources for puppet.
|