puppet-resource_api 1.8.13 → 1.8.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +94 -25
  3. data/README.md +9 -9
  4. data/docs/README.md +1 -1
  5. data/docs/hands-on-lab/01-installing-prereqs.md +1 -1
  6. data/docs/hands-on-lab/04-adding-a-new-transport.md +1 -1
  7. data/docs/hands-on-lab/07-implementing-a-task.md +1 -1
  8. data/lib/puppet/resource_api/base_context.rb +3 -1
  9. data/lib/puppet/resource_api/data_type_handling.rb +11 -2
  10. data/lib/puppet/resource_api/glue.rb +9 -2
  11. data/lib/puppet/resource_api/io_context.rb +2 -0
  12. data/lib/puppet/resource_api/parameter.rb +4 -2
  13. data/lib/puppet/resource_api/property.rb +65 -5
  14. data/lib/puppet/resource_api/puppet_context.rb +2 -0
  15. data/lib/puppet/resource_api/read_only_parameter.rb +2 -0
  16. data/lib/puppet/resource_api/simple_provider.rb +6 -4
  17. data/lib/puppet/resource_api/transport/wrapper.rb +2 -0
  18. data/lib/puppet/resource_api/transport.rb +15 -0
  19. data/lib/puppet/resource_api/type_definition.rb +59 -3
  20. data/lib/puppet/resource_api/value_creator.rb +2 -0
  21. data/lib/puppet/resource_api/version.rb +3 -1
  22. data/lib/puppet/resource_api.rb +41 -46
  23. data/lib/puppet/util/network_device/simple/device.rb +2 -0
  24. data/puppet-resource_api.gemspec +7 -8
  25. metadata +3 -19
  26. data/.dependency_decisions.yml +0 -98
  27. data/.fixtures.yml +0 -8
  28. data/.gitignore +0 -15
  29. data/.rspec +0 -3
  30. data/.rubocop.yml +0 -159
  31. data/.travis.yml +0 -79
  32. data/CODEOWNERS +0 -2
  33. data/Gemfile +0 -61
  34. data/HISTORY.md +0 -413
  35. data/Rakefile +0 -66
  36. data/appveyor.yml +0 -41
  37. data/bin/console +0 -14
  38. data/bin/setup +0 -8
  39. data/codecov.yml +0 -3
  40. data/contrib/README.md +0 -7
  41. data/contrib/pre-commit +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5413e02d045402f7d15951366174c814df1c910853b7496666ff118cb5ec0be1
4
- data.tar.gz: c08cf96dc16809a09c25240c7566cebf96e0e5dc2c012e34bb81e3e2b3f45ec9
3
+ metadata.gz: 3c0c670133fdc323f0924bf231fd59eb1d07f27ef17919b853275d0fb7cf0104
4
+ data.tar.gz: f99601ad94f6d186d981efbc7b5b4ca77bc3b599ad8b8093aa669bf7454112b0
5
5
  SHA512:
6
- metadata.gz: ed1d3489b89572098e0295ec6b18cc5806d6baca319bde52e3f2b6727af965ec304ca25828c0de902cb5ee8c2b400bd06c0ef824d81b0697328676503d712034
7
- data.tar.gz: 86cefc9bd04982603b80e15217a2074c45dc1e8c462e886bd403d16dcf8e08282e1e82aac2dfeadcc9459c4fae1e5c66e60379d909428a01172ece42a04b8d57
6
+ metadata.gz: 6ca81ef748e1ec292255f775922c68664360d59590c677da0cdc19fb001ea703ff89d924018e26a24234c2aebe2e3cdee2cd54250e6646daae1785f14c53df5f
7
+ data.tar.gz: 143368873f583691dd5afe77e96a64008b8565eb5e1d5820b5a3c549c00954b647afa5ca67e8245c2cca7facd76288f35df91e4def3690d1e06bef5058af5c21
data/CHANGELOG.md CHANGED
@@ -3,6 +3,75 @@
3
3
  All significant changes to this repo will be summarized in this file.
4
4
 
5
5
 
