pdk 2.7.1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +10 -50
- data/lib/pdk/analytics/client/google_analytics.rb +22 -26
- data/lib/pdk/analytics/util.rb +0 -1
- data/lib/pdk/analytics.rb +1 -1
- data/lib/pdk/bolt.rb +1 -0
- data/lib/pdk/cli/build.rb +53 -56
- data/lib/pdk/cli/bundle.rb +34 -33
- data/lib/pdk/cli/console.rb +136 -134
- data/lib/pdk/cli/convert.rb +39 -41
- data/lib/pdk/cli/env.rb +49 -47
- data/lib/pdk/cli/errors.rb +1 -2
- data/lib/pdk/cli/exec/command.rb +23 -29
- data/lib/pdk/cli/exec/interactive_command.rb +7 -12
- data/lib/pdk/cli/exec.rb +4 -11
- data/lib/pdk/cli/exec_group.rb +3 -2
- data/lib/pdk/cli/get/config.rb +21 -19
- data/lib/pdk/cli/get.rb +15 -13
- data/lib/pdk/cli/new/class.rb +22 -22
- data/lib/pdk/cli/new/defined_type.rb +22 -22
- data/lib/pdk/cli/new/fact.rb +19 -19
- data/lib/pdk/cli/new/function.rb +20 -20
- data/lib/pdk/cli/new/module.rb +40 -38
- data/lib/pdk/cli/new/provider.rb +19 -19
- data/lib/pdk/cli/new/task.rb +23 -23
- data/lib/pdk/cli/new/test.rb +50 -48
- data/lib/pdk/cli/new/transport.rb +18 -18
- data/lib/pdk/cli/new.rb +11 -9
- data/lib/pdk/cli/release/prep.rb +27 -25
- data/lib/pdk/cli/release/publish.rb +39 -37
- data/lib/pdk/cli/release.rb +152 -149
- data/lib/pdk/cli/remove/config.rb +63 -60
- data/lib/pdk/cli/remove.rb +15 -13
- data/lib/pdk/cli/set/config.rb +91 -89
- data/lib/pdk/cli/set.rb +15 -13
- data/lib/pdk/cli/test/unit.rb +71 -69
- data/lib/pdk/cli/test.rb +9 -7
- data/lib/pdk/cli/update.rb +33 -38
- data/lib/pdk/cli/util/command_redirector.rb +10 -1
- data/lib/pdk/cli/util/interview.rb +11 -4
- data/lib/pdk/cli/util/option_normalizer.rb +3 -5
- data/lib/pdk/cli/util/option_validator.rb +7 -9
- data/lib/pdk/cli/util/update_manager_printer.rb +4 -4
- data/lib/pdk/cli/util.rb +32 -48
- data/lib/pdk/cli/validate.rb +98 -96
- data/lib/pdk/cli.rb +124 -120
- data/lib/pdk/config/ini_file.rb +4 -3
- data/lib/pdk/config/ini_file_setting.rb +6 -10
- data/lib/pdk/config/json.rb +1 -0
- data/lib/pdk/config/json_schema_namespace.rb +5 -10
- data/lib/pdk/config/json_schema_setting.rb +3 -5
- data/lib/pdk/config/json_with_schema.rb +2 -4
- data/lib/pdk/config/namespace.rb +22 -14
- data/lib/pdk/config/setting.rb +5 -6
- data/lib/pdk/config/task_schema.json +116 -0
- data/lib/pdk/config/validator.rb +4 -4
- data/lib/pdk/config/yaml.rb +3 -8
- data/lib/pdk/config/yaml_with_schema.rb +4 -12
- data/lib/pdk/config.rb +47 -51
- data/lib/pdk/context/control_repo.rb +3 -2
- data/lib/pdk/context/module.rb +2 -2
- data/lib/pdk/context/none.rb +2 -2
- data/lib/pdk/context.rb +4 -5
- data/lib/pdk/control_repo.rb +3 -4
- data/lib/pdk/generate/defined_type.rb +3 -3
- data/lib/pdk/generate/fact.rb +3 -2
- data/lib/pdk/generate/function.rb +5 -4
- data/lib/pdk/generate/module.rb +91 -106
- data/lib/pdk/generate/provider.rb +5 -4
- data/lib/pdk/generate/puppet_class.rb +3 -3
- data/lib/pdk/generate/puppet_object.rb +9 -12
- data/lib/pdk/generate/task.rb +11 -10
- data/lib/pdk/generate/transport.rb +8 -7
- data/lib/pdk/generate.rb +1 -1
- data/lib/pdk/logger.rb +3 -2
- data/lib/pdk/module/build.rb +34 -49
- data/lib/pdk/module/convert.rb +13 -22
- data/lib/pdk/module/metadata.rb +53 -61
- data/lib/pdk/module/release.rb +19 -25
- data/lib/pdk/module/update.rb +4 -13
- data/lib/pdk/module/update_manager.rb +18 -25
- data/lib/pdk/module.rb +1 -1
- data/lib/pdk/monkey_patches.rb +268 -0
- data/lib/pdk/report/event.rb +12 -37
- data/lib/pdk/report.rb +11 -7
- data/lib/pdk/template/fetcher/git.rb +7 -8
- data/lib/pdk/template/fetcher/local.rb +1 -0
- data/lib/pdk/template/fetcher.rb +4 -2
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +4 -9
- data/lib/pdk/template/renderer/v1/renderer.rb +19 -20
- data/lib/pdk/template/renderer/v1/template_file.rb +4 -8
- data/lib/pdk/template/renderer/v1.rb +1 -1
- data/lib/pdk/template/renderer.rb +1 -0
- data/lib/pdk/template/template_dir.rb +3 -3
- data/lib/pdk/template.rb +2 -6
- data/lib/pdk/tests/unit.rb +36 -25
- data/lib/pdk/util/bundler.rb +10 -14
- data/lib/pdk/util/changelog_generator.rb +15 -12
- data/lib/pdk/util/env.rb +1 -0
- data/lib/pdk/util/filesystem.rb +18 -17
- data/lib/pdk/util/git.rb +16 -21
- data/lib/pdk/util/json_finder.rb +7 -6
- data/lib/pdk/util/puppet_strings.rb +1 -1
- data/lib/pdk/util/puppet_version.rb +21 -68
- data/lib/pdk/util/ruby_version.rb +9 -13
- data/lib/pdk/util/template_uri.rb +17 -29
- data/lib/pdk/util/vendored_file.rb +5 -18
- data/lib/pdk/util/windows/api_types.rb +70 -64
- data/lib/pdk/util/windows/file.rb +31 -27
- data/lib/pdk/util/windows/process.rb +59 -61
- data/lib/pdk/util/windows/string.rb +19 -12
- data/lib/pdk/util.rb +13 -21
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +1 -1
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +25 -25
- data/lib/pdk/validate/external_command_validator.rb +6 -1
- data/lib/pdk/validate/internal_ruby_validator.rb +5 -4
- data/lib/pdk/validate/invokable_validator.rb +30 -20
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +12 -14
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +13 -15
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +16 -18
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +14 -14
- data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +16 -18
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -1
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +10 -11
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +1 -1
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +19 -24
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +11 -13
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +1 -1
- data/lib/pdk/validate/validator.rb +4 -2
- data/lib/pdk/validate/validator_group.rb +6 -3
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +27 -36
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +1 -1
- data/lib/pdk/validate.rb +6 -6
- data/lib/pdk/version.rb +2 -2
- data/lib/pdk.rb +12 -12
- metadata +27 -35
- data/lib/pdk/cli/config/get.rb +0 -26
- data/lib/pdk/cli/config.rb +0 -22
- data/lib/pdk/cli/module/build.rb +0 -12
- data/lib/pdk/cli/module/generate.rb +0 -47
- data/lib/pdk/cli/module.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c39902d0ebbac37358fd3fccf5de760b47f77860054b08864ccdae63150b7597
|
4
|
+
data.tar.gz: 6a4d8beb3013edf1ed946b9cf94cd90b055ad63500102e131734600c81c3a5a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7af78ce8b0c4bb9122081a2c6449d862da04c9fec85d428b2e8ace3e88a74930fcf809462062b07994307c54c3ee5a827a83ae26e5c67b95f659c3f5c0cb89b5
|
7
|
+
data.tar.gz: c5af71c375d94c9e22f4c7ae284213a39aaa87b8bc21980580ce4e79743979d4cbb967f330c775dcd2ebc4d3046c4c9c5080480172e07dec33afd9546b94da7e
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,42 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
|
6
6
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
|
7
7
|
|
8
|
+
## [v3.0.1](https://github.com/puppetlabs/pdk/tree/v3.0.1) - 2023-12-07
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.0.0...v3.0.1)
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- (CAT-345) Update doc links where needed [#1285](https://github.com/puppetlabs/pdk/pull/1285) ([david22swan](https://github.com/david22swan))
|
15
|
+
- (CAT-270) Adjusting expected Puppet/Ruby versions [#1283](https://github.com/puppetlabs/pdk/pull/1283) ([LukasAud](https://github.com/LukasAud))
|
16
|
+
- (maint) - add stricter puppetlabs_spec_helper dependency [#1280](https://github.com/puppetlabs/pdk/pull/1280) ([jordanbreen28](https://github.com/jordanbreen28))
|
17
|
+
- (PUPDOC-5439) Add Trademark icon [#1277](https://github.com/puppetlabs/pdk/pull/1277) ([pmcmaw](https://github.com/pmcmaw))
|
18
|
+
|
19
|
+
## [v3.0.0](https://github.com/puppetlabs/pdk/tree/v3.0.0) - 2023-07-04
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.7.1...v3.0.0)
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
- (CONT-1134) Bump PDK Templates REF [#1264](https://github.com/puppetlabs/pdk/pull/1264) ([chelnak](https://github.com/chelnak))
|
25
|
+
- (CONT-1154) Disable console command [#1263](https://github.com/puppetlabs/pdk/pull/1263) ([chelnak](https://github.com/chelnak))
|
26
|
+
- (CONT-1130) Bump PDK gem version [#1260](https://github.com/puppetlabs/pdk/pull/1260) ([chelnak](https://github.com/chelnak))
|
27
|
+
- (CONT-1027) Deprecate pe-version option [#1252](https://github.com/puppetlabs/pdk/pull/1252) ([chelnak](https://github.com/chelnak))
|
28
|
+
- (CONT-1025) Remove module command [#1250](https://github.com/puppetlabs/pdk/pull/1250) ([chelnak](https://github.com/chelnak))
|
29
|
+
- (CONT-1024) Remove config command [#1249](https://github.com/puppetlabs/pdk/pull/1249) ([chelnak](https://github.com/chelnak))
|
30
|
+
- (CONT-755) - Bump gem version [#1240](https://github.com/puppetlabs/pdk/pull/1240) ([chelnak](https://github.com/chelnak))
|
31
|
+
- (CONT-755) Ruby 3 / Puppet 8 support [#1230](https://github.com/puppetlabs/pdk/pull/1230) ([chelnak](https://github.com/chelnak))
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- (CONT-1053) Update bundle command [#1255](https://github.com/puppetlabs/pdk/pull/1255) ([chelnak](https://github.com/chelnak))
|
36
|
+
- (ISS-1123) Verbose output w/ junit file [#1246](https://github.com/puppetlabs/pdk/pull/1246) ([coreymbe](https://github.com/coreymbe))
|
37
|
+
- Take "operatingsystem_support" parameter from answer.json [#1165](https://github.com/puppetlabs/pdk/pull/1165) ([me-minus](https://github.com/me-minus))
|
38
|
+
|
39
|
+
### Fixed
|
40
|
+
|
41
|
+
- (CONT-1069) Update compatibility handling [#1259](https://github.com/puppetlabs/pdk/pull/1259) ([chelnak](https://github.com/chelnak))
|
42
|
+
- (CONT-935) Fix issues with PDK package and tests [#1248](https://github.com/puppetlabs/pdk/pull/1248) ([chelnak](https://github.com/chelnak))
|
43
|
+
|
8
44
|
## [v2.7.1](https://github.com/puppetlabs/pdk/tree/v2.7.1) - 2023-03-24
|
9
45
|
|
10
46
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.7.0...v2.7.1)
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# pdk
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Code Owners](https://img.shields.io/badge/owners-DevX--team-blue)](https://github.com/puppetlabs/pdk/blob/main/CODEOWNERS)
|
4
|
+
[![ci](https://github.com/puppetlabs/pdk/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/pdk/actions/workflows/ci.yml)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/pdk.svg)](https://badge.fury.io/rb/pdk)
|
4
6
|
|
5
7
|
* [Installation](#installation)
|
6
8
|
* [Basic usage](#basic-usage)
|
@@ -20,7 +22,6 @@ PDK includes the following tools:
|
|
20
22
|
|facterdb|A gem that contains facts for Operating Systems.| N |
|
21
23
|
|metadata-json-lint|Validates and lints `metadata.json` files in modules against Puppet module metadata style guidelines.| N |
|
22
24
|
|pdk|Tool to generate and test modules and module content, such as classes, from the command line.| Y |
|
23
|
-
|puppet-debugger|Provides a REPL based debugger console.| N |
|
24
25
|
|puppet-lint|Checks your Puppet code against the recommendations in the Puppet language style guide.| Y |
|
25
26
|
|puppet-syntax|Checks for correct syntax in Puppet manifests, templates, and Hiera YAML.| N |
|
26
27
|
|puppetlabs_spec_helper|Provides classes, methods, and Rake tasks to help with spec testing Puppet code.| Y |
|
@@ -97,7 +98,7 @@ This command validates the metadata, Puppet code syntax and style, and Ruby synt
|
|
97
98
|
|
98
99
|
### Run unit tests
|
99
100
|
|
100
|
-
PDK's [default template](https://github.com/puppetlabs/pdk-templates) sets up [rspec](http://rspec.info/) for Ruby-level unit testing, and [rspec-puppet](https://github.com/
|
101
|
+
PDK's [default template](https://github.com/puppetlabs/pdk-templates) sets up [rspec](http://rspec.info/) for Ruby-level unit testing, and [rspec-puppet](https://github.com/puppetlabs/rspec-puppet/) for catalog-level unit testing.
|
101
102
|
|
102
103
|
In the module's directory, run unit tests with:
|
103
104
|
|
@@ -107,52 +108,6 @@ pdk test unit
|
|
107
108
|
|
108
109
|
This command runs all available unit tests.
|
109
110
|
|
110
|
-
## Experimental features
|
111
|
-
|
112
|
-
### `pdk console` command
|
113
|
-
The pdk console command executes a session of the puppet debugger when inside a module and allows for exploration of puppet code. See the official [puppet debugger site](https://www.puppet-debugger.com) for more info and the official docs [site here.](https://docs.puppet-debugger.com)
|
114
|
-
|
115
|
-
To use, execute `pdk console` from inside your module directory. You can also supply the `--puppet-version` or `--pe-version` or `--puppet-dev` to swap out the puppet version when using the console.
|
116
|
-
|
117
|
-
Example (from within a module):
|
118
|
-
|
119
|
-
* `pdk console --puppet-version=5`
|
120
|
-
* `pdk console --pe-version=2018.1`
|
121
|
-
|
122
|
-
The `pdk console` command will also pass through any puppet debugger arguments you wish to use.
|
123
|
-
|
124
|
-
Example:
|
125
|
-
|
126
|
-
* `pdk console --no-facterdb`
|
127
|
-
* `pdk console --play https://gist.github.com/logicminds/4f6bcfd723c92aad1f01f6a800319fa4`
|
128
|
-
* `pdk console -e "md5('sdfasdfasdf')" --run-once --quiet`
|
129
|
-
|
130
|
-
Use `pdk console -h` for a further explanation of pass through arguments.
|
131
|
-
|
132
|
-
If you receive the following error you do not have the puppet-debugger gem installed.
|
133
|
-
|
134
|
-
```
|
135
|
-
pdk console -h
|
136
|
-
Error: Unknown Puppet subcommand 'debugger'
|
137
|
-
See 'puppet help' for help on available puppet subcommands
|
138
|
-
```
|
139
|
-
|
140
|
-
To fix this you will need to add the following entry to your .sync.yml file and run pdk update:
|
141
|
-
|
142
|
-
```
|
143
|
-
Gemfile:
|
144
|
-
required:
|
145
|
-
":development":
|
146
|
-
- gem: puppet-debugger
|
147
|
-
version: "~> 0.14"
|
148
|
-
```
|
149
|
-
|
150
|
-
**NOTE**: The puppet-debugger gem has been added to the [puppet-module-* gems](https://github.com/puppetlabs/puppet-module-gems/pull/117), so once you get the gem update you no longer need the .sync.yml entry.
|
151
|
-
|
152
|
-
### `pdk bundle` command
|
153
|
-
|
154
|
-
This command executes arbitrary commands in a bundler context within the module you're currently working on. Arguments to this command are passed straight through to bundler. This command is experimental and can lead to errors that can't be resolved by PDK itself.
|
155
|
-
|
156
111
|
## Module Compatibility
|
157
112
|
|
158
113
|
**PDK Version Compatibility:** Modules created with PDK validate against and run on all Puppet and Ruby version combinations currently under maintenance (see https://docs.puppet.com/puppet/latest/about_agent.html and https://puppet.com/misc/puppet-enterprise-lifecycle)
|
@@ -161,6 +116,11 @@ This command executes arbitrary commands in a bundler context within the module
|
|
161
116
|
|
162
117
|
PDK encourages community contributions. See the [CONTRIBUTING.md](CONTRIBUTING.md) file for development notes.
|
163
118
|
|
119
|
+
## License
|
120
|
+
|
121
|
+
This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT.
|
122
|
+
|
164
123
|
## Contact Information
|
165
124
|
|
166
|
-
|
125
|
+
* [For reporting bugs](https://github.com/puppetlabs/pdk/blob/main/CONTRIBUTING.md#reporting-bugs)
|
126
|
+
* To contact us with questions, [join the Puppet Community on Slack](https://slack.puppet.com/)
|
@@ -8,18 +8,13 @@ module PDK
|
|
8
8
|
TRACKING_URL = 'https://google-analytics.com/collect'.freeze
|
9
9
|
CUSTOM_DIMENSIONS = {
|
10
10
|
operating_system: :cd1,
|
11
|
-
output_format:
|
12
|
-
ruby_version:
|
13
|
-
cli_options:
|
14
|
-
env_vars:
|
11
|
+
output_format: :cd2,
|
12
|
+
ruby_version: :cd3,
|
13
|
+
cli_options: :cd4,
|
14
|
+
env_vars: :cd5
|
15
15
|
}.freeze
|
16
16
|
|
17
|
-
attr_reader :user_id
|
18
|
-
attr_reader :logger
|
19
|
-
attr_reader :app_name
|
20
|
-
attr_reader :app_id
|
21
|
-
attr_reader :app_version
|
22
|
-
attr_reader :app_installer
|
17
|
+
attr_reader :user_id, :logger, :app_name, :app_id, :app_version, :app_installer
|
23
18
|
|
24
19
|
def initialize(opts)
|
25
20
|
# lazy-load expensive gem code
|
@@ -42,14 +37,14 @@ module PDK
|
|
42
37
|
|
43
38
|
def screen_view(screen, **kwargs)
|
44
39
|
custom_dimensions = walk_keys(kwargs) do |k|
|
45
|
-
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '%{key}'"
|
40
|
+
CUSTOM_DIMENSIONS[k] || raise(format("Unknown analytics key '%{key}'", key: k))
|
46
41
|
end
|
47
42
|
|
48
43
|
screen_view_params = {
|
49
44
|
# Type
|
50
|
-
t:
|
45
|
+
t: 'screenview',
|
51
46
|
# Screen Name
|
52
|
-
cd: screen
|
47
|
+
cd: screen
|
53
48
|
}.merge(custom_dimensions)
|
54
49
|
|
55
50
|
submit(base_params.merge(screen_view_params))
|
@@ -57,16 +52,16 @@ module PDK
|
|
57
52
|
|
58
53
|
def event(category, action, label: nil, value: nil, **kwargs)
|
59
54
|
custom_dimensions = walk_keys(kwargs) do |k|
|
60
|
-
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '%{key}'"
|
55
|
+
CUSTOM_DIMENSIONS[k] || raise(format("Unknown analytics key '%{key}'", key: k))
|
61
56
|
end
|
62
57
|
|
63
58
|
event_params = {
|
64
59
|
# Type
|
65
|
-
t:
|
60
|
+
t: 'event',
|
66
61
|
# Event Category
|
67
62
|
ec: category,
|
68
63
|
# Event Action
|
69
|
-
ea: action
|
64
|
+
ea: action
|
70
65
|
}.merge(custom_dimensions)
|
71
66
|
|
72
67
|
# Event Label
|
@@ -95,23 +90,23 @@ module PDK
|
|
95
90
|
require 'locale'
|
96
91
|
|
97
92
|
{
|
98
|
-
v:
|
93
|
+
v: PROTOCOL_VERSION,
|
99
94
|
# Client ID
|
100
|
-
cid:
|
95
|
+
cid: user_id,
|
101
96
|
# Tracking ID
|
102
|
-
tid:
|
97
|
+
tid: app_id,
|
103
98
|
# Application Name
|
104
|
-
an:
|
99
|
+
an: app_name,
|
105
100
|
# Application Version
|
106
|
-
av:
|
101
|
+
av: app_version,
|
107
102
|
# Application Installer ID
|
108
103
|
aiid: app_installer,
|
109
104
|
# Anonymize IPs
|
110
|
-
aip:
|
105
|
+
aip: true,
|
111
106
|
# User locale
|
112
|
-
ul:
|
107
|
+
ul: Locale.current.to_rfc,
|
113
108
|
# Custom Dimension 1 (Operating System)
|
114
|
-
cd1:
|
109
|
+
cd1: @os.value
|
115
110
|
}
|
116
111
|
end
|
117
112
|
|
@@ -128,12 +123,13 @@ module PDK
|
|
128
123
|
private
|
129
124
|
|
130
125
|
def walk_keys(data, &block)
|
131
|
-
|
126
|
+
case data
|
127
|
+
when Hash
|
132
128
|
data.each_with_object({}) do |(k, v), acc|
|
133
129
|
v = walk_keys(v, &block)
|
134
130
|
acc[yield(k)] = v
|
135
131
|
end
|
136
|
-
|
132
|
+
when Array
|
137
133
|
data.map { |v| walk_keys(v, &block) }
|
138
134
|
else
|
139
135
|
data
|
data/lib/pdk/analytics/util.rb
CHANGED
data/lib/pdk/analytics.rb
CHANGED
data/lib/pdk/bolt.rb
CHANGED
data/lib/pdk/cli/build.rb
CHANGED
@@ -1,78 +1,75 @@
|
|
1
|
-
module PDK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module PDK
|
2
|
+
module CLI
|
3
|
+
@build_cmd = @base_cmd.define_command do
|
4
|
+
name 'build'
|
5
|
+
usage 'build [options]'
|
6
|
+
summary 'Builds a package from the module that can be published to the Puppet Forge.'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
option nil, 'target-dir',
|
9
|
+
'The target directory where you want PDK to write the package.',
|
10
|
+
argument: :required, default: File.join(Dir.pwd, 'pkg')
|
10
11
|
|
11
|
-
|
12
|
+
option nil, 'force', 'Skips the prompts and builds the module package.'
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
run do |opts, _args, _cmd|
|
15
|
+
require 'pdk/module/build'
|
16
|
+
require 'pdk/module/metadata'
|
17
|
+
require 'pdk/cli/util'
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# Make sure build is being run in a valid module directory with a metadata.json
|
20
|
+
PDK::CLI::Util.ensure_in_module!(
|
21
|
+
message: '`pdk build` can only be run from inside a valid module with a metadata.json.',
|
22
|
+
log_level: :info
|
23
|
+
)
|
23
24
|
|
24
|
-
|
25
|
+
PDK::CLI::Util.analytics_screen_view('build', opts)
|
25
26
|
|
26
|
-
|
27
|
+
module_metadata = PDK::Module::Metadata.from_file('metadata.json')
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
# TODO: Ensure forge metadata has been set, or call out to interview
|
30
|
+
# to set it.
|
31
|
+
#
|
32
|
+
unless module_metadata.forge_ready?
|
33
|
+
if opts[:force]
|
34
|
+
PDK.logger.warn "This module is missing the following fields in the metadata.json: #{module_metadata.missing_fields.join(', ')}. " \
|
35
|
+
'These missing fields may affect the visibility of the module on the Forge.'
|
36
|
+
else
|
37
|
+
module_metadata.interview_for_forge!
|
38
|
+
module_metadata.write!('metadata.json')
|
39
|
+
end
|
38
40
|
end
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
+
builder = PDK::Module::Build.new(opts)
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
unless opts[:force]
|
45
|
+
if builder.package_already_exists?
|
46
|
+
PDK.logger.info format("The file '%{package}' already exists.", package: builder.package_file)
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
unless PDK::CLI::Util.prompt_for_yes('Overwrite?', default: false)
|
49
|
+
PDK.logger.info 'Build cancelled; exiting.'
|
50
|
+
exit 0
|
51
|
+
end
|
50
52
|
end
|
51
|
-
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
unless builder.module_pdk_compatible?
|
55
|
+
PDK.logger.info 'This module is not compatible with PDK, so PDK can not validate or test this build. ' \
|
56
|
+
'Unvalidated modules may have errors when uploading to the Forge. ' \
|
57
|
+
'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.'
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
unless PDK::CLI::Util.prompt_for_yes('Continue build without converting?')
|
60
|
+
PDK.logger.info 'Build cancelled; exiting.'
|
61
|
+
exit 0
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
63
|
-
end
|
64
65
|
|
65
|
-
|
66
|
-
module_name: module_metadata.data['name'],
|
67
|
-
module_version: module_metadata.data['version'],
|
68
|
-
}
|
66
|
+
PDK.logger.info format('Building %{module_name} version %{module_version}', module_name: module_metadata.data['name'], module_version: module_metadata.data['version'])
|
69
67
|
|
70
|
-
|
68
|
+
builder.build
|
71
69
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
70
|
+
PDK.logger.info format('Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}', package_name: module_metadata.data['name'],
|
71
|
+
package_path: builder.package_file)
|
72
|
+
end
|
76
73
|
end
|
77
74
|
end
|
78
75
|
end
|
data/lib/pdk/cli/bundle.rb
CHANGED
@@ -1,47 +1,48 @@
|
|
1
|
-
module PDK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module PDK
|
2
|
+
module CLI
|
3
|
+
@bundle_cmd = @base_cmd.define_command do
|
4
|
+
name 'bundle'
|
5
|
+
usage 'bundle [bundler_options]'
|
6
|
+
summary 'Command pass-through to bundler'
|
7
|
+
description <<~EOF
|
8
|
+
For advanced users, pdk bundle runs arbitrary commands in the bundler environment that pdk manages.
|
9
|
+
Careless use of this command can lead to errors that pdk can't help recover from.
|
10
|
+
EOF
|
11
|
+
skip_option_parsing
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
require 'pdk/util/bundler'
|
13
|
+
run do |_opts, args, _cmd|
|
14
|
+
require 'pdk/util/bundler'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
PDK::CLI::Util.ensure_in_module!(
|
17
|
+
message: '`pdk bundle` can only be run from inside a valid module directory.'
|
18
|
+
)
|
19
19
|
|
20
|
-
|
20
|
+
PDK::CLI::Util.validate_puppet_version_opts({})
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
screen_view_name = ['bundle']
|
23
|
+
screen_view_name << args[0] if args.size >= 1
|
24
|
+
screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'
|
25
25
|
|
26
|
-
|
26
|
+
PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
# Ensure that the correct Ruby is activated before running command.
|
29
|
+
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
|
30
|
+
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
31
31
|
|
32
|
-
|
32
|
+
gemfile_env = PDK::Util::Bundler::BundleHelper.gemfile_env(puppet_env[:gemset])
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
require 'pdk/cli/exec'
|
35
|
+
require 'pdk/cli/exec/interactive_command'
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
command = PDK::CLI::Exec::InteractiveCommand.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
|
38
|
+
c.context = :pwd
|
39
|
+
c.update_environment(gemfile_env)
|
40
|
+
end
|
41
41
|
|
42
|
-
|
42
|
+
result = command.execute!
|
43
43
|
|
44
|
-
|
44
|
+
exit result[:exit_code]
|
45
|
+
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|