puppet-resource_api 1.8.13 → 1.8.14
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/.github/dependabot.yml +12 -0
- data/.rubocop.yml +1 -1
- data/.travis.yml +8 -44
- data/CHANGELOG.md +66 -25
- data/Gemfile +39 -19
- data/HISTORY.md +0 -5
- data/README.md +6 -6
- data/appveyor.yml +3 -3
- data/contrib/pre-commit +2 -0
- data/docs/README.md +1 -1
- data/docs/hands-on-lab/01-installing-prereqs.md +1 -1
- data/docs/hands-on-lab/04-adding-a-new-transport.md +1 -1
- data/docs/hands-on-lab/07-implementing-a-task.md +1 -1
- data/lib/puppet/resource_api.rb +37 -45
- data/lib/puppet/resource_api/base_context.rb +2 -0
- data/lib/puppet/resource_api/data_type_handling.rb +2 -0
- data/lib/puppet/resource_api/glue.rb +9 -2
- data/lib/puppet/resource_api/io_context.rb +2 -0
- data/lib/puppet/resource_api/parameter.rb +4 -2
- data/lib/puppet/resource_api/property.rb +65 -5
- data/lib/puppet/resource_api/puppet_context.rb +2 -0
- data/lib/puppet/resource_api/read_only_parameter.rb +2 -0
- data/lib/puppet/resource_api/simple_provider.rb +2 -0
- data/lib/puppet/resource_api/transport.rb +2 -0
- data/lib/puppet/resource_api/transport/wrapper.rb +2 -0
- data/lib/puppet/resource_api/type_definition.rb +59 -3
- data/lib/puppet/resource_api/value_creator.rb +2 -0
- data/lib/puppet/resource_api/version.rb +3 -1
- data/lib/puppet/util/network_device/simple/device.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 535559ec94778cea613ca61f7fd96309506730c7a79b7b081e198cea19739db0
|
|
4
|
+
data.tar.gz: afc626bed3349a334d7a25df3950f56ce997f6a607e8bdbe156c38b631c98d4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c587b8c92ed10ec5329cb80c00968003b8f0a95f51e62002b26c4b446f48f517754ebf2344542806411e81a239f3f1bc56d56574652ad34624076726ed9880b8
|
|
7
|
+
data.tar.gz: b2fd76ef2a2cf6ae5e1f9f18022a318012ec29dbfbc4af6232b7bdb6481e5affeeb9f77c471fd0195e6401427656f854ac4c4083202b742c3be5772bbe9ba1fb
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
|
@@ -15,13 +15,6 @@ jobs:
|
|
|
15
15
|
include:
|
|
16
16
|
- rvm: 2.4.3
|
|
17
17
|
env: PUPPET_GEM_VERSION='~> 5' SIMPLECOV=yes # 5.5
|
|
18
|
-
- env: RVM="jruby-1.7.26" PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug" SIMPLECOV=yes
|
|
19
|
-
dist: trusty
|
|
20
|
-
before_cache: pushd ~/.rvm && rm -rf archives rubies/ruby-2.2.7 rubies/ruby-2.3.4 && popd
|
|
21
|
-
cache:
|
|
22
|
-
bundler: true
|
|
23
|
-
directories: [~/.rvm]
|
|
24
|
-
before_install: rvm use jruby-1.7.26 --install --binary --fuzzy && gem install bundler -v '~> 1.7.0'
|
|
25
18
|
# disable coverage on jruby9k as this confuses codecov
|
|
26
19
|
- env: RVM="jruby-9.1.9.0" PUPPET_GEM_VERSION='~> 5' JRUBY_OPTS="--debug"
|
|
27
20
|
dist: trusty
|
|
@@ -35,45 +28,16 @@ jobs:
|
|
|
35
28
|
- rvm: 2.5.1
|
|
36
29
|
env: CHECK=license_finder
|
|
37
30
|
bundler_args: ""
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
env: PUPPET_GEM_VERSION='~> 5.1.0'
|
|
47
|
-
- rvm: 2.4.1
|
|
48
|
-
env: PUPPET_GEM_VERSION='~> 5.0.0'
|
|
49
|
-
- rvm: 2.1.9
|
|
50
|
-
env: PUPPET_GEM_VERSION='~> 4' SIMPLECOV=yes # 4.10
|
|
51
|
-
before_install:
|
|
52
|
-
- gem install bundler -v '< 2'
|
|
53
|
-
- rvm: 2.1.9
|
|
54
|
-
env: PUPPET_GEM_VERSION='~> 4.9.0'
|
|
55
|
-
before_install:
|
|
56
|
-
- gem install bundler -v '< 2'
|
|
57
|
-
- rvm: 2.1.9
|
|
58
|
-
env: PUPPET_GEM_VERSION='~> 4.8.0'
|
|
59
|
-
before_install:
|
|
60
|
-
- gem install bundler -v '< 2'
|
|
61
|
-
- rvm: 2.1.9
|
|
62
|
-
env: PUPPET_GEM_VERSION='~> 4.7.0'
|
|
63
|
-
before_install:
|
|
64
|
-
- gem install bundler -v '< 2'
|
|
65
|
-
- rvm: 2.5.1
|
|
66
|
-
env: PUPPET_GEM_VERSION='~> 6' # 6.0, soon 6.1
|
|
67
|
-
- rvm: 2.5.1
|
|
68
|
-
env: PUPPET_GEM_VERSION='~> 6.0'
|
|
69
|
-
- rvm: 2.5.1
|
|
70
|
-
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#master'
|
|
71
|
-
- rvm: 2.5.1
|
|
72
|
-
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#6.0.x'
|
|
31
|
+
- rvm: 2.5.7
|
|
32
|
+
env: PUPPET_GEM_VERSION='~> 6' SIMPLECOV=yes # latest 6 release
|
|
33
|
+
- rvm: 2.5.7
|
|
34
|
+
env: PUPPET_GEM_VERSION='~> 6.14.0'
|
|
35
|
+
- rvm: 2.5.7
|
|
36
|
+
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#main'
|
|
37
|
+
- rvm: 2.7
|
|
38
|
+
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#main'
|
|
73
39
|
- rvm: 2.4.3
|
|
74
40
|
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#5.5.x'
|
|
75
|
-
- rvm: 2.1.9
|
|
76
|
-
env: PUPPET_GEM_VERSION='https://github.com/puppetlabs/puppet.git#4.10.x'
|
|
77
41
|
notifications:
|
|
78
42
|
slack:
|
|
79
43
|
secure: aPXZYNow8LsmmlS8PQU3FjL0bc7FqUUA95d++wZfIu7YAjGboIUiekxYouQ0XnY+Aig8InvbTOIgBHgGNheyr/YFbFS90/jtulbF8oW7BitW+imgjeAHDCwlQZTCc4FFYde/2pI7QTT8H5NpLR9mKxlTU77Sqr8gFAIybuPdHcKMYQZdEZS07ma2pUp7+GyKS6PDQpzW2+mDCz/wfi3/JdsUvc0mclCZ8vxySc66j5P1E6nFDMzuakBOjwJHpgeDpreapbmSUQLAX0a3ZsFP+N+SNduLotlV2BWnJK2gcO6rGFP4Fz1D0bGXuBnYYdIiB+9OgI3wtXg9y1SifNHUG3IrOBAA8CGNyrebTGKtH0TS2O+HZLbaNX2g6udD5e3156vys9wScmJuQ/rSkVtQfXf1qUm5eijvlXI+DIbssbZHqm6QQGyM4p3NoULmNmF1C85bQoZ4GF7b1P/8mstsVE/HUfnzRPNbwD0r6j1aE/ck3PKMi7ZAhIi0Ja9RnAgP3wi0t62uERYcJGGYEycWohMWnrf2w6GFwGeuoiwAkASdHOLX0/AOMPc4mBOjlc621o8uYMrrZqfF5CrOAvJ151USSsWn2AhXaibIvnHo6X91paNvvNpU/GYu3CUAl6q8OhYovvjtRVPVnhs2DrpgoRB+6NWHnzjRG/wr6Z9U+vA=
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
3
3
|
All significant changes to this repo will be summarized in this file.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## [v1.8.14](https://github.com/puppetlabs/puppet-resource_api/tree/v1.8.14) (2021-06-09)
|
|
7
|
+
|
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.13...v1.8.14)
|
|
9
|
+
|
|
10
|
+
**Implemented enhancements:**
|
|
11
|
+
|
|
12
|
+
- \(GH-225\) Add support for custom insync [\#285](https://github.com/puppetlabs/puppet-resource_api/pull/285) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
|
13
|
+
- Improve type validation error messages to show expected types [\#279](https://github.com/puppetlabs/puppet-resource_api/pull/279) ([timidri](https://github.com/timidri))
|
|
14
|
+
- Support `puppet device --resource ... --to_yaml` invocation; drop puppet4 and jruby 1.7 testing [\#278](https://github.com/puppetlabs/puppet-resource_api/pull/278) ([timidri](https://github.com/timidri))
|
|
15
|
+
|
|
16
|
+
**Fixed bugs:**
|
|
17
|
+
|
|
18
|
+
- Git tag 1.8.13 exists, but missing on rubygems.org / in CHANGELOG.md [\#266](https://github.com/puppetlabs/puppet-resource_api/issues/266)
|
|
19
|
+
|
|
20
|
+
**Closed issues:**
|
|
21
|
+
|
|
22
|
+
- CHANGELOG.md entries are missing for latest releases? [\#258](https://github.com/puppetlabs/puppet-resource_api/issues/258)
|
|
23
|
+
|
|
24
|
+
**Merged pull requests:**
|
|
25
|
+
|
|
26
|
+
- Upgrade to GitHub-native Dependabot [\#287](https://github.com/puppetlabs/puppet-resource_api/pull/287) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
|
27
|
+
- \(IAC-1455\) - Removal of Inappropriate Terminology [\#283](https://github.com/puppetlabs/puppet-resource_api/pull/283) ([david22swan](https://github.com/david22swan))
|
|
28
|
+
- Update puppetlabs\_spec\_helper requirement from ~\> 2.7 to ~\> 3.0 [\#281](https://github.com/puppetlabs/puppet-resource_api/pull/281) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
|
29
|
+
- \(maint\) Update Puppet VS Code Extension ID [\#277](https://github.com/puppetlabs/puppet-resource_api/pull/277) ([jpogran](https://github.com/jpogran))
|
|
30
|
+
- \(IAC-859\) Add ruby 2.7 to test matrix [\#276](https://github.com/puppetlabs/puppet-resource_api/pull/276) ([DavidS](https://github.com/DavidS))
|
|
31
|
+
- \(maint\) Cleanup gemfile and fix codecov dependency [\#275](https://github.com/puppetlabs/puppet-resource_api/pull/275) ([DavidS](https://github.com/DavidS))
|
|
32
|
+
- Language correction [\#270](https://github.com/puppetlabs/puppet-resource_api/pull/270) ([epackorigan](https://github.com/epackorigan))
|
|
33
|
+
- \(maint\) Update CHANGELOG [\#268](https://github.com/puppetlabs/puppet-resource_api/pull/268) ([DavidS](https://github.com/DavidS))
|
|
34
|
+
- \(maint\) update test matrix for current supported versions; remove older versions to cut down on resource usage [\#265](https://github.com/puppetlabs/puppet-resource_api/pull/265) ([DavidS](https://github.com/DavidS))
|
|
35
|
+
- \(maint\) Mock Hocon.load\(...\) [\#263](https://github.com/puppetlabs/puppet-resource_api/pull/263) ([IrimieBogdan](https://github.com/IrimieBogdan))
|
|
36
|
+
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#262](https://github.com/puppetlabs/puppet-resource_api/pull/262) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
|
|
37
|
+
- \(maint\) update Gemfile to allow use of non-vulnerable rake version 12.3.3 [\#260](https://github.com/puppetlabs/puppet-resource_api/pull/260) ([DavidS](https://github.com/DavidS))
|
|
38
|
+
|
|
39
|
+
## [1.8.13](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.13) (2020-02-19)
|
|
40
|
+
|
|
41
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.12...1.8.13)
|
|
42
|
+
|
|
43
|
+
**Merged pull requests:**
|
|
44
|
+
|
|
45
|
+
- \(IAC-274\) update CHANGELOG [\#259](https://github.com/puppetlabs/puppet-resource_api/pull/259) ([DavidS](https://github.com/DavidS))
|
|
46
|
+
|
|
6
47
|
## [1.8.12](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.12) (2020-02-03)
|
|
7
48
|
|
|
8
49
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.11...1.8.12)
|
|
@@ -48,7 +89,7 @@ All significant changes to this repo will be summarized in this file.
|
|
|
48
89
|
|
|
49
90
|
**Merged pull requests:**
|
|
50
91
|
|
|
51
|
-
- \(FM-8740\): Documentation tweaks based on most recent walkthrough [\#246](https://github.com/puppetlabs/puppet-resource_api/pull/246) ([
|
|
92
|
+
- \(FM-8740\): Documentation tweaks based on most recent walkthrough [\#246](https://github.com/puppetlabs/puppet-resource_api/pull/246) ([sanfrancrisko](https://github.com/sanfrancrisko))
|
|
52
93
|
|
|
53
94
|
## [1.8.9](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.9) (2019-10-03)
|
|
54
95
|
|
|
@@ -86,19 +127,28 @@ All significant changes to this repo will be summarized in this file.
|
|
|
86
127
|
**Merged pull requests:**
|
|
87
128
|
|
|
88
129
|
- \(FM-8485\) - Addition of CODEOWNERS file [\#203](https://github.com/puppetlabs/puppet-resource_api/pull/203) ([david22swan](https://github.com/david22swan))
|
|
89
|
-
- \(MODULES-9258\) Improve referencing and add summary [\#199](https://github.com/puppetlabs/puppet-resource_api/pull/199) ([
|
|
130
|
+
- \(MODULES-9258\) Improve referencing and add summary [\#199](https://github.com/puppetlabs/puppet-resource_api/pull/199) ([maxiegit](https://github.com/maxiegit))
|
|
90
131
|
- \(maint\) Pin both Jruby cells to use `dist: trusty` [\#197](https://github.com/puppetlabs/puppet-resource_api/pull/197) ([da-ar](https://github.com/da-ar))
|
|
91
132
|
|
|
92
133
|
## [1.8.6](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.6) (2019-07-04)
|
|
93
|
-
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.6.5...1.8.6)
|
|
94
134
|
|
|
95
|
-
|
|
96
|
-
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.5...1.6.5)
|
|
135
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.6.5...1.8.6)
|
|
97
136
|
|
|
98
137
|
**Implemented enhancements:**
|
|
99
138
|
|
|
100
139
|
- \(SERVER-2470\) list\_all\_transports implementation for puppetserver [\#187](https://github.com/puppetlabs/puppet-resource_api/pull/187) ([DavidS](https://github.com/DavidS))
|
|
101
140
|
|
|
141
|
+
**Merged pull requests:**
|
|
142
|
+
|
|
143
|
+
- Merge 1.6.x [\#194](https://github.com/puppetlabs/puppet-resource_api/pull/194) ([da-ar](https://github.com/da-ar))
|
|
144
|
+
- \(packaging\) Revert to version '1.8.5' \[no-promote\] [\#192](https://github.com/puppetlabs/puppet-resource_api/pull/192) ([gimmyxd](https://github.com/gimmyxd))
|
|
145
|
+
- \(packaging\) Bump to version '1.9.0' \[no-promote\] [\#191](https://github.com/puppetlabs/puppet-resource_api/pull/191) ([gimmyxd](https://github.com/gimmyxd))
|
|
146
|
+
- \(maint\) retrofitting changelog for the last couple of releases [\#190](https://github.com/puppetlabs/puppet-resource_api/pull/190) ([DavidS](https://github.com/DavidS))
|
|
147
|
+
|
|
148
|
+
## [1.6.5](https://github.com/puppetlabs/puppet-resource_api/tree/1.6.5) (2019-07-04)
|
|
149
|
+
|
|
150
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.5...1.6.5)
|
|
151
|
+
|
|
102
152
|
**Fixed bugs:**
|
|
103
153
|
|
|
104
154
|
- \(MODULES-9428\) make the composite namevar implementation usable [\#174](https://github.com/puppetlabs/puppet-resource_api/pull/174) ([DavidS](https://github.com/DavidS))
|
|
@@ -106,18 +156,17 @@ All significant changes to this repo will be summarized in this file.
|
|
|
106
156
|
**Merged pull requests:**
|
|
107
157
|
|
|
108
158
|
- \(packaging\) Bump to 1.6.5 [\#196](https://github.com/puppetlabs/puppet-resource_api/pull/196) ([gimmyxd](https://github.com/gimmyxd))
|
|
109
|
-
- Merge 1.6.x [\#194](https://github.com/puppetlabs/puppet-resource_api/pull/194) ([da-ar](https://github.com/da-ar))
|
|
110
159
|
- \(maint\) test fixes [\#193](https://github.com/puppetlabs/puppet-resource_api/pull/193) ([DavidS](https://github.com/DavidS))
|
|
111
|
-
- \(packaging\) Revert to version '1.8.5' \[no-promote\] [\#192](https://github.com/puppetlabs/puppet-resource_api/pull/192) ([gimmyxd](https://github.com/gimmyxd))
|
|
112
|
-
- \(packaging\) Bump to version '1.9.0' \[no-promote\] [\#191](https://github.com/puppetlabs/puppet-resource_api/pull/191) ([gimmyxd](https://github.com/gimmyxd))
|
|
113
|
-
- \(maint\) retrofitting changelog for the last couple of releases [\#190](https://github.com/puppetlabs/puppet-resource_api/pull/190) ([DavidS](https://github.com/DavidS))
|
|
114
160
|
|
|
115
161
|
## [1.8.5](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.5) (2019-06-24)
|
|
162
|
+
|
|
116
163
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.4...1.8.5)
|
|
117
164
|
|
|
118
165
|
**Fixed bugs:**
|
|
119
166
|
|
|
120
167
|
- \(maint\) Mergeup 1.6.x: FM-7839, desc/docs cleanup [\#186](https://github.com/puppetlabs/puppet-resource_api/pull/186) ([DavidS](https://github.com/DavidS))
|
|
168
|
+
- \(maint\) backport minor fixes from master to 1.6.x [\#184](https://github.com/puppetlabs/puppet-resource_api/pull/184) ([DavidS](https://github.com/DavidS))
|
|
169
|
+
- \(maint\) implement `desc`/`docs` fallback [\#177](https://github.com/puppetlabs/puppet-resource_api/pull/177) ([DavidS](https://github.com/DavidS))
|
|
121
170
|
|
|
122
171
|
**Merged pull requests:**
|
|
123
172
|
|
|
@@ -127,18 +176,17 @@ All significant changes to this repo will be summarized in this file.
|
|
|
127
176
|
- \(maint\) make test order really random [\#175](https://github.com/puppetlabs/puppet-resource_api/pull/175) ([DavidS](https://github.com/DavidS))
|
|
128
177
|
|
|
129
178
|
## [1.8.4](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.4) (2019-06-12)
|
|
179
|
+
|
|
130
180
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.3...1.8.4)
|
|
131
181
|
|
|
132
182
|
**Implemented enhancements:**
|
|
133
183
|
|
|
134
|
-
- \(FM-7839\) Implement `
|
|
184
|
+
- \(FM-7839\) Implement `to_json` method for ResourceShim [\#168](https://github.com/puppetlabs/puppet-resource_api/pull/168) ([da-ar](https://github.com/da-ar))
|
|
135
185
|
|
|
136
186
|
**Fixed bugs:**
|
|
137
187
|
|
|
138
|
-
- \(maint\) backport minor fixes from master to 1.6.x [\#184](https://github.com/puppetlabs/puppet-resource_api/pull/184) ([DavidS](https://github.com/DavidS))
|
|
139
188
|
- \(PUP-9747\) Relax validation for bolt [\#182](https://github.com/puppetlabs/puppet-resource_api/pull/182) ([DavidS](https://github.com/DavidS))
|
|
140
189
|
- \(maint\) Add to\_hash function to resourceShim for compatibility [\#180](https://github.com/puppetlabs/puppet-resource_api/pull/180) ([da-ar](https://github.com/da-ar))
|
|
141
|
-
- \(maint\) implement `desc`/`docs` fallback [\#177](https://github.com/puppetlabs/puppet-resource_api/pull/177) ([DavidS](https://github.com/DavidS))
|
|
142
190
|
|
|
143
191
|
**Closed issues:**
|
|
144
192
|
|
|
@@ -152,6 +200,7 @@ All significant changes to this repo will be summarized in this file.
|
|
|
152
200
|
- \(packaging\) Update reported version to 1.8.4 \[no-promote\] [\#171](https://github.com/puppetlabs/puppet-resource_api/pull/171) ([gimmyxd](https://github.com/gimmyxd))
|
|
153
201
|
|
|
154
202
|
## [1.8.3](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.3) (2019-04-12)
|
|
203
|
+
|
|
155
204
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.2...1.8.3)
|
|
156
205
|
|
|
157
206
|
**Fixed bugs:**
|
|
@@ -163,30 +212,22 @@ All significant changes to this repo will be summarized in this file.
|
|
|
163
212
|
- \(PA-2496\) Bump version and remove v from version number [\#170](https://github.com/puppetlabs/puppet-resource_api/pull/170) ([mihaibuzgau](https://github.com/mihaibuzgau))
|
|
164
213
|
|
|
165
214
|
## [1.8.2](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.2) (2019-04-10)
|
|
215
|
+
|
|
166
216
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.6.4...1.8.2)
|
|
167
217
|
|
|
168
218
|
**Merged pull requests:**
|
|
169
219
|
|
|
170
220
|
- \(packaging\) Update reported version to 1.8.2 \[no-promote\] [\#167](https://github.com/puppetlabs/puppet-resource_api/pull/167) ([mihaibuzgau](https://github.com/mihaibuzgau))
|
|
221
|
+
- Add `implementations` to reserved bolt keywords [\#165](https://github.com/puppetlabs/puppet-resource_api/pull/165) ([DavidS](https://github.com/DavidS))
|
|
222
|
+
- Release prep for v1.8.1 [\#163](https://github.com/puppetlabs/puppet-resource_api/pull/163) ([DavidS](https://github.com/DavidS))
|
|
171
223
|
|
|
172
224
|
## [v1.6.4](https://github.com/puppetlabs/puppet-resource_api/tree/v1.6.4) (2019-03-25)
|
|
173
|
-
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.8.1...v1.6.4)
|
|
174
|
-
|
|
175
|
-
**Implemented enhancements:**
|
|
176
225
|
|
|
177
|
-
|
|
226
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.8.1...v1.6.4)
|
|
178
227
|
|
|
179
228
|
**Merged pull requests:**
|
|
180
229
|
|
|
181
|
-
- Add `implementations` to reserved bolt keywords [\#165](https://github.com/puppetlabs/puppet-resource_api/pull/165) ([DavidS](https://github.com/DavidS))
|
|
182
230
|
- \(MAINT\) Bump version [\#164](https://github.com/puppetlabs/puppet-resource_api/pull/164) ([sebastian-miclea](https://github.com/sebastian-miclea))
|
|
183
|
-
- Release prep for v1.8.1 [\#163](https://github.com/puppetlabs/puppet-resource_api/pull/163) ([DavidS](https://github.com/DavidS))
|
|
184
|
-
- 1.6.x mergeup [\#162](https://github.com/puppetlabs/puppet-resource_api/pull/162) ([DavidS](https://github.com/DavidS))
|
|
185
|
-
|
|
186
|
-
# Changelog
|
|
187
|
-
|
|
188
|
-
All significant changes to this repo will be summarized in this file.
|
|
189
|
-
|
|
190
231
|
|
|
191
232
|
## [v1.8.1](https://github.com/puppetlabs/puppet-resource_api/tree/v1.8.1) (2019-03-13)
|
|
192
233
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.8.0...v1.8.1)
|
|
@@ -598,4 +639,4 @@ All significant changes to this repo will be summarized in this file.
|
|
|
598
639
|
- Workaround missing report back from here to flush\(\) [\#1](https://github.com/puppetlabs/puppet-resource_api/pull/1) ([james-stocks](https://github.com/james-stocks))
|
|
599
640
|
|
|
600
641
|
|
|
601
|
-
\* *This
|
|
642
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
|
@@ -1,46 +1,66 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
4
4
|
|
|
5
5
|
# Specify your gem's dependencies in puppet-resource_api.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
8
|
group :tests do
|
|
9
|
-
gem '
|
|
10
|
-
gem 'rake', '~> 10.0'
|
|
9
|
+
gem 'CFPropertyList'
|
|
11
10
|
gem 'rspec', '~> 3.0'
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
gem 'simplecov-console'
|
|
12
|
+
|
|
13
|
+
# the test gems required for module testing
|
|
14
|
+
gem 'puppetlabs_spec_helper', '~> 3.0'
|
|
15
|
+
gem 'rspec-puppet'
|
|
16
|
+
|
|
17
|
+
# since the Resource API runs inside the puppetserver, test against the JRuby versions we ship
|
|
18
|
+
# these require special dependencies to have everything load properly
|
|
19
|
+
|
|
20
|
+
# `codecov` 0.1.17 introduced usage of %i[] which is not recognised by JRuby 1.7
|
|
21
|
+
if RUBY_PLATFORM == 'java' && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0')
|
|
22
|
+
gem 'codecov', '= 0.1.16'
|
|
23
|
+
else
|
|
24
|
+
gem 'codecov'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# `rake` dropped support for older versions of ruby a while back
|
|
28
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1.0')
|
|
29
|
+
gem 'rake', '11.3.0'
|
|
30
|
+
elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.0')
|
|
31
|
+
gem 'rake', '12.3.3'
|
|
32
|
+
else
|
|
33
|
+
gem 'rake', '~> 13.0'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# rubocop is special, as usual
|
|
14
37
|
if RUBY_PLATFORM == 'java'
|
|
15
38
|
# load a rubocop version that works on java for the Rakefile
|
|
16
39
|
gem 'parser', '2.3.3.1'
|
|
17
40
|
gem 'rubocop', '0.41.2'
|
|
18
|
-
# JRuby 1.7 does not like json 2.3.0, jruby 9.1.9.0 has RUBY_VERSION == '2.3.3'
|
|
19
|
-
gem 'json', '2.2.0' if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('2.3.0')
|
|
20
41
|
elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.0')
|
|
42
|
+
# rubocop 0.58 throws when testing against ruby 2.1, so pin to the latest version that works
|
|
21
43
|
gem 'rubocop', '0.57.2'
|
|
22
|
-
# the last version of parallel to support ruby 2.1
|
|
23
|
-
gem 'parallel', '1.13.0'
|
|
24
44
|
gem 'rubocop-rspec'
|
|
25
45
|
else
|
|
26
46
|
# 2.1-compatible analysis was dropped after version 0.58
|
|
27
47
|
# This needs to be removed once we drop puppet4 support.
|
|
28
48
|
gem 'rubocop', '~> 0.57.0'
|
|
29
49
|
gem 'rubocop-rspec'
|
|
30
|
-
# license_finder does not install on windows using older versions of rubygems.
|
|
31
|
-
# ruby 2.4 is confirmed working on appveyor.
|
|
32
|
-
gem 'license_finder' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0')
|
|
33
50
|
end
|
|
34
|
-
gem 'simplecov-console'
|
|
35
|
-
# the test gems required for module testing
|
|
36
|
-
gem 'puppetlabs_spec_helper', '~> 2.7'
|
|
37
|
-
gem 'rspec-puppet'
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
# JRuby 1.7 does not like json 2.3.0, jruby 9.1.9.0 has RUBY_VERSION == '2.3.3'
|
|
53
|
+
gem 'json', '2.2.0' if RUBY_PLATFORM == 'java' && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0')
|
|
54
|
+
# the last version of parallel to support ruby 2.1
|
|
55
|
+
gem 'parallel', '1.13.0' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.0')
|
|
56
|
+
|
|
57
|
+
# license_finder does not install on windows using older versions of rubygems.
|
|
58
|
+
# ruby 2.4 is confirmed working on appveyor and we only need to run it on the newest gemset anyways
|
|
59
|
+
gem 'license_finder' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0')
|
|
40
60
|
end
|
|
41
61
|
|
|
42
62
|
group :development do
|
|
43
|
-
gem 'github_changelog_generator', '~> 1.
|
|
63
|
+
gem 'github_changelog_generator', '~> 1.15' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')
|
|
44
64
|
gem 'pry-byebug'
|
|
45
65
|
end
|
|
46
66
|
|
data/HISTORY.md
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All significant changes to this repo will be summarized in this file.
|
|
4
|
-
|
|
5
|
-
|
|
6
1
|
## [v1.8.1](https://github.com/puppetlabs/puppet-resource_api/tree/v1.8.1) (2019-03-13)
|
|
7
2
|
[Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.8.0...v1.8.1)
|
|
8
3
|
|
data/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Puppet::ResourceApi [](https://travis-ci.org/puppetlabs/puppet-resource_api) [](https://ci.appveyor.com/project/puppetlabs/puppet-resource-api/branch/main) [](https://codecov.io/gh/puppetlabs/puppet-resource_api)
|
|
2
2
|
|
|
3
|
-
This is an implementation of the [Resource API specification](https://github.com/puppetlabs/puppet-specifications/blob/
|
|
3
|
+
This is an implementation of the [Resource API specification](https://github.com/puppetlabs/puppet-specifications/blob/main/language/resource-api/README.md).
|
|
4
4
|
|
|
5
5
|
Find a working example of a new-style providers in the [Palo Alto Firewall module](https://github.com/puppetlabs/puppetlabs-panos/):
|
|
6
|
-
* [Type](https://github.com/puppetlabs/puppetlabs-panos/blob/
|
|
7
|
-
* [Base provider](https://github.com/puppetlabs/puppetlabs-panos/blob/
|
|
8
|
-
* [Actual provider with validation and xml processing](https://github.com/puppetlabs/puppetlabs-panos/blob/
|
|
9
|
-
* [New unit tests](https://github.com/puppetlabs/puppetlabs-panos/blob/
|
|
6
|
+
* [Type](https://github.com/puppetlabs/puppetlabs-panos/blob/main/lib/puppet/type/panos_address.rb)
|
|
7
|
+
* [Base provider](https://github.com/puppetlabs/puppetlabs-panos/blob/main/lib/puppet/provider/panos_provider.rb)
|
|
8
|
+
* [Actual provider with validation and xml processing](https://github.com/puppetlabs/puppetlabs-panos/blob/main/lib/puppet/provider/panos_address/panos_address.rb)
|
|
9
|
+
* [New unit tests](https://github.com/puppetlabs/puppetlabs-panos/blob/main/spec/unit/puppet/provider/panos_provider_spec.rb) for 100% coverage.
|
|
10
10
|
|
|
11
11
|
## [Find the full Resource API documentation here](https://puppet.com/docs/puppet/latest/custom_resources.html)
|
|
12
12
|
|
data/appveyor.yml
CHANGED
|
@@ -6,9 +6,9 @@ branches:
|
|
|
6
6
|
|
|
7
7
|
environment:
|
|
8
8
|
matrix:
|
|
9
|
-
- RUBY_VERSION:
|
|
10
|
-
- PUPPET_GEM_VERSION: '~>
|
|
11
|
-
RUBY_VERSION:
|
|
9
|
+
- RUBY_VERSION: 25-x64
|
|
10
|
+
- PUPPET_GEM_VERSION: '~> 5.0'
|
|
11
|
+
RUBY_VERSION: 24-x64
|
|
12
12
|
|
|
13
13
|
install:
|
|
14
14
|
- set PATH=C:\Ruby%RUBY_VERSION%\bin;C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
|
data/contrib/pre-commit
CHANGED
data/docs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Resource API hands-on lab
|
|
2
2
|
|
|
3
|
-
The Resource API hands-on lab walks you through creating a native integration with Puppet. After
|
|
3
|
+
The Resource API hands-on lab walks you through creating a native integration with Puppet. After completing this lab, you will have a fully functioning module to manage Philips HUE lights.
|
|
4
4
|
|
|
5
5
|
>Note: These labs are intended for both new and experienced developers. If you have any feedback or suggestions for improvement, post it in the [issues section](https://github.com/puppetlabs/puppet-resource_api/issues).
|
|
6
6
|
|
|
@@ -6,7 +6,7 @@ To start, install Puppet Development Kit (PDK), which provides all the necessary
|
|
|
6
6
|
|
|
7
7
|
2. If you do not have a Philips HUE hub and bulbs available, you can download the [Hue-Emulator](https://github.com/SteveyO/Hue-Emulator/raw/master/HueEmulator-v0.8.jar). You need to have Java installed to run this.
|
|
8
8
|
|
|
9
|
-
3. To edit code, we recommend the cross-platform editor [
|
|
9
|
+
3. To edit code, we recommend the cross-platform editor [VS Code](https://code.visualstudio.com/download), with the [Ruby](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby) and [Puppet](https://marketplace.visualstudio.com/items?itemName=puppet.puppet-vscode) extensions. There are lots of other extensions that can help you with your development workflow.
|
|
10
10
|
|
|
11
11
|
4. Git is a version control system that helps you keep track of changes and collaborate with others. As we go through hands-on lab, we will show you some integrations with cloud services. If you have never used git before, ignore this and all related steps.
|
|
12
12
|
|
|
@@ -87,7 +87,7 @@ david@davids:~/tmp/hue$ git init
|
|
|
87
87
|
Initialized empty Git repository in ~/tmp/hue/.git/
|
|
88
88
|
david@davids:~/tmp/hue$ git add -A
|
|
89
89
|
david@davids:~/tmp/hue$ git commit -m 'initial commit'
|
|
90
|
-
[
|
|
90
|
+
[main (root-commit) 67951dd] initial commit
|
|
91
91
|
26 files changed, 887 insertions(+)
|
|
92
92
|
create mode 100644 .fixtures.yml
|
|
93
93
|
create mode 100644 .gitattributes
|
|
@@ -84,7 +84,7 @@ I, [2019-06-04T13:43:58.577944 #9390] INFO -- : Creating symlink from spec/fixt
|
|
|
84
84
|
david@davids:~/tmp/hue_workshop$
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
* `pdk new task` based on https://github.com/puppetlabs/puppetlabs-panos/blob/
|
|
87
|
+
* `pdk new task` based on https://github.com/puppetlabs/puppetlabs-panos/blob/main/tasks/apikey.rb
|
|
88
88
|
|
|
89
89
|
```
|
|
90
90
|
david@davids:~/tmp/hue_workshop$ pdk new task alarm
|
data/lib/puppet/resource_api.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'pathname'
|
|
2
4
|
require 'puppet/resource_api/data_type_handling'
|
|
3
5
|
require 'puppet/resource_api/glue'
|
|
@@ -123,6 +125,22 @@ module Puppet::ResourceApi
|
|
|
123
125
|
@rsapi_title
|
|
124
126
|
end
|
|
125
127
|
|
|
128
|
+
def rsapi_canonicalized_target_state
|
|
129
|
+
@rsapi_canonicalized_target_state ||= begin
|
|
130
|
+
# skip puppet's injected metaparams
|
|
131
|
+
actual_params = @parameters.select { |k, _v| type_definition.attributes.key? k }
|
|
132
|
+
target_state = Hash[actual_params.map { |k, v| [k, v.rs_value] }]
|
|
133
|
+
target_state = my_provider.canonicalize(context, [target_state]).first if type_definition.feature?('canonicalize')
|
|
134
|
+
target_state
|
|
135
|
+
end
|
|
136
|
+
@rsapi_canonicalized_target_state
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def rsapi_current_state
|
|
140
|
+
refresh_current_state unless @rsapi_current_state
|
|
141
|
+
@rsapi_current_state
|
|
142
|
+
end
|
|
143
|
+
|
|
126
144
|
def to_resource
|
|
127
145
|
to_resource_shim(super)
|
|
128
146
|
end
|
|
@@ -166,6 +184,21 @@ module Puppet::ResourceApi
|
|
|
166
184
|
raise_missing_params if @missing_params.any?
|
|
167
185
|
end
|
|
168
186
|
|
|
187
|
+
# If the custom_insync feature is specified but no insyncable attributes are included
|
|
188
|
+
# in the definition, add the hidden rsapi_custom_insync_trigger property.
|
|
189
|
+
# This property exists *only* to allow a resource without properties to still execute an
|
|
190
|
+
# insync check; there's no point in specifying it in a manifest as it can only have one
|
|
191
|
+
# value; it cannot be specified in a type definition as it should only exist in this case.
|
|
192
|
+
if type_definition.feature?('custom_insync') && type_definition.insyncable_attributes.empty?
|
|
193
|
+
custom_insync_trigger_options = {
|
|
194
|
+
type: 'Enum[do_not_specify_in_manifest]',
|
|
195
|
+
desc: 'A hidden property which enables a type with custom insync to perform an insync check without specifying any insyncable properties',
|
|
196
|
+
default: 'do_not_specify_in_manifest',
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type_definition.create_attribute_in(self, :rsapi_custom_insync_trigger, :newproperty, Puppet::ResourceApi::Property, custom_insync_trigger_options)
|
|
200
|
+
end
|
|
201
|
+
|
|
169
202
|
definition[:attributes].each do |name, options|
|
|
170
203
|
# puts "#{name}: #{options.inspect}"
|
|
171
204
|
|
|
@@ -189,43 +222,7 @@ module Puppet::ResourceApi
|
|
|
189
222
|
parent = Puppet::ResourceApi::Property
|
|
190
223
|
end
|
|
191
224
|
|
|
192
|
-
|
|
193
|
-
# customizations required by the Resource API applied. Under the hood,
|
|
194
|
-
# this maps to the relevant DSL methods in Puppet::Type. See
|
|
195
|
-
# https://puppet.com/docs/puppet/6.0/custom_types.html#reference-5883
|
|
196
|
-
# for details.
|
|
197
|
-
send(param_or_property, name.to_sym, parent: parent) do
|
|
198
|
-
if options[:desc]
|
|
199
|
-
desc "#{options[:desc]} (a #{options[:type]})"
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
# The initialize method is called when puppet core starts building up
|
|
203
|
-
# type objects. The core passes in a hash of shape { resource:
|
|
204
|
-
# #<Puppet::Type::TypeName> }. We use this to pass through the
|
|
205
|
-
# required configuration data to the parent (see
|
|
206
|
-
# Puppet::ResourceApi::Property, Puppet::ResourceApi::Parameter and
|
|
207
|
-
# Puppet::ResourceApi::ReadOnlyParameter).
|
|
208
|
-
define_method(:initialize) do |resource_hash|
|
|
209
|
-
super(definition[:name], self.class.data_type, name, resource_hash)
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# get pops data type object for this parameter or property
|
|
213
|
-
define_singleton_method(:data_type) do
|
|
214
|
-
@rsapi_data_type ||= Puppet::ResourceApi::DataTypeHandling.parse_puppet_type(
|
|
215
|
-
name,
|
|
216
|
-
options[:type],
|
|
217
|
-
)
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
# from ValueCreator call create_values which makes alias values and
|
|
221
|
-
# default values for properties and params
|
|
222
|
-
Puppet::ResourceApi::ValueCreator.create_values(
|
|
223
|
-
self,
|
|
224
|
-
data_type,
|
|
225
|
-
param_or_property,
|
|
226
|
-
options,
|
|
227
|
-
)
|
|
228
|
-
end
|
|
225
|
+
type_definition.create_attribute_in(self, name, param_or_property, parent, options)
|
|
229
226
|
end
|
|
230
227
|
|
|
231
228
|
def self.instances
|
|
@@ -279,11 +276,9 @@ module Puppet::ResourceApi
|
|
|
279
276
|
end
|
|
280
277
|
|
|
281
278
|
def retrieve
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
Puppet.debug("Current State: #{@rsapi_current_state.inspect}")
|
|
279
|
+
Puppet.debug("Current State: #{rsapi_current_state.inspect}")
|
|
285
280
|
|
|
286
|
-
result = Puppet::Resource.new(self.class, title, parameters:
|
|
281
|
+
result = Puppet::Resource.new(self.class, title, parameters: rsapi_current_state)
|
|
287
282
|
# puppet needs ensure to be a symbol
|
|
288
283
|
result[:ensure] = result[:ensure].to_sym if type_definition.ensurable? && result[:ensure].is_a?(String)
|
|
289
284
|
|
|
@@ -302,10 +297,7 @@ module Puppet::ResourceApi
|
|
|
302
297
|
raise_missing_attrs
|
|
303
298
|
|
|
304
299
|
# puts 'flush'
|
|
305
|
-
|
|
306
|
-
actual_params = @parameters.select { |k, _v| type_definition.attributes.key? k }
|
|
307
|
-
target_state = Hash[actual_params.map { |k, v| [k, v.rs_value] }]
|
|
308
|
-
target_state = my_provider.canonicalize(context, [target_state]).first if type_definition.feature?('canonicalize')
|
|
300
|
+
target_state = rsapi_canonicalized_target_state
|
|
309
301
|
|
|
310
302
|
retrieve unless @rsapi_current_state
|
|
311
303
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'yaml'
|
|
2
4
|
|
|
3
5
|
module Puppet; end # rubocop:disable Style/Documentation
|
|
@@ -35,6 +37,11 @@ module Puppet::ResourceApi
|
|
|
35
37
|
end + ['}']).compact.join("\n")
|
|
36
38
|
end
|
|
37
39
|
|
|
40
|
+
# Required to enable `puppet device --resource ... --to_yaml` workflow
|
|
41
|
+
def to_hiera_hash
|
|
42
|
+
to_hierayaml
|
|
43
|
+
end
|
|
44
|
+
|
|
38
45
|
# Convert our resource to yaml for Hiera purposes.
|
|
39
46
|
def to_hierayaml
|
|
40
47
|
attributes = Hash[filtered_keys.map { |k| [k.to_s, values[k]] }]
|
|
@@ -52,9 +59,9 @@ module Puppet::ResourceApi
|
|
|
52
59
|
values
|
|
53
60
|
end
|
|
54
61
|
|
|
55
|
-
# attribute names that are not title or
|
|
62
|
+
# attribute names that are not title, namevars, or rsapi_custom_insync_trigger
|
|
56
63
|
def filtered_keys
|
|
57
|
-
values.keys.reject { |k| k == :title || !attr_def[k] || (attr_def[k][:behaviour] == :namevar && @namevars.size == 1) }
|
|
64
|
+
values.keys.reject { |k| k == :title || k == :rsapi_custom_insync_trigger || !attr_def[k] || (attr_def[k][:behaviour] == :namevar && @namevars.size == 1) }
|
|
58
65
|
end
|
|
59
66
|
end
|
|
60
67
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'puppet/util'
|
|
2
4
|
require 'puppet/parameter'
|
|
3
5
|
|
|
@@ -13,11 +15,11 @@ class Puppet::ResourceApi::Parameter < Puppet::Parameter
|
|
|
13
15
|
# @param attribute_name the name of attribue of the parameter
|
|
14
16
|
# @param resource_hash the resource hash instance which is passed to the
|
|
15
17
|
# parent class.
|
|
16
|
-
def initialize(type_name, data_type, attribute_name, resource_hash)
|
|
18
|
+
def initialize(type_name, data_type, attribute_name, resource_hash, _referrable_type = nil)
|
|
17
19
|
@type_name = type_name
|
|
18
20
|
@data_type = data_type
|
|
19
21
|
@attribute_name = attribute_name
|
|
20
|
-
super(resource_hash) # Pass resource to parent Puppet class.
|
|
22
|
+
super(**resource_hash) # Pass resource to parent Puppet class.
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
# This method assigns value to the parameter and cleans value.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'puppet/util'
|
|
2
4
|
require 'puppet/property'
|
|
3
5
|
|
|
@@ -11,14 +13,31 @@ class Puppet::ResourceApi::Property < Puppet::Property
|
|
|
11
13
|
# @param attribute_name the name of attribue of the property
|
|
12
14
|
# @param resource_hash the resource hash instance which is passed to the
|
|
13
15
|
# parent class.
|
|
14
|
-
def initialize(type_name, data_type, attribute_name, resource_hash)
|
|
16
|
+
def initialize(type_name, data_type, attribute_name, resource_hash, referrable_type = nil)
|
|
15
17
|
@type_name = type_name
|
|
16
18
|
@data_type = data_type
|
|
17
19
|
@attribute_name = attribute_name
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
@resource = resource_hash[:resource]
|
|
21
|
+
@referrable_type = referrable_type
|
|
22
|
+
|
|
23
|
+
# Do not want to define insync on the base class because
|
|
24
|
+
# this overrides for everything instead of only for the
|
|
25
|
+
# appropriate instance/class of the property.
|
|
26
|
+
if self.class != Puppet::ResourceApi::Property
|
|
27
|
+
# Define class method insync?(is) if the custom_insync feature flag is set
|
|
28
|
+
if referrable_type&.type_definition&.feature?('custom_insync')
|
|
29
|
+
def_custom_insync?
|
|
30
|
+
if @attribute_name == :rsapi_custom_insync_trigger
|
|
31
|
+
@change_to_s_value = 'Custom insync logic determined that this resource is out of sync'
|
|
32
|
+
end
|
|
33
|
+
# Define class method insync?(is) if the name is :ensure and custom_insync feature flag is not set
|
|
34
|
+
elsif @attribute_name == :ensure
|
|
35
|
+
def_ensure_insync?
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
20
39
|
# Pass resource to parent Puppet class.
|
|
21
|
-
super(resource_hash)
|
|
40
|
+
super(**resource_hash)
|
|
22
41
|
end
|
|
23
42
|
|
|
24
43
|
# This method returns value of the property.
|
|
@@ -69,10 +88,51 @@ class Puppet::ResourceApi::Property < Puppet::Property
|
|
|
69
88
|
# method overloaded only for the :ensure property, add option to check if the
|
|
70
89
|
# rs_value matches is. Only if the class is child of
|
|
71
90
|
# Puppet::ResourceApi::Property.
|
|
72
|
-
def
|
|
91
|
+
def def_ensure_insync?
|
|
73
92
|
define_singleton_method(:insync?) { |is| rs_value.to_s == is.to_s }
|
|
74
93
|
end
|
|
75
94
|
|
|
95
|
+
def def_custom_insync?
|
|
96
|
+
define_singleton_method(:insync?) do |is|
|
|
97
|
+
provider = @referrable_type.my_provider
|
|
98
|
+
context = @referrable_type.context
|
|
99
|
+
should_hash = @resource.rsapi_canonicalized_target_state
|
|
100
|
+
is_hash = @resource.rsapi_current_state
|
|
101
|
+
title = @resource.rsapi_title
|
|
102
|
+
|
|
103
|
+
raise(Puppet::DevError, 'No insync? method defined in the provider; an insync? method must be defined if the custom_insync feature is defined for the type') unless provider.respond_to?(:insync?)
|
|
104
|
+
|
|
105
|
+
provider_insync_result, change_message = provider.insync?(context, title, @attribute_name, is_hash, should_hash)
|
|
106
|
+
|
|
107
|
+
unless provider_insync_result.nil? || change_message.nil? || change_message.empty?
|
|
108
|
+
@change_to_s_value = change_message
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
case provider_insync_result
|
|
112
|
+
when nil
|
|
113
|
+
# If validating ensure and no custom insync was used, check if rs_value matches is.
|
|
114
|
+
return rs_value.to_s == is.to_s if @attribute_name == :ensure
|
|
115
|
+
# Otherwise, super and rely on Puppet::Property.insync?
|
|
116
|
+
super(is)
|
|
117
|
+
when TrueClass, FalseClass
|
|
118
|
+
return provider_insync_result
|
|
119
|
+
else
|
|
120
|
+
# When returning anything else, raise a DevError for a non-idiomatic return
|
|
121
|
+
raise(Puppet::DevError, "Custom insync for #{@attribute_name} returned a #{provider_insync_result.class} with a value of #{provider_insync_result.inspect} instead of true/false; insync? MUST return nil or the boolean true or false") # rubocop:disable Metrics/LineLength
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
define_singleton_method(:change_to_s) do |current_value, newvalue|
|
|
126
|
+
# As defined in the custom insync? method, it is sometimes useful to overwrite the default change messaging;
|
|
127
|
+
# The enables a user to return a more useful change report than a strict "is to should" report.
|
|
128
|
+
# If @change_to_s_value is not set, Puppet writes a generic change notification, like:
|
|
129
|
+
# Notice: /Stage[main]/Main/<type_name>[<name_hash>]/<property name>: <property name> changed <is value> to <should value>
|
|
130
|
+
# If #change_to_s_value is *nil* Puppet writes a weird empty message like:
|
|
131
|
+
# Notice: /Stage[main]/Main/<type_name>[<name_hash>]/<property name>:
|
|
132
|
+
@change_to_s_value || super(current_value, newvalue)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
76
136
|
# puppet symbolizes some values through puppet/parameter/value.rb
|
|
77
137
|
# (see .convert()), but (especially) Enums are strings. specifying a
|
|
78
138
|
# munge block here skips the value_collection fallback in
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Provides accessor methods for the type being provided
|
|
2
4
|
module Puppet::ResourceApi
|
|
3
5
|
# pre-declare class
|
|
@@ -15,7 +17,7 @@ module Puppet::ResourceApi
|
|
|
15
17
|
|
|
16
18
|
# rubocop complains when this is named has_feature?
|
|
17
19
|
def feature?(feature)
|
|
18
|
-
|
|
20
|
+
definition[:features]&.include?(feature)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def title_patterns
|
|
@@ -34,10 +36,56 @@ module Puppet::ResourceApi
|
|
|
34
36
|
Puppet::ResourceApi::DataTypeHandling.validate_ensure(definition)
|
|
35
37
|
|
|
36
38
|
definition[:features] ||= []
|
|
37
|
-
supported_features = %w[supports_noop canonicalize remote_resource simple_get_filter].freeze
|
|
39
|
+
supported_features = %w[supports_noop canonicalize custom_insync remote_resource simple_get_filter].freeze
|
|
38
40
|
unknown_features = definition[:features] - supported_features
|
|
39
41
|
Puppet.warning("Unknown feature detected: #{unknown_features.inspect}") unless unknown_features.empty?
|
|
40
42
|
end
|
|
43
|
+
|
|
44
|
+
# This call creates a new parameter or property with all work-arounds or
|
|
45
|
+
# customizations required by the Resource API applied. Under the hood,
|
|
46
|
+
# this maps to the relevant DSL methods in Puppet::Type. See
|
|
47
|
+
# https://puppet.com/docs/puppet/6.0/custom_types.html#reference-5883
|
|
48
|
+
# for details.
|
|
49
|
+
#
|
|
50
|
+
# type: the Resource API Type the attribute is being created in
|
|
51
|
+
# attribute_name: the name of the attribute being created
|
|
52
|
+
# param_or_property: Whether to call the :newparam or :newproperty method
|
|
53
|
+
# parent: The type of attribute to create: Property, ReadOnly, or Parameter
|
|
54
|
+
# options: The hash of attribute options, including type, desc, default, and behaviour
|
|
55
|
+
def create_attribute_in(type, attribute_name, param_or_property, parent, options)
|
|
56
|
+
type.send(param_or_property, attribute_name.to_sym, parent: parent) do
|
|
57
|
+
if options[:desc]
|
|
58
|
+
desc "#{options[:desc]} (a #{options[:type]})"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# The initialize method is called when puppet core starts building up
|
|
62
|
+
# type objects. The core passes in a hash of shape { resource:
|
|
63
|
+
# #<Puppet::Type::TypeName> }. We use this to pass through the
|
|
64
|
+
# required configuration data to the parent (see
|
|
65
|
+
# Puppet::ResourceApi::Property, Puppet::ResourceApi::Parameter and
|
|
66
|
+
# Puppet::ResourceApi::ReadOnlyParameter).
|
|
67
|
+
define_method(:initialize) do |resource_hash|
|
|
68
|
+
super(type.name, self.class.data_type, attribute_name, resource_hash, type)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# get pops data type object for this parameter or property
|
|
72
|
+
define_singleton_method(:data_type) do
|
|
73
|
+
@rsapi_data_type ||= Puppet::ResourceApi::DataTypeHandling.parse_puppet_type(
|
|
74
|
+
attribute_name,
|
|
75
|
+
options[:type],
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# from ValueCreator call create_values which makes alias values and
|
|
80
|
+
# default values for properties and params
|
|
81
|
+
Puppet::ResourceApi::ValueCreator.create_values(
|
|
82
|
+
self,
|
|
83
|
+
data_type,
|
|
84
|
+
param_or_property,
|
|
85
|
+
options,
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
41
89
|
end
|
|
42
90
|
|
|
43
91
|
# RSAPI Transport schema
|
|
@@ -88,6 +136,13 @@ module Puppet::ResourceApi
|
|
|
88
136
|
}.keys
|
|
89
137
|
end
|
|
90
138
|
|
|
139
|
+
def insyncable_attributes
|
|
140
|
+
@insyncable_attributes ||= attributes.reject { |_name, options|
|
|
141
|
+
# Only attributes without any behavior are normal Puppet Properties and get insynced
|
|
142
|
+
options.key?(:behaviour)
|
|
143
|
+
}.keys
|
|
144
|
+
end
|
|
145
|
+
|
|
91
146
|
def validate_schema(definition, attr_key)
|
|
92
147
|
raise Puppet::DevError, '%{type_class} must be a Hash, not `%{other_type}`' % { type_class: self.class.name, other_type: definition.class } unless definition.is_a?(Hash)
|
|
93
148
|
@attributes = definition[attr_key]
|
|
@@ -110,6 +165,7 @@ module Puppet::ResourceApi
|
|
|
110
165
|
Puppet.warning('`%{name}` has no documentation, add it using a `desc` key' % { name: definition[:name] }) unless definition.key? :desc
|
|
111
166
|
|
|
112
167
|
attributes.each do |key, attr|
|
|
168
|
+
raise Puppet::DevError, '`rsapi_custom_insync_trigger` cannot be specified as an attribute; it is reserved for propertyless types with the custom_insync feature' if key == :rsapi_custom_insync_trigger # rubocop:disable Metrics/LineLength
|
|
113
169
|
raise Puppet::DevError, "`#{definition[:name]}.#{key}` must be a Hash, not a #{attr.class}" unless attr.is_a? Hash
|
|
114
170
|
raise Puppet::DevError, "`#{definition[:name]}.#{key}` has no type" unless attr.key? :type
|
|
115
171
|
Puppet.warning('`%{name}.%{key}` has no documentation, add it using a `desc` key' % { name: definition[:name], key: key }) unless attr.key? :desc
|
|
@@ -194,7 +250,7 @@ module Puppet::ResourceApi
|
|
|
194
250
|
if is_sensitive
|
|
195
251
|
bad_vals[key] = '<< redacted value >> ' + error_message unless error_message.nil?
|
|
196
252
|
else
|
|
197
|
-
bad_vals[key] = value unless error_message.nil?
|
|
253
|
+
bad_vals[key] = "#{value} (#{error_message})" unless error_message.nil?
|
|
198
254
|
end
|
|
199
255
|
end
|
|
200
256
|
bad_vals
|
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.8.
|
|
4
|
+
version: 1.8.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Schmitt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hocon
|
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
|
33
33
|
files:
|
|
34
34
|
- ".dependency_decisions.yml"
|
|
35
35
|
- ".fixtures.yml"
|
|
36
|
+
- ".github/dependabot.yml"
|
|
36
37
|
- ".gitignore"
|
|
37
38
|
- ".rspec"
|
|
38
39
|
- ".rubocop.yml"
|
|
@@ -99,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
100
|
- !ruby/object:Gem::Version
|
|
100
101
|
version: '0'
|
|
101
102
|
requirements: []
|
|
102
|
-
rubygems_version: 3.
|
|
103
|
+
rubygems_version: 3.2.5
|
|
103
104
|
signing_key:
|
|
104
105
|
specification_version: 4
|
|
105
106
|
summary: This library provides a simple way to write new native resources for puppet.
|