6
+ ## [1.8.18](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.18) (2023-07-17)
7
+
8
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.16...1.8.18)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - \(PA-5641\) Add release job via PR [\#321](https://github.com/puppetlabs/puppet-resource_api/pull/321) [\#322](https://github.com/puppetlabs/puppet-resource_api/pull/322) [\#323](https://github.com/puppetlabs/puppet-resource_api/pull/323) ([tvpartytonight](https://github.com/tvpartytonight))
13
+ - Remove old Ruby logic from Gemfile [\#320](https://github.com/puppetlabs/puppet-resource_api/pull/320) ([mhashizume](https://github.com/mhashizume))
14
+ - \(PA-4639\) Migrate away from AppVeyor [\#319](https://github.com/puppetlabs/puppet-resource_api/pull/319) ([mhashizume](https://github.com/mhashizume))
15
+ - Don't require git [\#318](https://github.com/puppetlabs/puppet-resource_api/pull/318) ([joshcooper](https://github.com/joshcooper))
16
+ - \(PA-5641\) Update rspec tests with modern Ruby [\#317](https://github.com/puppetlabs/puppet-resource_api/pull/317) ([mhashizume](https://github.com/mhashizume))
17
+ - Update to Mend [\#311](https://github.com/puppetlabs/puppet-resource_api/pull/311) ([cthorn42](https://github.com/cthorn42))
18
+
19
+ ## [1.8.16](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.16) (2022-10-03)
20
+
21
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.14...1.8.16)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - \(PA-4558\) Replaces Travis CI with GitHub Actions [\#298](https://github.com/puppetlabs/puppet-resource_api/pull/298) ([mhashizume](https://github.com/mhashizume))
26
+ - Add snyk monitoring [\#297](https://github.com/puppetlabs/puppet-resource_api/pull/297) ([joshcooper](https://github.com/joshcooper))
27
+ - \(packaging\) Sets version to 1.8.15 for release [\#296](https://github.com/puppetlabs/puppet-resource_api/pull/296) ([mhashizume](https://github.com/mhashizume))
28
+ - Update CODEOWNERS [\#295](https://github.com/puppetlabs/puppet-resource_api/pull/295) ([binford2k](https://github.com/binford2k))
29
+ - Add array support to autorequire variable expansion [\#294](https://github.com/puppetlabs/puppet-resource_api/pull/294) ([seanmil](https://github.com/seanmil))
30
+ - \(GH-231\) Add default to transport attributes [\#293](https://github.com/puppetlabs/puppet-resource_api/pull/293) ([seanmil](https://github.com/seanmil))
31
+ - Support ensure parameter with Optional data type [\#292](https://github.com/puppetlabs/puppet-resource_api/pull/292) ([seanmil](https://github.com/seanmil))
32
+ - Only ship needed files [\#289](https://github.com/puppetlabs/puppet-resource_api/pull/289) ([ekohl](https://github.com/ekohl))
33
+
34
+ ## [1.8.14](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.14) (2021-06-09)
35
+
36
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.13...1.8.14)
37
+
38
+ **Implemented enhancements:**
39
+
40
+ - \(GH-225\) Add support for custom insync [\#285](https://github.com/puppetlabs/puppet-resource_api/pull/285) ([michaeltlombardi](https://github.com/michaeltlombardi))
41
+ - Improve type validation error messages to show expected types [\#279](https://github.com/puppetlabs/puppet-resource_api/pull/279) ([timidri](https://github.com/timidri))
42
+ - 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))
43
+
44
+ **Fixed bugs:**
45
+
46
+ - Git tag 1.8.13 exists, but missing on rubygems.org / in CHANGELOG.md [\#266](https://github.com/puppetlabs/puppet-resource_api/issues/266)
47
+
48
+ **Closed issues:**
49
+
50
+ - CHANGELOG.md entries are missing for latest releases? [\#258](https://github.com/puppetlabs/puppet-resource_api/issues/258)
51
+
52
+ **Merged pull requests:**
53
+
54
+ - Upgrade to GitHub-native Dependabot [\#287](https://github.com/puppetlabs/puppet-resource_api/pull/287) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
55
+ - \(IAC-1455\) - Removal of Inappropriate Terminology [\#283](https://github.com/puppetlabs/puppet-resource_api/pull/283) ([david22swan](https://github.com/david22swan))
56
+ - 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))
57
+ - \(maint\) Update Puppet VS Code Extension ID [\#277](https://github.com/puppetlabs/puppet-resource_api/pull/277) ([jpogran](https://github.com/jpogran))
58
+ - \(IAC-859\) Add ruby 2.7 to test matrix [\#276](https://github.com/puppetlabs/puppet-resource_api/pull/276) ([DavidS](https://github.com/DavidS))
59
+ - \(maint\) Cleanup gemfile and fix codecov dependency [\#275](https://github.com/puppetlabs/puppet-resource_api/pull/275) ([DavidS](https://github.com/DavidS))
60
+ - Language correction [\#270](https://github.com/puppetlabs/puppet-resource_api/pull/270) ([epackorigan](https://github.com/epackorigan))
61
+ - \(maint\) Update CHANGELOG [\#268](https://github.com/puppetlabs/puppet-resource_api/pull/268) ([DavidS](https://github.com/DavidS))
62
+ - \(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))
63
+ - \(maint\) Mock Hocon.load\(...\) [\#263](https://github.com/puppetlabs/puppet-resource_api/pull/263) ([BogdanIrimie](https://github.com/BogdanIrimie))
64
+ - 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))
65
+ - \(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))
66
+
67
+ ## [1.8.13](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.13) (2020-02-19)
68
+
69
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.12...1.8.13)
70
+
71
+ **Merged pull requests:**
72
+
73
+ - \(IAC-274\) update CHANGELOG [\#259](https://github.com/puppetlabs/puppet-resource_api/pull/259) ([DavidS](https://github.com/DavidS))
74
+
6
75
  ## [1.8.12](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.12) (2020-02-03)
7
76
 
8
77
  [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.11...1.8.12)
@@ -48,7 +117,7 @@ All significant changes to this repo will be summarized in this file.
48
117
 
49
118
  **Merged pull requests:**
50
119
 
51
- - \(FM-8740\): Documentation tweaks based on most recent walkthrough [\#246](https://github.com/puppetlabs/puppet-resource_api/pull/246) ([cmccrisken-puppet](https://github.com/cmccrisken-puppet))
120
+ - \(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
121
 
53
122
  ## [1.8.9](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.9) (2019-10-03)
54
123
 
@@ -86,19 +155,28 @@ All significant changes to this repo will be summarized in this file.
86
155
  **Merged pull requests:**
87
156
 
88
157
  - \(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) ([MaxMagill](https://github.com/MaxMagill))
158
+ - \(MODULES-9258\) Improve referencing and add summary [\#199](https://github.com/puppetlabs/puppet-resource_api/pull/199) ([maxiegit](https://github.com/maxiegit))
90
159
  - \(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
160
 
92
161
  ## [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
162
 
95
- ## [1.6.5](https://github.com/puppetlabs/puppet-resource_api/tree/1.6.5) (2019-07-04)
96
- [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.5...1.6.5)
163
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.6.5...1.8.6)
97
164
 
98
165
  **Implemented enhancements:**
99
166
 
100
167
  - \(SERVER-2470\) list\_all\_transports implementation for puppetserver [\#187](https://github.com/puppetlabs/puppet-resource_api/pull/187) ([DavidS](https://github.com/DavidS))
101
168
 
169
+ **Merged pull requests:**
170
+
171
+ - Merge 1.6.x [\#194](https://github.com/puppetlabs/puppet-resource_api/pull/194) ([da-ar](https://github.com/da-ar))
172
+ - \(packaging\) Revert to version '1.8.5' \[no-promote\] [\#192](https://github.com/puppetlabs/puppet-resource_api/pull/192) ([gimmyxd](https://github.com/gimmyxd))
173
+ - \(packaging\) Bump to version '1.9.0' \[no-promote\] [\#191](https://github.com/puppetlabs/puppet-resource_api/pull/191) ([gimmyxd](https://github.com/gimmyxd))
174
+ - \(maint\) retrofitting changelog for the last couple of releases [\#190](https://github.com/puppetlabs/puppet-resource_api/pull/190) ([DavidS](https://github.com/DavidS))
175
+
176
+ ## [1.6.5](https://github.com/puppetlabs/puppet-resource_api/tree/1.6.5) (2019-07-04)
177
+
178
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.5...1.6.5)
179
+
102
180
  **Fixed bugs:**
103
181
 
104
182
  - \(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 +184,17 @@ All significant changes to this repo will be summarized in this file.
106
184
  **Merged pull requests:**
107
185
 
108
186
  - \(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
187
  - \(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
188
 
115
189
  ## [1.8.5](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.5) (2019-06-24)
190
+
116
191
  [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.4...1.8.5)
117
192
 
118
193
  **Fixed bugs:**
119
194
 
120
195
  - \(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))
196
+ - \(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))
197
+ - \(maint\) implement `desc`/`docs` fallback [\#177](https://github.com/puppetlabs/puppet-resource_api/pull/177) ([DavidS](https://github.com/DavidS))
121
198
 
122
199
  **Merged pull requests:**
123
200
 
@@ -127,18 +204,17 @@ All significant changes to this repo will be summarized in this file.
127
204
  - \(maint\) make test order really random [\#175](https://github.com/puppetlabs/puppet-resource_api/pull/175) ([DavidS](https://github.com/DavidS))
128
205
 
129
206
  ## [1.8.4](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.4) (2019-06-12)
207
+
130
208
  [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.3...1.8.4)
131
209
 
132
210
  **Implemented enhancements:**
133
211
 
134
- - \(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))
212
+ - \(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
213
 
136
214
  **Fixed bugs:**
137
215
 
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
216
  - \(PUP-9747\) Relax validation for bolt [\#182](https://github.com/puppetlabs/puppet-resource_api/pull/182) ([DavidS](https://github.com/DavidS))
140
217
  - \(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
218
 
143
219
  **Closed issues:**
144
220
 
@@ -152,6 +228,7 @@ All significant changes to this repo will be summarized in this file.
152
228
  - \(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
229
 
154
230
  ## [1.8.3](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.3) (2019-04-12)
231
+
155
232
  [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/1.8.2...1.8.3)
156
233
 
157
234
  **Fixed bugs:**
@@ -163,30 +240,22 @@ All significant changes to this repo will be summarized in this file.
163
240
  - \(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
241
 
165
242
  ## [1.8.2](https://github.com/puppetlabs/puppet-resource_api/tree/1.8.2) (2019-04-10)
243
+
166
244
  [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.6.4...1.8.2)
167
245
 
168
246
  **Merged pull requests:**
169
247
 
170
248
  - \(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))
249
+ - Add `implementations` to reserved bolt keywords [\#165](https://github.com/puppetlabs/puppet-resource_api/pull/165) ([DavidS](https://github.com/DavidS))
250
+ - Release prep for v1.8.1 [\#163](https://github.com/puppetlabs/puppet-resource_api/pull/163) ([DavidS](https://github.com/DavidS))
171
251
 
172
252
  ## [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
253
 
175
- **Implemented enhancements:**
176
-
177
- - \(PDK-1271\) Allow a transport to be wrapped and used like a device [\#155](https://github.com/puppetlabs/puppet-resource_api/pull/155) ([da-ar](https://github.com/da-ar))
254
+ [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.8.1...v1.6.4)
178
255
 
179
256
  **Merged pull requests:**
180
257
 
181
- - Add `implementations` to reserved bolt keywords [\#165](https://github.com/puppetlabs/puppet-resource_api/pull/165) ([DavidS](https://github.com/DavidS))
182
258
  - \(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
259
 
191
260
  ## [v1.8.1](https://github.com/puppetlabs/puppet-resource_api/tree/v1.8.1) (2019-03-13)
192
261
  [Full Changelog](https://github.com/puppetlabs/puppet-resource_api/compare/v1.8.0...v1.8.1)
@@ -598,4 +667,4 @@ All significant changes to this repo will be summarized in this file.
598
667
  - 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
668
 
600
669
 
601
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
670
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # Puppet::ResourceApi [![TravisCI Build Status](https://travis-ci.org/puppetlabs/puppet-resource_api.svg?branch=master)](https://travis-ci.org/puppetlabs/puppet-resource_api) [![Appveyor Build status](https://ci.appveyor.com/api/projects/status/8o9s1ax0hs8lm5fd/branch/master?svg=true)](https://ci.appveyor.com/project/puppetlabs/puppet-resource-api/branch/master) [![codecov](https://codecov.io/gh/puppetlabs/puppet-resource_api/branch/master/graph/badge.svg)](https://codecov.io/gh/puppetlabs/puppet-resource_api)
1
+ # Puppet::ResourceApi [![codecov](https://codecov.io/gh/puppetlabs/puppet-resource_api/branch/main/graph/badge.svg)](https://codecov.io/gh/puppetlabs/puppet-resource_api)
2
2
 
3
3
  This is an implementation of the [Resource API specification](https://github.com/puppetlabs/puppet-specifications/blob/master/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/master/lib/puppet/type/panos_address.rb)
7
- * [Base provider](https://github.com/puppetlabs/puppetlabs-panos/blob/master/lib/puppet/provider/panos_provider.rb)
8
- * [Actual provider with validation and xml processing](https://github.com/puppetlabs/puppetlabs-panos/blob/master/lib/puppet/provider/panos_address/panos_address.rb)
9
- * [New unit tests](https://github.com/puppetlabs/puppetlabs-panos/blob/master/spec/unit/puppet/provider/panos_provider_spec.rb) for 100% coverage.
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
 
@@ -15,18 +15,18 @@ Find a working example of a new-style providers in the [Palo Alto Firewall modul
15
15
  * The [Resource API specs](https://github.com/puppetlabs/puppet-specifications/blob/master/language/resource-api/README.md) describes details of all the capabilities of this gem.
16
16
  * The [puppetlabs-hue module](https://github.com/puppetlabs/puppetlabs-hue) is a very simple example for using the Resource API for remote resources.
17
17
  * The [meraki module](https://github.com/meraki/puppet-module) is a full example for using the Resource API for remote resources.
18
- * This [Introduction to Testing Puppet Modules](https://www.netways.de/index.php?id=3445#c44135) talk describes rspec usage in more detail.
19
- * The [RSpec docs](https://relishapp.com/rspec) provide an overview of the capabilities of rspec.
18
+ * This [Introduction to Testing Puppet Modules](https://www.youtube.com/watch?v=GgNrxLfoDF8) talk describes rspec usage in more detail.
19
+ * The [RSpec docs](https://rspec.info/documentation/) provide an overview of the capabilities of rspec.
20
20
  * Read [betterspecs](http://www.betterspecs.org/) for general guidelines on what is considered good specs.
21
21
 
22
22
 
23
23
  ## Deployment
24
24
 
25
- The `puppet-resource_api` gem is part of the [Puppet 6 Platform](https://puppet.com/blog/introducing-puppet-6). With older versions of Puppet, you can use the [puppetlabs-resource_api module](https://forge.puppet.com/puppetlabs/resource_api) to install the gem on your servers and agents.
25
+ The `puppet-resource_api` gem is part of Puppet from version 6 onward.
26
26
 
27
27
 
28
28
  ## Contributing
29
- We are always welcoming bug reports and pull requests on the Resource API, so that we can continue to improve it to the best of our ability. If you would like to contribute, [have a look at our GitHub](https://github.com/puppetlabs/puppet-resource_api) and the [Resource API Backlog](https://github.com/puppetlabs/puppet-resource_api/projects/1).
29
+ We welcome bug reports and pull requests on the Resource API so that we can continue to improve it to the best of our ability. If you would like to contribute, [have a look at our GitHub](https://github.com/puppetlabs/puppet-resource_api) and the [Resource API Backlog](https://github.com/puppetlabs/puppet-resource_api/projects/1).
30
30
 
31
31
 
32
32
  ## Known Issues
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 completely this lab, you will have a fully functioning module to manage Philips HUE lights.
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 [VSCode](https://code.visualstudio.com/download), with the [Ruby](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby) and [Puppet](https://marketplace.visualstudio.com/items?itemName=jpogran.puppet-vscode) extensions. There are lots of other extensions that can help you with your development workflow.
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
- [master (root-commit) 67951dd] initial commit
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/master/tasks/apikey.rb
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'puppet/resource_api/type_definition'
2
4
 
3
5
  # rubocop:disable Style/Documentation
@@ -88,7 +90,7 @@ class Puppet::ResourceApi::BaseContext
88
90
  end
89
91
  end
90
92
 
91
- def processing(title, is, should, message: 'Processing')
93
+ def processing(title, is, should, message = 'Processing')
92
94
  raise "#{__method__} only accepts a single resource title" if title.respond_to?(:each)
93
95
  start_time = Time.now
94
96
  setup_context(title, message)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Puppet; module ResourceApi; end; end # predeclare the main module # rubocop:disable Style/Documentation,Style/ClassAndModuleChildren
2
4
 
3
5
  # This module is used to handle data inside types, contains methods for munging
@@ -84,7 +86,7 @@ module Puppet::ResourceApi::DataTypeHandling
84
86
  when Puppet::Pops::Types::PIntegerType,
85
87
  Puppet::Pops::Types::PFloatType,
86
88
  Puppet::Pops::Types::PNumericType
87
- if value =~ %r{^-?\d+$} || value =~ Puppet::Pops::Patterns::NUMERIC
89
+ if value.is_a?(String) && (value.match?(%r{^-?\d+$}) || value.match?(Puppet::Pops::Patterns::NUMERIC))
88
90
  value = Puppet::Pops::Utils.to_n(value)
89
91
  end
90
92
  when Puppet::Pops::Types::PEnumType,
@@ -182,8 +184,15 @@ module Puppet::ResourceApi::DataTypeHandling
182
184
  options = definition[:attributes][:ensure]
183
185
  type = parse_puppet_type(:ensure, options[:type])
184
186
 
187
+ # If the type is wrapped in optional, then check it unwrapped:
188
+ type = type.type if type.is_a?(Puppet::Pops::Types::POptionalType)
185
189
  return if type.is_a?(Puppet::Pops::Types::PEnumType) && type.values.sort == %w[absent present].sort
186
- raise Puppet::DevError, '`:ensure` attribute must have a type of: `Enum[present, absent]`'
190
+
191
+ # If Variant was used instead, then construct one and use the built-in type comparison:
192
+ variant_type = Puppet::Pops::Types::TypeParser.singleton.parse('Variant[Undef, Enum[present, absent]]')
193
+ return if variant_type == type
194
+
195
+ raise Puppet::DevError, '`:ensure` attribute must have a type of: `Enum[present, absent]` or `Optional[Enum[present, absent]]`'
187
196
  end
188
197
 
189
198
  def self.parse_puppet_type(attr_name, type)
@@ -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 namevars
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/resource_api/base_context'
2
4
 
3
5
  # Implement Resource API Conext to log through an IO object, defaulting to `$stderr`.
@@ -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
- # Define class method insync?(is) if the name is :ensure
19
- def_insync? if @attribute_name == :ensure && self.class != Puppet::ResourceApi::Property
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 def_insync?
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
  require 'puppet/resource_api/base_context'
2
4
  require 'puppet/util/logging'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'puppet/util'
2
4
  require 'puppet/resource_api/parameter'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Puppet; end # rubocop:disable Style/Documentation
2
4
 
3
5
  module Puppet::ResourceApi
@@ -38,14 +40,14 @@ module Puppet::ResourceApi
38
40
  context.creating(name) do
39
41
  create(context, name_hash, should)
40
42
  end
41
- elsif is[:ensure].to_s == 'present' && should[:ensure].to_s == 'present'
42
- context.updating(name) do
43
- update(context, name_hash, should)
44
- end
45
43
  elsif is[:ensure].to_s == 'present' && should[:ensure].to_s == 'absent'
46
44
  context.deleting(name) do
47
45
  delete(context, name_hash)
48
46
  end
47
+ elsif is[:ensure].to_s == 'present'
48
+ context.updating(name) do
49
+ update(context, name_hash, should)
50
+ end
49
51
  end
50
52
  end
51
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'puppet/resource_api/transport'
2
4
  require 'hocon'
3
5
  require 'hocon/config_syntax'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Puppet::ResourceApi; end # rubocop:disable Style/Documentation
2
4
 
3
5
  # Remote target transport API
@@ -101,6 +103,7 @@ module Puppet::ResourceApi::Transport
101
103
  clean_bolt_attributes(transport_schema, connection_info)
102
104
  end
103
105
 
106
+ apply_defaults(transport_schema, connection_info)
104
107
  message_prefix = 'The connection info provided does not match the Transport Schema'
105
108
  transport_schema.check_schema(connection_info, message_prefix)
106
109
  transport_schema.validate(connection_info)
@@ -126,6 +129,18 @@ module Puppet::ResourceApi::Transport
126
129
  end
127
130
  private_class_method :wrap_sensitive
128
131
 
132
+ def self.apply_defaults(transport_schema, connection_info)
133
+ context = get_context(transport_schema.name)
134
+ transport_schema.attributes.each do |attr_name, options|
135
+ if options.key?(:default) && connection_info.key?(attr_name) == false
136
+ context.debug('Using default value for attribute: %{attribute_name}, value: %{default_value}' % { attribute_name: attr_name, default_value: options[:default].inspect })
137
+ connection_info[attr_name] = options[:default]
138
+ end
139
+ end
140
+ connection_info
141
+ end
142
+ private_class_method :apply_defaults
143
+
129
144
  def self.transports
130
145
  @transports ||= {}
131
146
  end