pdk 1.18.1 → 2.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 +42 -10
- data/README.md +1 -1
- data/lib/pdk/cli.rb +4 -1
- data/lib/pdk/cli/new.rb +2 -0
- data/lib/pdk/cli/new/fact.rb +29 -0
- data/lib/pdk/cli/new/function.rb +29 -0
- data/lib/pdk/cli/release/publish.rb +11 -1
- data/lib/pdk/cli/util/option_validator.rb +6 -0
- data/lib/pdk/generate.rb +0 -1
- data/lib/pdk/generate/fact.rb +25 -0
- data/lib/pdk/generate/function.rb +48 -0
- data/lib/pdk/generate/provider.rb +1 -1
- data/lib/pdk/generate/transport.rb +1 -1
- data/lib/pdk/module.rb +1 -0
- data/lib/pdk/module/metadata.rb +6 -2
- data/lib/pdk/module/release.rb +1 -1
- data/lib/pdk/module/update.rb +1 -1
- data/lib/pdk/report.rb +3 -3
- data/lib/pdk/report/event.rb +8 -2
- data/lib/pdk/tests/unit.rb +3 -1
- data/lib/pdk/util/bundler.rb +1 -1
- data/lib/pdk/util/changelog_generator.rb +7 -3
- data/lib/pdk/util/puppet_version.rb +2 -2
- data/lib/pdk/util/ruby_version.rb +5 -1
- data/lib/pdk/util/template_uri.rb +5 -5
- data/lib/pdk/util/vendored_file.rb +1 -2
- data/lib/pdk/validate/invokable_validator.rb +6 -1
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +1 -1
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +2 -2
- data/lib/pdk/version.rb +1 -1
- metadata +19 -9
- data/lib/pdk/generate/resource_api_object.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0614fb53065a8c2545ffe2bf3839b9d30aaef65d3b9827635ceb5f24d0181e
|
4
|
+
data.tar.gz: b582b1d8c5622fd2bbbe7facc1676a2c4d2d4c50729b2156667a96eb6bcc73e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a09558ee0700783e650c8506ee291c768b89567f7c063763652a449c50544e9f31b95173918f8c553bd120742232d542b897c8eaccd23e8153702b7c75609582
|
7
|
+
data.tar.gz: e93a741e535ffe7bd3f9929cc7464891d0a9bbb04d13e5c4e9faf3ff2fd03434a2e127d7a62be06ad64479994198b0427e172ab9df496d48ce79b8f189079a2f
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,36 @@ All changes to this repo will be documented in this file.
|
|
4
4
|
See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) for a high-level summary.
|
5
5
|
|
6
6
|
|
7
|
-
## [
|
7
|
+
## [v2.0.0](https://github.com/puppetlabs/pdk/tree/v2.0.0) (2021-02-24)
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.18.1...v2.0.0)
|
10
|
+
|
11
|
+
**Implemented enhancements:**
|
12
|
+
|
13
|
+
- Provide more context when forge upload fails [\#905](https://github.com/puppetlabs/pdk/issues/905)
|
14
|
+
- \(IAC-1438\) - Removal of Inappropriate Terminology [\#945](https://github.com/puppetlabs/pdk/pull/945) ([david22swan](https://github.com/david22swan))
|
15
|
+
- Remove pre-condition checks for RSAPI objects [\#943](https://github.com/puppetlabs/pdk/pull/943) ([DavidS](https://github.com/DavidS))
|
16
|
+
- Update lower puppet requirements bound when creating new modules [\#942](https://github.com/puppetlabs/pdk/pull/942) ([DavidS](https://github.com/DavidS))
|
17
|
+
- Allow Facter4 to be co-installed with PDK [\#941](https://github.com/puppetlabs/pdk/pull/941) ([GabrielNagy](https://github.com/GabrielNagy))
|
18
|
+
- Add ability to generate functions [\#932](https://github.com/puppetlabs/pdk/pull/932) ([logicminds](https://github.com/logicminds))
|
19
|
+
- \(GH-905\) Ensure release failure includes error message [\#929](https://github.com/puppetlabs/pdk/pull/929) ([michaeltlombardi](https://github.com/michaeltlombardi))
|
20
|
+
- Adds AIX support when creating a new module [\#927](https://github.com/puppetlabs/pdk/pull/927) ([logicminds](https://github.com/logicminds))
|
21
|
+
- Add ability to generate new facts [\#921](https://github.com/puppetlabs/pdk/pull/921) ([logicminds](https://github.com/logicminds))
|
22
|
+
- Add forge token env [\#913](https://github.com/puppetlabs/pdk/pull/913) ([scotje](https://github.com/scotje))
|
23
|
+
- \(FORGE-339\) Omit .DS\_Store files from module builds [\#910](https://github.com/puppetlabs/pdk/pull/910) ([binford2k](https://github.com/binford2k))
|
24
|
+
- \(\#876\) Refactor text report output when validators are skipped [\#904](https://github.com/puppetlabs/pdk/pull/904) ([scotje](https://github.com/scotje))
|
25
|
+
|
26
|
+
**Fixed bugs:**
|
27
|
+
|
28
|
+
- puppet 7 dependency problems [\#931](https://github.com/puppetlabs/pdk/issues/931)
|
29
|
+
- PDK download fails with 404 for macOS [\#928](https://github.com/puppetlabs/pdk/issues/928)
|
30
|
+
- PDK does not support ruby 2.7 [\#914](https://github.com/puppetlabs/pdk/issues/914)
|
31
|
+
- The `pdk release prep` command cannot find the github\_changelog\_generator gem [\#902](https://github.com/puppetlabs/pdk/issues/902)
|
32
|
+
- \(PDK-1655\) pdk test unit fails when compiling spec tests on puppet 6.17 due to removal of default\_env [\#890](https://github.com/puppetlabs/pdk/issues/890)
|
33
|
+
- Unit tests fail with can't modify frozen String \(RuntimeError\) [\#886](https://github.com/puppetlabs/pdk/issues/886)
|
34
|
+
- `pdk validate` is missing a newline at the end, resulting in the shell prompt being printed on the same line [\#876](https://github.com/puppetlabs/pdk/issues/876)
|
35
|
+
|
36
|
+
## [v1.18.1](https://github.com/puppetlabs/pdk/tree/v1.18.1) (2020-07-17)
|
8
37
|
|
9
38
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.18.0...v1.18.1)
|
10
39
|
|
@@ -54,6 +83,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
54
83
|
- \(PDK-1615\) Add Ini File configuration support [\#856](https://github.com/puppetlabs/pdk/pull/856) ([glennsarti](https://github.com/glennsarti))
|
55
84
|
- \(PDK-1612\) Add PDK::Context and context detection [\#853](https://github.com/puppetlabs/pdk/pull/853) ([glennsarti](https://github.com/glennsarti))
|
56
85
|
- \(PDK-1607\)\(PDK-1608\) Implement system-level settings for PDK configuration [\#841](https://github.com/puppetlabs/pdk/pull/841) ([glennsarti](https://github.com/glennsarti))
|
86
|
+
- \(PDK-1557\) Detect Control Repositories [\#826](https://github.com/puppetlabs/pdk/pull/826) ([glennsarti](https://github.com/glennsarti))
|
57
87
|
|
58
88
|
**Fixed bugs:**
|
59
89
|
|
@@ -77,8 +107,8 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
77
107
|
- \(PDK-1545\) Include template-ref in module generation output [\#840](https://github.com/puppetlabs/pdk/pull/840) ([rodjek](https://github.com/rodjek))
|
78
108
|
- \(PDK-1587\) Reject paths with non-ASCII characters when building [\#832](https://github.com/puppetlabs/pdk/pull/832) ([rodjek](https://github.com/rodjek))
|
79
109
|
- \(PDK-1588\) Increase granularity of `pdk bundle` analytics [\#827](https://github.com/puppetlabs/pdk/pull/827) ([rodjek](https://github.com/rodjek))
|
80
|
-
- \(PDK-1557\) Detect Control Repositories [\#826](https://github.com/puppetlabs/pdk/pull/826) ([glennsarti](https://github.com/glennsarti))
|
81
110
|
- \(PDK-1556\) Use the module root when generating objects [\#824](https://github.com/puppetlabs/pdk/pull/824) ([glennsarti](https://github.com/glennsarti))
|
111
|
+
- \(PDK-1487\) Add --default-template flag to pdk convert [\#814](https://github.com/puppetlabs/pdk/pull/814) ([rodjek](https://github.com/rodjek))
|
82
112
|
|
83
113
|
**Fixed bugs:**
|
84
114
|
|
@@ -100,7 +130,6 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
100
130
|
**Implemented enhancements:**
|
101
131
|
|
102
132
|
- \(PDK-1488\) Inform user if updating a pinned module [\#816](https://github.com/puppetlabs/pdk/pull/816) ([rodjek](https://github.com/rodjek))
|
103
|
-
- \(PDK-1487\) Add --default-template flag to pdk convert [\#814](https://github.com/puppetlabs/pdk/pull/814) ([rodjek](https://github.com/rodjek))
|
104
133
|
- \(GH-808\) Implement pdk release prep and publish subcommands [\#813](https://github.com/puppetlabs/pdk/pull/813) ([glennsarti](https://github.com/glennsarti))
|
105
134
|
- \(GH-808\) Implement pdk release subcommand [\#809](https://github.com/puppetlabs/pdk/pull/809) ([glennsarti](https://github.com/glennsarti))
|
106
135
|
- \(PDK-1364\) Allow non-git template directories to be used [\#803](https://github.com/puppetlabs/pdk/pull/803) ([glennsarti](https://github.com/glennsarti))
|
@@ -244,7 +273,6 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
244
273
|
- \(maint\) Update beaker in package tests [\#695](https://github.com/puppetlabs/pdk/pull/695) ([rodjek](https://github.com/rodjek))
|
245
274
|
- Revert "Merge pull request \#666 from DavidS/fm-8081-pdk-new-transport" [\#693](https://github.com/puppetlabs/pdk/pull/693) ([DavidS](https://github.com/DavidS))
|
246
275
|
- \(maint\) Message and string fixes [\#676](https://github.com/puppetlabs/pdk/pull/676) ([DavidS](https://github.com/DavidS))
|
247
|
-
- \(PDK-1333\) command\_spec rake task [\#644](https://github.com/puppetlabs/pdk/pull/644) ([rodjek](https://github.com/rodjek))
|
248
276
|
|
249
277
|
## [v1.11.1](https://github.com/puppetlabs/pdk/tree/v1.11.1) (2019-07-01)
|
250
278
|
|
@@ -309,7 +337,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
309
337
|
- \(PDK-1335\) Add development note when on Windows [\#649](https://github.com/puppetlabs/pdk/pull/649) ([glennsarti](https://github.com/glennsarti))
|
310
338
|
- \(maint\) Allow developers to add additional gems [\#648](https://github.com/puppetlabs/pdk/pull/648) ([glennsarti](https://github.com/glennsarti))
|
311
339
|
- \(PDK-1167\) Validator should honor case sensitive of the file system [\#646](https://github.com/puppetlabs/pdk/pull/646) ([glennsarti](https://github.com/glennsarti))
|
312
|
-
- \(PDK-
|
340
|
+
- \(PDK-1333\) command\_spec rake task [\#644](https://github.com/puppetlabs/pdk/pull/644) ([rodjek](https://github.com/rodjek))
|
313
341
|
|
314
342
|
## [v1.10.0](https://github.com/puppetlabs/pdk/tree/v1.10.0) (2019-04-02)
|
315
343
|
|
@@ -321,6 +349,10 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
321
349
|
- \(PDK-1308\) Ensure PDK-written non-templated files have trailing newline [\#640](https://github.com/puppetlabs/pdk/pull/640) ([scotje](https://github.com/scotje))
|
322
350
|
- \(PDK-718\) Add --template-ref argument for upstream template repo tags [\#434](https://github.com/puppetlabs/pdk/pull/434) ([hunner](https://github.com/hunner))
|
323
351
|
|
352
|
+
**Fixed bugs:**
|
353
|
+
|
354
|
+
- \(PDK-1266\) Clear modulepath value when validating manifest syntax [\#629](https://github.com/puppetlabs/pdk/pull/629) ([rodjek](https://github.com/rodjek))
|
355
|
+
|
324
356
|
**Closed issues:**
|
325
357
|
|
326
358
|
- `pdk update` is not idempotent for deletion of CI config files [\#593](https://github.com/puppetlabs/pdk/issues/593)
|
@@ -333,6 +365,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
333
365
|
- \(PDK-1324\) Release 1.10.0 [\#650](https://github.com/puppetlabs/pdk/pull/650) ([rodjek](https://github.com/rodjek))
|
334
366
|
- \(maint\) Fix package specs for template-ref changes [\#647](https://github.com/puppetlabs/pdk/pull/647) ([rodjek](https://github.com/rodjek))
|
335
367
|
- \(maint\) Enforce LF line endings in Rubocop [\#645](https://github.com/puppetlabs/pdk/pull/645) ([glennsarti](https://github.com/glennsarti))
|
368
|
+
- \(PDK-1193\) Saves packaged template-url in metadata as a keyword [\#639](https://github.com/puppetlabs/pdk/pull/639) ([bmjen](https://github.com/bmjen))
|
336
369
|
- \(FM-7579, PDK-1236\) bump the version of CRI used [\#638](https://github.com/puppetlabs/pdk/pull/638) ([tphoney](https://github.com/tphoney))
|
337
370
|
- \(PDK-1294\) Update version post-release [\#637](https://github.com/puppetlabs/pdk/pull/637) ([bmjen](https://github.com/bmjen))
|
338
371
|
- \(PDK-1298\) acceptance:local test suite optimisation [\#633](https://github.com/puppetlabs/pdk/pull/633) ([rodjek](https://github.com/rodjek))
|
@@ -344,16 +377,15 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
344
377
|
**Fixed bugs:**
|
345
378
|
|
346
379
|
- \(IMAGES-1037\) Make sure our paths are used [\#630](https://github.com/puppetlabs/pdk/pull/630) ([mihaibuzgau](https://github.com/mihaibuzgau))
|
347
|
-
- \(PDK-1266\) Clear modulepath value when validating manifest syntax [\#629](https://github.com/puppetlabs/pdk/pull/629) ([rodjek](https://github.com/rodjek))
|
348
|
-
- \(PDK-1272\) Convert user/module module names to user-module [\#626](https://github.com/puppetlabs/pdk/pull/626) ([rodjek](https://github.com/rodjek))
|
349
380
|
- \(PDK-1276\) Skip non-file YAML validator targets [\#625](https://github.com/puppetlabs/pdk/pull/625) ([rodjek](https://github.com/rodjek))
|
350
|
-
- \(PDK-1273\)
|
381
|
+
- \(PDK-1273\) Allowlist Ruby symbols in YAML validator [\#624](https://github.com/puppetlabs/pdk/pull/624) ([rodjek](https://github.com/rodjek))
|
351
382
|
|
352
383
|
**Merged pull requests:**
|
353
384
|
|
354
385
|
- \(PDK-1289\) Release 1.9.1 [\#632](https://github.com/puppetlabs/pdk/pull/632) ([bmjen](https://github.com/bmjen))
|
355
386
|
- \(maint\) Pin parallel gem to 1.13.0 [\#631](https://github.com/puppetlabs/pdk/pull/631) ([rodjek](https://github.com/rodjek))
|
356
387
|
- \(PDK-1260\) Bump to 1.10.0.pre for new dev work [\#621](https://github.com/puppetlabs/pdk/pull/621) ([bmjen](https://github.com/bmjen))
|
388
|
+
- \(maint\) Fix package tests to remove hardcoding [\#613](https://github.com/puppetlabs/pdk/pull/613) ([bmjen](https://github.com/bmjen))
|
357
389
|
|
358
390
|
## [v1.9.0](https://github.com/puppetlabs/pdk/tree/v1.9.0) (2019-01-29)
|
359
391
|
|
@@ -365,6 +397,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
365
397
|
|
366
398
|
**Fixed bugs:**
|
367
399
|
|
400
|
+
- \(PDK-1272\) Convert user/module module names to user-module [\#626](https://github.com/puppetlabs/pdk/pull/626) ([rodjek](https://github.com/rodjek))
|
368
401
|
- \(PDK-914\) Adjust default\_template\_url validation to accept local dirs [\#606](https://github.com/puppetlabs/pdk/pull/606) ([rodjek](https://github.com/rodjek))
|
369
402
|
- \(PDK-1204\) pdk bundle execs in the context of the pwd [\#603](https://github.com/puppetlabs/pdk/pull/603) ([rodjek](https://github.com/rodjek))
|
370
403
|
|
@@ -380,7 +413,6 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
380
413
|
- \(maint\) Update hitimes pin to 1.3.0 for r2.1 compat [\#617](https://github.com/puppetlabs/pdk/pull/617) ([bmjen](https://github.com/bmjen))
|
381
414
|
- Release 1.9.0 [\#616](https://github.com/puppetlabs/pdk/pull/616) ([bmjen](https://github.com/bmjen))
|
382
415
|
- \(MAINT\) Configure Slack notifications for Travis [\#614](https://github.com/puppetlabs/pdk/pull/614) ([scotje](https://github.com/scotje))
|
383
|
-
- \(maint\) Fix package tests to remove hardcoding [\#613](https://github.com/puppetlabs/pdk/pull/613) ([bmjen](https://github.com/bmjen))
|
384
416
|
- \(MAINT\) Fix package acceptance tests to pass with any Ruby 2.4.x [\#611](https://github.com/puppetlabs/pdk/pull/611) ([scotje](https://github.com/scotje))
|
385
417
|
- \(MAINT\) Bump default packaged ruby version to 2.4.5 [\#608](https://github.com/puppetlabs/pdk/pull/608) ([scotje](https://github.com/scotje))
|
386
418
|
- \(PDK-1202\) Pass TemplateDir object through to TemplateFile [\#605](https://github.com/puppetlabs/pdk/pull/605) ([rodjek](https://github.com/rodjek))
|
@@ -999,6 +1031,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
999
1031
|
- Validate fails on existing module [\#158](https://github.com/puppetlabs/pdk/issues/158)
|
1000
1032
|
- \(\#158\) \(\#166\) Resolve issue loading bundler from gem installs [\#170](https://github.com/puppetlabs/pdk/pull/170) ([scotje](https://github.com/scotje))
|
1001
1033
|
- \(SDK-319\) force usage of our ruby [\#168](https://github.com/puppetlabs/pdk/pull/168) ([DavidS](https://github.com/DavidS))
|
1034
|
+
- \(FIXUP\) Add missing newlines in new module interview prompts [\#161](https://github.com/puppetlabs/pdk/pull/161) ([scotje](https://github.com/scotje))
|
1002
1035
|
|
1003
1036
|
**Closed issues:**
|
1004
1037
|
|
@@ -1031,7 +1064,6 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
1031
1064
|
**Fixed bugs:**
|
1032
1065
|
|
1033
1066
|
- Can't create module if new module fails to get login [\#157](https://github.com/puppetlabs/pdk/issues/157)
|
1034
|
-
- \(FIXUP\) Add missing newlines in new module interview prompts [\#161](https://github.com/puppetlabs/pdk/pull/161) ([scotje](https://github.com/scotje))
|
1035
1067
|
- Use default username when Etc.getlogin fails [\#160](https://github.com/puppetlabs/pdk/pull/160) ([austb](https://github.com/austb))
|
1036
1068
|
|
1037
1069
|
**Merged pull requests:**
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# pdk [![Build Status](https://travis-ci.org/puppetlabs/pdk.svg?branch=
|
1
|
+
# pdk [![Build Status](https://travis-ci.org/puppetlabs/pdk.svg?branch=main)](https://travis-ci.org/puppetlabs/pdk) [![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/x70e2fqllbaootpd?svg=true)](https://ci.appveyor.com/project/puppetlabs/pdk) [![Coverage Status](https://coveralls.io/repos/github/puppetlabs/pdk/badge.svg?branch=main)](https://coveralls.io/github/puppetlabs/pdk?branch=main)
|
2
2
|
|
3
3
|
* [Installation](#installation)
|
4
4
|
* [Basic usage](#basic-usage)
|
data/lib/pdk/cli.rb
CHANGED
data/lib/pdk/cli/new.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module PDK::CLI
|
2
|
+
@new_fact_cmd = @new_cmd.define_command do
|
3
|
+
name 'fact'
|
4
|
+
usage _('fact [options] <name>')
|
5
|
+
summary _('Create a new custom fact named <name> using given options')
|
6
|
+
|
7
|
+
run do |opts, args, _cmd|
|
8
|
+
PDK::CLI::Util.ensure_in_module!
|
9
|
+
|
10
|
+
fact_name = args[0]
|
11
|
+
|
12
|
+
if fact_name.nil? || fact_name.empty?
|
13
|
+
puts command.help
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
unless Util::OptionValidator.valid_fact_name?(fact_name)
|
18
|
+
raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid fact name") % { name: fact_name }
|
19
|
+
end
|
20
|
+
|
21
|
+
PDK::CLI::Util.analytics_screen_view('new_fact', opts)
|
22
|
+
|
23
|
+
require 'pdk/generate/fact'
|
24
|
+
|
25
|
+
updates = PDK::Generate::Fact.new(PDK.context, fact_name, opts).run
|
26
|
+
PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PDK::CLI
|
2
|
+
@new_function_cmd = @new_cmd.define_command do
|
3
|
+
name 'function'
|
4
|
+
usage _('function [options] <name>')
|
5
|
+
summary _('Create a new function named <name> using given options')
|
6
|
+
option :t, :type, _('The function type, (native or v4)'), argument: :required, default: 'native'
|
7
|
+
|
8
|
+
run do |opts, args, _cmd|
|
9
|
+
PDK::CLI::Util.ensure_in_module!
|
10
|
+
|
11
|
+
function_name = args[0]
|
12
|
+
|
13
|
+
if function_name.nil? || function_name.empty?
|
14
|
+
puts command.help
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
|
18
|
+
unless Util::OptionValidator.valid_function_name?(function_name)
|
19
|
+
raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid function name") % { name: function_name }
|
20
|
+
end
|
21
|
+
|
22
|
+
PDK::CLI::Util.analytics_screen_view('new_function', opts)
|
23
|
+
|
24
|
+
require 'pdk/generate/function'
|
25
|
+
updates = PDK::Generate::Function.new(PDK.context, function_name, opts).run
|
26
|
+
PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -11,7 +11,7 @@ module PDK::CLI
|
|
11
11
|
option nil, :'forge-upload-url', _('Set forge upload url path.'),
|
12
12
|
argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
|
13
13
|
|
14
|
-
option nil, :'forge-token', _('Set Forge API token
|
14
|
+
option nil, :'forge-token', _('Set Forge API token (you may also set via environment variable PDK_FORGE_TOKEN)'), argument: :required
|
15
15
|
|
16
16
|
run do |opts, _args, cmd|
|
17
17
|
# Make sure build is being run in a valid module directory with a metadata.json
|
@@ -27,6 +27,16 @@ module PDK::CLI
|
|
27
27
|
opts[:'skip-build'] = true
|
28
28
|
opts[:'skip-versionset'] = true
|
29
29
|
opts[:force] = true unless PDK::CLI::Util.interactive?
|
30
|
+
opts[:'forge-token'] ||= PDK::Util::Env['PDK_FORGE_TOKEN']
|
31
|
+
|
32
|
+
if opts[:'forge-token'].nil? || opts[:'forge-token'].empty?
|
33
|
+
PDK.logger.error _(
|
34
|
+
'You must supply a Forge API token either via `--forge-token` option ' \
|
35
|
+
'or PDK_FORGE_TOKEN environment variable.',
|
36
|
+
)
|
37
|
+
|
38
|
+
exit 1
|
39
|
+
end
|
30
40
|
|
31
41
|
Release.prepare_publish_interview(TTY::Prompt.new(help_color: :cyan), opts) unless opts[:force]
|
32
42
|
|
@@ -8,6 +8,11 @@ module PDK
|
|
8
8
|
(list =~ %r{^[\w\-]+(?:,[\w\-]+)+$}) ? true : false
|
9
9
|
end
|
10
10
|
|
11
|
+
# @return [Boolean] true if the fact name is valid
|
12
|
+
def self.valid_fact_name?(name)
|
13
|
+
name.length > 1
|
14
|
+
end
|
15
|
+
|
11
16
|
def self.enum(val, valid_entries, _options = {})
|
12
17
|
vals = val.is_a?(Array) ? val : [val]
|
13
18
|
invalid_entries = vals.reject { |e| valid_entries.include?(e) }
|
@@ -41,6 +46,7 @@ module PDK
|
|
41
46
|
|
42
47
|
!(string =~ %r{\A([a-z][a-z0-9_]*)(::[a-z][a-z0-9_]*)*\Z}).nil?
|
43
48
|
end
|
49
|
+
singleton_class.send(:alias_method, :valid_function_name?, :valid_namespace?)
|
44
50
|
|
45
51
|
singleton_class.send(:alias_method, :valid_class_name?, :valid_namespace?)
|
46
52
|
singleton_class.send(:alias_method, :valid_defined_type_name?, :valid_namespace?)
|
data/lib/pdk/generate.rb
CHANGED
@@ -7,7 +7,6 @@ module PDK
|
|
7
7
|
autoload :Provider, 'pdk/generate/provider'
|
8
8
|
autoload :PuppetClass, 'pdk/generate/puppet_class'
|
9
9
|
autoload :PuppetObject, 'pdk/generate/puppet_object'
|
10
|
-
autoload :ResourceAPIObject, 'pdk/generate/resource_api_object'
|
11
10
|
autoload :Task, 'pdk/generate/task'
|
12
11
|
autoload :Transport, 'pdk/generate/transport'
|
13
12
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Generate
|
5
|
+
class Fact < PuppetObject
|
6
|
+
def friendly_name
|
7
|
+
'Custom Fact'.freeze
|
8
|
+
end
|
9
|
+
|
10
|
+
def template_files
|
11
|
+
files = {
|
12
|
+
'fact_spec.erb' => File.join('spec', 'unit', 'facter', object_name) + '_spec.rb',
|
13
|
+
}
|
14
|
+
return files if spec_only?
|
15
|
+
files.merge(
|
16
|
+
'fact.erb' => File.join('lib', 'facter', object_name) + '.rb',
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def template_data
|
21
|
+
{ name: object_name }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Generate
|
5
|
+
class Function < PuppetObject
|
6
|
+
def initialize(*_args)
|
7
|
+
super
|
8
|
+
object_name_parts = @object_name.split('::')
|
9
|
+
|
10
|
+
@object_name = if object_name_parts.first == module_name
|
11
|
+
object_name
|
12
|
+
else
|
13
|
+
[module_name, object_name].join('::')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def friendly_name
|
18
|
+
'Function'.freeze
|
19
|
+
end
|
20
|
+
|
21
|
+
def template_files
|
22
|
+
# Calculate the function tests name
|
23
|
+
func_name_parts = object_name.split('::')
|
24
|
+
# Drop the module name if the object name contains multiple parts
|
25
|
+
func_name_parts.delete_at(0) if func_name_parts.length > 1
|
26
|
+
files = {
|
27
|
+
File.join('functions', 'function_spec.erb') => File.join('spec', 'functions', *func_name_parts) + '_spec.rb',
|
28
|
+
}
|
29
|
+
return files if spec_only?
|
30
|
+
func_name_parts = object_name.split('::')[1..-1]
|
31
|
+
template_file = File.join('functions', "#{options[:type]}_function.erb")
|
32
|
+
|
33
|
+
files[template_file] = if options[:type].eql?('v4')
|
34
|
+
File.join('lib', 'puppet', 'functions', module_name, *func_name_parts) + '.rb'
|
35
|
+
else
|
36
|
+
File.join('functions', *func_name_parts) + '.pp'
|
37
|
+
end
|
38
|
+
files
|
39
|
+
end
|
40
|
+
|
41
|
+
def template_data
|
42
|
+
func_name = object_name.split('::').last
|
43
|
+
namespace = object_name.split('::')[0...-1].join('::')
|
44
|
+
{ name: object_name, func_name: func_name, namespace: namespace }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/pdk/module.rb
CHANGED
data/lib/pdk/module/metadata.rb
CHANGED
@@ -27,7 +27,7 @@ module PDK
|
|
27
27
|
'Debian based Linux' => [
|
28
28
|
{
|
29
29
|
'operatingsystem' => 'Debian',
|
30
|
-
'operatingsystemrelease' => ['
|
30
|
+
'operatingsystemrelease' => ['10'],
|
31
31
|
},
|
32
32
|
{
|
33
33
|
'operatingsystem' => 'Ubuntu',
|
@@ -54,6 +54,10 @@ module PDK
|
|
54
54
|
'operatingsystem' => 'windows',
|
55
55
|
'operatingsystemrelease' => %w[2019 10],
|
56
56
|
},
|
57
|
+
'AIX' => {
|
58
|
+
'operatingsystem' => 'AIX',
|
59
|
+
'operatingsystemrelease' => %w[6.1 7.1 7.2],
|
60
|
+
},
|
57
61
|
}.freeze
|
58
62
|
|
59
63
|
DEFAULT_OPERATING_SYSTEMS = [
|
@@ -77,7 +81,7 @@ module PDK
|
|
77
81
|
OPERATING_SYSTEMS[os_name]
|
78
82
|
}.flatten,
|
79
83
|
'requirements' => [
|
80
|
-
{ 'name' => 'puppet', 'version_requirement' => '>=
|
84
|
+
{ 'name' => 'puppet', 'version_requirement' => '>= 6.21.0 < 8.0.0' },
|
81
85
|
],
|
82
86
|
}.freeze
|
83
87
|
|
data/lib/pdk/module/release.rb
CHANGED
@@ -163,7 +163,7 @@ module PDK
|
|
163
163
|
http.request(request)
|
164
164
|
end
|
165
165
|
|
166
|
-
raise PDK::CLI::ExitWithError, _('Error uploading to Puppet Forge: %{result}') % { result: response } unless response.is_a?(Net::HTTPSuccess)
|
166
|
+
raise PDK::CLI::ExitWithError, _('Error uploading to Puppet Forge: %{result}') % { result: response.body } unless response.is_a?(Net::HTTPSuccess)
|
167
167
|
PDK.logger.info _('Publish to Forge was successful')
|
168
168
|
end
|
169
169
|
|
data/lib/pdk/module/update.rb
CHANGED
data/lib/pdk/report.rb
CHANGED
@@ -104,7 +104,7 @@ module PDK
|
|
104
104
|
if event.rspec_puppet_coverage?
|
105
105
|
coverage_report = event.to_text
|
106
106
|
else
|
107
|
-
report << event.to_text unless event.pass?
|
107
|
+
report << event.to_text unless event.pass? || event.skipped?
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -113,8 +113,8 @@ module PDK
|
|
113
113
|
|
114
114
|
if target.is_a?(String)
|
115
115
|
PDK::Util::Filesystem.write_file(target, report.join("\n"))
|
116
|
-
|
117
|
-
target << report.join("\n")
|
116
|
+
elsif !report.empty?
|
117
|
+
target << report.join("\n") << "\n"
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
data/lib/pdk/report/event.rb
CHANGED
@@ -111,8 +111,8 @@ module PDK
|
|
111
111
|
location = nil if location.empty?
|
112
112
|
|
113
113
|
# TODO: maybe add trace
|
114
|
-
header = [severity, source, location, message].compact.join(': ')
|
115
114
|
if source == 'rspec'
|
115
|
+
header = [severity, source, location, message].compact.join(': ')
|
116
116
|
result = [header, " #{test}"]
|
117
117
|
context = context_lines
|
118
118
|
unless context.nil?
|
@@ -123,7 +123,13 @@ module PDK
|
|
123
123
|
|
124
124
|
result.compact.join("\n")
|
125
125
|
else
|
126
|
-
|
126
|
+
output = ['pdk']
|
127
|
+
output << "(#{severity.upcase}):" unless severity.nil?
|
128
|
+
output << "#{source}:" unless source.nil?
|
129
|
+
output << message unless message.nil?
|
130
|
+
output << "(#{location})" unless location.nil?
|
131
|
+
|
132
|
+
output.join(' ')
|
127
133
|
end
|
128
134
|
end
|
129
135
|
|
data/lib/pdk/tests/unit.rb
CHANGED
@@ -139,7 +139,7 @@ module PDK
|
|
139
139
|
|
140
140
|
example_results = {
|
141
141
|
# Only possibilities are passed, failed, pending:
|
142
|
-
# https://github.com/rspec/rspec-core/blob/
|
142
|
+
# https://github.com/rspec/rspec-core/blob/main/lib/rspec/core/example.rb#L548
|
143
143
|
'passed' => [],
|
144
144
|
'failed' => [],
|
145
145
|
'pending' => [],
|
@@ -183,6 +183,8 @@ module PDK
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def self.merge_json_results(json_data)
|
186
|
+
require 'set'
|
187
|
+
|
186
188
|
merged_json_result = {}
|
187
189
|
|
188
190
|
# Merge messages
|
data/lib/pdk/util/bundler.rb
CHANGED
@@ -44,7 +44,7 @@ module PDK
|
|
44
44
|
# If there are missing dependencies after updating the lockfile, let `bundle install`
|
45
45
|
# go out and get them. If the specified puppet gem version points to a remote location
|
46
46
|
# or local filepath, then run bundle install as well.
|
47
|
-
if !bundle.installed? || (gem_overrides[:puppet] && gem_overrides[:puppet].start_with?('file://', 'git://', 'https://'))
|
47
|
+
if !bundle.installed?(gem_overrides) || (gem_overrides[:puppet] && gem_overrides[:puppet].start_with?('file://', 'git://', 'https://'))
|
48
48
|
bundle.install!(gem_overrides)
|
49
49
|
end
|
50
50
|
|
@@ -9,11 +9,15 @@ module PDK
|
|
9
9
|
|
10
10
|
# Raises if the github_changelog_generator is not available
|
11
11
|
def self.github_changelog_generator_available!
|
12
|
-
|
13
|
-
|
12
|
+
check_command = PDK::CLI::Exec::InteractiveCommand.new(PDK::CLI::Exec.bundle_bin, 'show', 'github_changelog_generator')
|
13
|
+
check_command.context = :module
|
14
|
+
|
15
|
+
result = check_command.execute!
|
16
|
+
|
17
|
+
return if result[:exit_code].zero?
|
14
18
|
|
15
19
|
raise PDK::CLI::ExitWithError, _(
|
16
|
-
'Unable to generate the changelog as the %{gem} gem is not
|
20
|
+
'Unable to generate the changelog as the %{gem} gem is not included in this module\'s Gemfile',
|
17
21
|
) % { gem: GEM }
|
18
22
|
end
|
19
23
|
|
@@ -17,7 +17,7 @@ module PDK
|
|
17
17
|
|
18
18
|
PE_VERSIONS_URL = 'https://forgeapi.puppet.com/private/versions/pe'.freeze
|
19
19
|
DEFAULT_PUPPET_DEV_URL = 'https://github.com/puppetlabs/puppet'.freeze
|
20
|
-
DEFAULT_PUPPET_DEV_BRANCH = '
|
20
|
+
DEFAULT_PUPPET_DEV_BRANCH = 'main'.freeze
|
21
21
|
|
22
22
|
def puppet_dev_env
|
23
23
|
require 'pdk/util/ruby_version'
|
@@ -80,7 +80,7 @@ module PDK
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Reset local repo to latest
|
83
|
-
reset_result = PDK::Util::Git.git('-C', puppet_dev_path, 'reset', '--hard',
|
83
|
+
reset_result = PDK::Util::Git.git('-C', puppet_dev_path, 'reset', '--hard', "origin/#{DEFAULT_PUPPET_DEV_BRANCH}")
|
84
84
|
|
85
85
|
@puppet_dev_fetched = true
|
86
86
|
return if reset_result[:exit_code].zero?
|
@@ -60,7 +60,11 @@ module PDK
|
|
60
60
|
#
|
61
61
|
# PDK::Util::PuppetVersion.find_gem_for('5.5.10')[:ruby_version]
|
62
62
|
#
|
63
|
-
|
63
|
+
# For using the latest puppet gem:
|
64
|
+
# PDK::Util::PuppetVersion.latest_available[:ruby_version]
|
65
|
+
#
|
66
|
+
# Temporarily lock to Ruby 2.5.x as default until 2.7.x ecosystem is sorted
|
67
|
+
versions.keys.detect { |v| v =~ %r{^2\.5} }
|
64
68
|
else
|
65
69
|
# TODO: may not be a safe assumption that highest available version should be default
|
66
70
|
# WARNING Do NOT use PDK::Util::PuppetVersion.*** methods as it can recurse into this
|
@@ -26,13 +26,13 @@ module PDK
|
|
26
26
|
#
|
27
27
|
# file:///c:/foo (git clone location)
|
28
28
|
# c:/foo (shell paths)
|
29
|
-
# file:///c:/foo#
|
30
|
-
# c:/foo#
|
29
|
+
# file:///c:/foo#main (only for metadata)
|
30
|
+
# c:/foo#main (only for metadata)
|
31
31
|
#
|
32
32
|
# non output formats:
|
33
33
|
#
|
34
34
|
# /c:/foo (internal use only)
|
35
|
-
# /c:/foo#
|
35
|
+
# /c:/foo#main (internal use only)
|
36
36
|
#
|
37
37
|
def initialize(opts_or_uri)
|
38
38
|
require 'addressable'
|
@@ -241,11 +241,11 @@ module PDK
|
|
241
241
|
require 'pdk/util'
|
242
242
|
require 'pdk/version'
|
243
243
|
|
244
|
-
return '
|
244
|
+
return 'main' if PDK::Util.development_mode?
|
245
245
|
return PDK::TEMPLATE_REF if uri.nil?
|
246
246
|
|
247
247
|
uri = new(uri) unless uri.is_a?(self)
|
248
|
-
uri.default? ? PDK::TEMPLATE_REF : '
|
248
|
+
uri.default? ? PDK::TEMPLATE_REF : 'main'
|
249
249
|
end
|
250
250
|
|
251
251
|
# @returns Addressable::URI
|
@@ -55,8 +55,7 @@ module PDK
|
|
55
55
|
uri = URI.parse(url)
|
56
56
|
http = Net::HTTP.new(uri.host, uri.port)
|
57
57
|
http.use_ssl = true
|
58
|
-
# TODO: Get rid of this
|
59
|
-
# https://github.com/glennsarti/dev-tools/blob/master/RubyCerts.ps1
|
58
|
+
# TODO: Get rid of this
|
60
59
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if Gem.win_platform?
|
61
60
|
request = Net::HTTP::Get.new(uri.request_uri)
|
62
61
|
response = http.request(request)
|
@@ -86,7 +86,12 @@ module PDK
|
|
86
86
|
ignore_list = ignore_pathspec
|
87
87
|
target_list = target_list.reject { |file| ignore_list.match(file) }
|
88
88
|
|
89
|
-
|
89
|
+
if target_list.flatten.empty?
|
90
|
+
PDK.logger.info(_('Validator \'%{validator}\' skipped for \'%{target}\'. No files matching \'%{pattern}\' found to validate.') % { validator: name, target: target, pattern: pattern })
|
91
|
+
|
92
|
+
skipped << target
|
93
|
+
end
|
94
|
+
|
90
95
|
target_list
|
91
96
|
elsif PDK::Util::Filesystem.file?(target)
|
92
97
|
if Array(pattern).include? target
|
@@ -49,7 +49,7 @@ module PDK
|
|
49
49
|
# Need to set the JSON Parser and State Generator to the Native one to be
|
50
50
|
# compatible with the multi_json adapter.
|
51
51
|
JSON.parser = JSON::Ext::Parser if defined?(JSON::Ext::Parser)
|
52
|
-
JSON.generator = JSON::Ext::Generator
|
52
|
+
JSON.generator = JSON::Ext::Generator if defined?(JSON::Ext::Generator)
|
53
53
|
|
54
54
|
begin
|
55
55
|
errors = JSON::Validator.fully_validate(schema_file, PDK::Util::Filesystem.read_file(target)) || []
|
@@ -4,7 +4,7 @@ module PDK
|
|
4
4
|
module Validate
|
5
5
|
module YAML
|
6
6
|
class YAMLSyntaxValidator < InternalRubyValidator
|
7
|
-
|
7
|
+
YAML_ALLOWLISTED_CLASSES = [Symbol].freeze
|
8
8
|
|
9
9
|
def ignore_dotfiles
|
10
10
|
false
|
@@ -53,7 +53,7 @@ module PDK
|
|
53
53
|
end
|
54
54
|
|
55
55
|
begin
|
56
|
-
::YAML.safe_load(PDK::Util::Filesystem.read_file(target),
|
56
|
+
::YAML.safe_load(PDK::Util::Filesystem.read_file(target), YAML_ALLOWLISTED_CLASSES, [], true)
|
57
57
|
|
58
58
|
report.add_event(
|
59
59
|
file: target,
|
data/lib/pdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -182,14 +182,14 @@ dependencies:
|
|
182
182
|
requirements:
|
183
183
|
- - "~>"
|
184
184
|
- !ruby/object:Gem::Version
|
185
|
-
version: '0.
|
185
|
+
version: '0.22'
|
186
186
|
type: :runtime
|
187
187
|
prerelease: false
|
188
188
|
version_requirements: !ruby/object:Gem::Requirement
|
189
189
|
requirements:
|
190
190
|
- - "~>"
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: '0.
|
192
|
+
version: '0.22'
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
194
|
name: tty-spinner
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,16 +236,22 @@ dependencies:
|
|
236
236
|
name: facter
|
237
237
|
requirement: !ruby/object:Gem::Requirement
|
238
238
|
requirements:
|
239
|
-
- - "
|
239
|
+
- - ">="
|
240
240
|
- !ruby/object:Gem::Version
|
241
241
|
version: 2.5.1
|
242
|
+
- - "<"
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: 5.0.0
|
242
245
|
type: :runtime
|
243
246
|
prerelease: false
|
244
247
|
version_requirements: !ruby/object:Gem::Requirement
|
245
248
|
requirements:
|
246
|
-
- - "
|
249
|
+
- - ">="
|
247
250
|
- !ruby/object:Gem::Version
|
248
251
|
version: 2.5.1
|
252
|
+
- - "<"
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
version: 5.0.0
|
249
255
|
- !ruby/object:Gem::Dependency
|
250
256
|
name: httpclient
|
251
257
|
requirement: !ruby/object:Gem::Requirement
|
@@ -313,6 +319,8 @@ files:
|
|
313
319
|
- lib/pdk/cli/new.rb
|
314
320
|
- lib/pdk/cli/new/class.rb
|
315
321
|
- lib/pdk/cli/new/defined_type.rb
|
322
|
+
- lib/pdk/cli/new/fact.rb
|
323
|
+
- lib/pdk/cli/new/function.rb
|
316
324
|
- lib/pdk/cli/new/module.rb
|
317
325
|
- lib/pdk/cli/new/provider.rb
|
318
326
|
- lib/pdk/cli/new/task.rb
|
@@ -357,11 +365,12 @@ files:
|
|
357
365
|
- lib/pdk/control_repo.rb
|
358
366
|
- lib/pdk/generate.rb
|
359
367
|
- lib/pdk/generate/defined_type.rb
|
368
|
+
- lib/pdk/generate/fact.rb
|
369
|
+
- lib/pdk/generate/function.rb
|
360
370
|
- lib/pdk/generate/module.rb
|
361
371
|
- lib/pdk/generate/provider.rb
|
362
372
|
- lib/pdk/generate/puppet_class.rb
|
363
373
|
- lib/pdk/generate/puppet_object.rb
|
364
|
-
- lib/pdk/generate/resource_api_object.rb
|
365
374
|
- lib/pdk/generate/task.rb
|
366
375
|
- lib/pdk/generate/transport.rb
|
367
376
|
- lib/pdk/i18n.rb
|
@@ -440,14 +449,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
440
449
|
requirements:
|
441
450
|
- - ">="
|
442
451
|
- !ruby/object:Gem::Version
|
443
|
-
version: 2.
|
452
|
+
version: 2.4.0
|
444
453
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
445
454
|
requirements:
|
446
455
|
- - ">="
|
447
456
|
- !ruby/object:Gem::Version
|
448
457
|
version: '0'
|
449
458
|
requirements: []
|
450
|
-
|
459
|
+
rubyforge_project:
|
460
|
+
rubygems_version: 2.7.6.2
|
451
461
|
signing_key:
|
452
462
|
specification_version: 4
|
453
463
|
summary: A key part of the Puppet Development Kit, the shortest path to better modules
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Generate
|
5
|
-
# An abstract class for generated objects that require the Puppet Resource API Gem
|
6
|
-
#
|
7
|
-
# @abstract
|
8
|
-
class ResourceAPIObject < PuppetObject
|
9
|
-
#:nocov: This is tested in spec/acceptance/new_transport_spec.rb
|
10
|
-
# @see PDK::Generate::PuppetObject.check_preconditions
|
11
|
-
def check_preconditions
|
12
|
-
super
|
13
|
-
# Note that these preconditions are only applicable to the current (V1) template rendering layout and will need to be changed
|
14
|
-
# when additional template renderers are introduced.
|
15
|
-
#
|
16
|
-
# These preconditions can be removed once the pdk-templates are carrying the puppet-resource_api gem by default, and have switched
|
17
|
-
# the default mock_with value.
|
18
|
-
sync_path = PDK::Util.find_upwards('.sync.yml')
|
19
|
-
if sync_path.nil?
|
20
|
-
raise_precondition_error(_('.sync.yml not found'))
|
21
|
-
end
|
22
|
-
sync = YAML.load_file(sync_path)
|
23
|
-
if !sync.is_a? Hash
|
24
|
-
raise_precondition_error(_('.sync.yml contents is not a Hash'))
|
25
|
-
elsif !sync.key? 'Gemfile'
|
26
|
-
raise_precondition_error(_('Gemfile configuration not found'))
|
27
|
-
elsif !sync['Gemfile'].key? 'optional'
|
28
|
-
raise_precondition_error(_('Gemfile.optional configuration not found'))
|
29
|
-
elsif !sync['Gemfile']['optional'].key? ':development'
|
30
|
-
raise_precondition_error(_('Gemfile.optional.:development configuration not found'))
|
31
|
-
elsif sync['Gemfile']['optional'][':development'].none? { |g| g['gem'] == 'puppet-resource_api' }
|
32
|
-
raise_precondition_error(_('puppet-resource_api not found in the Gemfile config'))
|
33
|
-
elsif !sync.key? 'spec/spec_helper.rb'
|
34
|
-
raise_precondition_error(_('spec/spec_helper.rb configuration not found'))
|
35
|
-
elsif !sync['spec/spec_helper.rb'].key? 'mock_with'
|
36
|
-
raise_precondition_error(_('spec/spec_helper.rb.mock_with configuration not found'))
|
37
|
-
elsif !sync['spec/spec_helper.rb']['mock_with'] == ':rspec'
|
38
|
-
raise_precondition_error(_('spec/spec_helper.rb.mock_with not set to \':rspec\''))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Helper method to raise an error if the Resource API is not available
|
43
|
-
#
|
44
|
-
# @api private
|
45
|
-
def raise_precondition_error(error)
|
46
|
-
raise PDK::CLI::ExitWithError, _('%{error}: Creating a %{thing_name} needs some local configuration in your module.' \
|
47
|
-
' Please follow the docs at https://puppet.com/docs/puppet/latest/create_types_and_providers_resource_api.html') % {
|
48
|
-
thing_name: friendly_name,
|
49
|
-
error: error,
|
50
|
-
}
|
51
|
-
end
|
52
|
-
#:nocov:
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|