pdk 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +50 -250
- data/lib/pdk/cli.rb +2 -1
- data/lib/pdk/cli/exec.rb +47 -38
- data/lib/pdk/cli/exec_group.rb +53 -0
- data/lib/pdk/cli/new/class.rb +1 -5
- data/lib/pdk/cli/util.rb +11 -0
- data/lib/pdk/cli/util/interview.rb +1 -0
- data/lib/pdk/cli/validate.rb +17 -5
- data/lib/pdk/generators/module.rb +36 -18
- data/lib/pdk/generators/puppet_class.rb +1 -4
- data/lib/pdk/generators/puppet_object.rb +1 -1
- data/lib/pdk/logger.rb +4 -0
- data/lib/pdk/module/metadata.rb +1 -0
- data/lib/pdk/module/templatedir.rb +9 -3
- data/lib/pdk/monkey_patches.rb +13 -0
- data/lib/pdk/report/event.rb +4 -2
- data/lib/pdk/util.rb +14 -0
- data/lib/pdk/util/bundler.rb +5 -11
- data/lib/pdk/validators/base_validator.rb +67 -6
- data/lib/pdk/validators/metadata/metadata_json_lint.rb +3 -3
- data/lib/pdk/validators/metadata/metadata_syntax.rb +33 -13
- data/lib/pdk/validators/puppet/puppet_lint.rb +1 -1
- data/lib/pdk/validators/puppet/puppet_syntax.rb +1 -1
- data/lib/pdk/validators/ruby/rubocop.rb +5 -1
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +240 -117
- metadata +9 -8
- data/locales/de/pdk.po +0 -604
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12446b239a4b17f9ed1845579d087414bdacbd77
|
4
|
+
data.tar.gz: 2779afaa6e16fb2476fe9a3a8b914c8767f26aeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79144605c521beafd6e98ce924b114f69ed1c0c662c5896846e248ea54d80061973ec557efc829dfc8ec054ee21ff744279bb1cf037a244cdaa1cdac73d93baa
|
7
|
+
data.tar.gz: ec55661f0d0d7a15a96b7049c22f201ac4b55af5732ec99d56decadafef1fccd18a0b5888ba80a18c3352c7a52ea7fb57ee83062aaf890c58d216f8561d47d37
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,29 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
5
|
|
6
|
+
## [v1.0.0](https://github.com/puppetlabs/pdk/tree/v1.0.0) (2017-08-15)
|
7
|
+
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.6.0...v1.0.0)
|
9
|
+
|
10
|
+
**Implemented enhancements:**
|
11
|
+
|
12
|
+
- \(PDK-395\) Use vendored pdk-module-template repo when available [\#255](https://github.com/puppetlabs/pdk/pull/255) ([scotje](https://github.com/scotje))
|
13
|
+
- Move content from README to official docs site [\#252](https://github.com/puppetlabs/pdk/pull/252) ([jbondpdx](https://github.com/jbondpdx))
|
14
|
+
- \(PDK-367\) Update questionnaire wording [\#251](https://github.com/puppetlabs/pdk/pull/251) ([DavidS](https://github.com/DavidS))
|
15
|
+
- \(PDK-406\) Add GEM\_HOME and GEM\_PATH bin dirs to PATH when executing commands [\#249](https://github.com/puppetlabs/pdk/pull/249) ([rodjek](https://github.com/rodjek))
|
16
|
+
- \(PDK-401, PDK-402, PDK-403, PDK-404\) Update validators to handle targets better [\#248](https://github.com/puppetlabs/pdk/pull/248) ([bmjen](https://github.com/bmjen))
|
17
|
+
- \(maint\) Allow bundler to install gems in parallel [\#245](https://github.com/puppetlabs/pdk/pull/245) ([james-stocks](https://github.com/james-stocks))
|
18
|
+
- \(PDK-397\) Log output of bundler commands at appropriate levels [\#243](https://github.com/puppetlabs/pdk/pull/243) ([scotje](https://github.com/scotje))
|
19
|
+
- \(PDK-396\) Disable spinners in debug mode [\#233](https://github.com/puppetlabs/pdk/pull/233) ([rodjek](https://github.com/rodjek))
|
20
|
+
- \(PDK-388, PDK-392\) Add README, CHANGELOG, and puppet requirement to module generation [\#232](https://github.com/puppetlabs/pdk/pull/232) ([bmjen](https://github.com/bmjen))
|
21
|
+
- \(SDK-144\) Add option to run validate in parallel [\#144](https://github.com/puppetlabs/pdk/pull/144) ([austb](https://github.com/austb))
|
22
|
+
|
23
|
+
**Fixed bugs:**
|
24
|
+
|
25
|
+
- Running PDK native packages on Windows under ConEmu fails [\#220](https://github.com/puppetlabs/pdk/issues/220)
|
26
|
+
- \(PDK-407\) Validate module interview confirmation answer [\#237](https://github.com/puppetlabs/pdk/pull/237) ([rodjek](https://github.com/rodjek))
|
27
|
+
- \(PDK-386\) Remove parameter options from 'new class' [\#236](https://github.com/puppetlabs/pdk/pull/236) ([austb](https://github.com/austb))
|
28
|
+
|
6
29
|
## [v0.6.0](https://github.com/puppetlabs/pdk/tree/v0.6.0) (2017-08-08)
|
7
30
|
|
8
31
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v0.5.0...v0.6.0)
|
@@ -10,6 +33,7 @@ All notable changes to this project will be documented in this file.
|
|
10
33
|
**Implemented enhancements:**
|
11
34
|
|
12
35
|
- \(MAINT\) Improve moduleroot error message [\#224](https://github.com/puppetlabs/pdk/pull/224) ([DavidS](https://github.com/DavidS))
|
36
|
+
- \(MAINT\) workaround rspec-puppt-facts being case-sensitive for operatingsystem filters [\#222](https://github.com/puppetlabs/pdk/pull/222) ([DavidS](https://github.com/DavidS))
|
13
37
|
- \(PDK-354\) Change PDK::Logger to write to STDERR [\#217](https://github.com/puppetlabs/pdk/pull/217) ([scotje](https://github.com/scotje))
|
14
38
|
- \(SDK-331\) Use vendored Gemfile.lock when available and needed [\#215](https://github.com/puppetlabs/pdk/pull/215) ([scotje](https://github.com/scotje))
|
15
39
|
- \(maint\) Expose message when FileUtils.mkdir\_p fails during module generation [\#209](https://github.com/puppetlabs/pdk/pull/209) ([rodjek](https://github.com/rodjek))
|
data/README.md
CHANGED
@@ -1,57 +1,41 @@
|
|
1
1
|
# pdk [![Build Status](https://travis-ci.org/puppetlabs/pdk.svg?branch=master)](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=master)](https://coveralls.io/github/puppetlabs/pdk?branch=master)
|
2
2
|
|
3
|
+
* [Installation](#installation)
|
4
|
+
* [Basic usage](#basic-usage)
|
5
|
+
* [Experimental features](#experimental-features)
|
6
|
+
* [Module compatibility](#module-compatibility)
|
7
|
+
* [Contributing](#contributing)
|
3
8
|
|
4
|
-
|
9
|
+
The Puppet Development Kit (PDK) includes key Puppet code development and testing tools for Linux, Windows, and OS X workstations, so you can install one package with the tools you need to create and validate new modules.
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
Download and install the newest package matching your platform from [here](https://drive.google.com/drive/folders/0Bz0tCHSb1u41alR4MmZfRHBTV1k?usp=sharing). If you are using Windows, please remember to close any open PowerShell windows.
|
9
|
-
|
10
|
-
### Windows
|
11
|
-
|
12
|
-
On Windows you should run PDK from PowerShell and `pdk` will be available in your PowerShell prompt after installation.
|
11
|
+
PDK includes testing tools, a complete module skeleton, and command line tools to help you create, validate, and run tests on Puppet modules. PDK also includes all dependencies needed for its use.
|
13
12
|
|
14
|
-
|
13
|
+
PDK includes the following tools:
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
Tool | Description
|
16
|
+
----------------|-------------------------
|
17
|
+
metadata-json-lint | Validates and lints `metadata.json` files in modules against Puppet's module metadatastyle guidelines.
|
18
|
+
pdk | Command line tool for generating and testing modules
|
19
|
+
puppet-lint | Checks your Puppet code against the recommendations in the Puppet Language style guide.
|
20
|
+
puppet-syntax | Checks for correct syntax in Puppet manifests, templates, and Hiera YAML.
|
21
|
+
puppetlabs_spec_helper | Provides classes, methods, and Rake tasks to help with spec testing Puppet code.
|
22
|
+
rspec-puppet | Tests the behavior of Puppet when it compiles your manifests into a catalog of Puppet resources.
|
23
|
+
rspec-puppet-facts | Adds support for running rspec-puppet tests against the facts for your supported operating systems.
|
19
24
|
|
20
|
-
If no output is returned, load the `PuppetDevelopmentKit` module by running the following command:
|
21
|
-
|
22
|
-
```
|
23
|
-
Import-Module -Name PuppetDevelopmentKit
|
24
|
-
```
|
25
|
-
|
26
|
-
> Note: On PowerShell version 3 and above, PowerShell modules are loaded automatically so this step shouldn't be necessary.
|
27
|
-
|
28
|
-
You should set your script execution policy to at least [RemoteSigned](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.security/set-executionpolicy), if it's not already, to allow the PowerShell integration to work.
|
29
|
-
|
30
|
-
You can check your ExecutionPolicy by running the following command from a PowerShell prompt:
|
31
|
-
|
32
|
-
```
|
33
|
-
Get-ExecutionPolicy
|
34
|
-
```
|
35
25
|
|
36
|
-
|
26
|
+
## Installation
|
37
27
|
|
38
|
-
|
39
|
-
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
|
40
|
-
```
|
28
|
+
Download and install the newest package matching your platform from the [download](https://puppet.com/download-puppet-development-kit) page. If you are using Windows, remember to close any open PowerShell windows.
|
41
29
|
|
42
|
-
|
30
|
+
For complete installation information, see the [PDK documentation](https://docs.puppet.com/pdk/latest/pdk_install.html).
|
43
31
|
|
44
|
-
|
45
|
-
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
46
|
-
```
|
47
|
-
|
48
|
-
For more information about PowerShell `ExecutionPolicies` or how to change them, see [about_Execution_Policies](http://go.microsoft.com/fwlink/?LinkID=135170).
|
32
|
+
## Basic usage
|
49
33
|
|
50
|
-
|
34
|
+
PDK can generate modules and classes, validate module metadata, style, and syntax, and run unit tests. This README contains very basic usage information---for complete usage information, see the [PDK documentation](https://docs.puppet.com/pdk/).
|
51
35
|
|
52
|
-
### Generate a
|
36
|
+
### Generate a module
|
53
37
|
|
54
|
-
|
38
|
+
Generates the basic components of a module and set up an infrastructure for testing it with PDK.
|
55
39
|
|
56
40
|
1. Run the `pdk new module` command, specifying the name of the new module:
|
57
41
|
|
@@ -59,232 +43,49 @@ To get started, generate a new module from the default template.
|
|
59
43
|
pdk new module my_module
|
60
44
|
```
|
61
45
|
|
62
|
-
This
|
46
|
+
This command asks a series of metadata questions and then generates the basic components of a new module.
|
63
47
|
|
64
|
-
###
|
48
|
+
### Generate a class
|
65
49
|
|
66
|
-
|
50
|
+
To generate a class in your module, use the `pdk new class` command, specifying the name of your new class. To generate the main class of the module, which is defined in an `init.pp` file, give the class the same name as the module.
|
67
51
|
|
68
|
-
|
69
|
-
|
70
|
-
```
|
52
|
+
1. From the command line, in your module's directory, run `pdk new class class_name`.
|
53
|
+
```
|
71
54
|
|
72
|
-
|
55
|
+
PDK creates the new class manifest and a test file (as `class_name_spec.rb`) in your module's `/spec/classes` directory.
|
73
56
|
|
74
|
-
```
|
75
|
-
pdk (INFO): Running all available validators...
|
76
|
-
[✔] Checking for missing Gemfile dependencies
|
77
|
-
[✔] Checking metadata.json
|
78
|
-
[✔] Checking Ruby code style
|
79
|
-
[...]
|
80
|
-
```
|
81
57
|
|
82
|
-
|
83
|
-
separated list of names) as an argument to `pdk validate`.
|
58
|
+
### Validating a module
|
84
59
|
|
85
|
-
|
86
|
-
$ pdk validate metadata
|
87
|
-
[✔] Checking for missing Gemfile dependencies
|
88
|
-
[✔] Checking metadata.json
|
89
|
-
```
|
60
|
+
PDK can validate the well-formedness of the module and style and syntax of its files.
|
90
61
|
|
91
|
-
|
92
|
-
module that it should validate, however validations can be run on specific
|
93
|
-
files or directories by providing them as arguments to `pdk validate`
|
62
|
+
1. In the module's directory, run:
|
94
63
|
|
95
64
|
```
|
96
|
-
|
97
|
-
[✔] Checking for missing Gemfile dependencies
|
98
|
-
[✔] Checking Ruby code style
|
65
|
+
pdk validate
|
99
66
|
```
|
100
67
|
|
101
|
-
|
102
|
-
both rubocop and puppet-lint can automatically correct many common code style
|
103
|
-
problems). To enable this functionality, run `pdk validate` with the
|
104
|
-
`--auto-correct` option.
|
105
|
-
|
106
|
-
```
|
107
|
-
$ pdk validate --auto-correct
|
108
|
-
pdk (INFO): Running all available validators...
|
109
|
-
[✔] Checking for missing Gemfile dependencies
|
110
|
-
[✔] Checking metadata.json
|
111
|
-
[✔] Checking Puppet manifest style
|
112
|
-
[✔] Checking Puppet manifest syntax
|
113
|
-
[✔] Checking Ruby code style
|
114
|
-
manifests/init.pp:1:10: corrected: double quoted string containing no variables
|
115
|
-
```
|
68
|
+
This command validates the metadata, Puppet code syntax and style, and Ruby syntax and style for the entire module.
|
116
69
|
|
117
70
|
### Run unit tests
|
118
71
|
|
119
|
-
|
72
|
+
PDK's default template sets up [rspec](http://rspec.info/) for Ruby-level unit testing, and [rspec-puppet](https://github.com/rodjek/rspec-puppet/) for catalog-level unit testing.
|
120
73
|
|
121
|
-
|
74
|
+
In the module's directory, run unit tests with:
|
122
75
|
|
123
76
|
```
|
124
77
|
pdk test unit
|
125
78
|
```
|
126
79
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
## Reference
|
131
|
-
|
132
|
-
### `pdk new module` command
|
133
|
-
|
134
|
-
Generates a new module.
|
135
|
-
|
136
|
-
Usage:
|
137
|
-
|
138
|
-
```
|
139
|
-
pdk new module [--template-url=git_url] [--license=spdx_identifier] module_name [target_dir]
|
140
|
-
```
|
141
|
-
|
142
|
-
The `pdk new module` command accepts the following arguments and options. Arguments are optional unless otherwise specified.
|
143
|
-
|
144
|
-
#### `--template-url=git_url`
|
80
|
+
This command runs all available unit tests.
|
145
81
|
|
146
|
-
|
147
|
-
|
148
|
-
#### `--license=spdx_identifier`
|
149
|
-
|
150
|
-
Specifies the license this module is written under. See https://spdx.org/licenses/ for a list of open source licenses, or use `proprietary`. Defaults to `Apache-2.0`.
|
151
|
-
|
152
|
-
#### `--skip-interview`
|
153
|
-
|
154
|
-
Suppress interactive queries for initial values. All questions will use the default values.
|
155
|
-
|
156
|
-
#### `module_name`
|
157
|
-
|
158
|
-
**Required**. Specifies the name of the module being created. e.g.: `my_module`
|
159
|
-
|
160
|
-
#### `target_dir`
|
161
|
-
|
162
|
-
Specifies the directory that the new module will be created in. Defaults to creating a new directory with the given `module_name` inside the current directory.
|
163
|
-
|
164
|
-
### `pdk new class` command
|
165
|
-
|
166
|
-
Generates a new class and skeleton test for it in the current module.
|
167
|
-
|
168
|
-
Usage:
|
169
|
-
|
170
|
-
```
|
171
|
-
pdk new class [--template-url=git_url] <class_name> [parameter_name[:parameter_type]] [parameter_name[:parameter_type]] ...
|
172
|
-
```
|
173
|
-
|
174
|
-
e.g.
|
175
|
-
|
176
|
-
```
|
177
|
-
cd my_module
|
178
|
-
pdk new class my_class "ensure:Enum['absent', 'present']" version:String
|
179
|
-
```
|
180
|
-
|
181
|
-
#### `--template-url`
|
182
|
-
|
183
|
-
Overrides the template to use when generating this class. If this is not
|
184
|
-
specified, the template used to generate the module will be used instead. If
|
185
|
-
that template is not available, the default template at
|
186
|
-
[puppetlabs/pdk-module-template](https://github.com/puppetlabs/pdk-module-template)
|
187
|
-
will be used.
|
188
|
-
|
189
|
-
#### `class_name`
|
190
|
-
|
191
|
-
The name of the class to generate. If the class name is not inside the module
|
192
|
-
namespace (e.g. module name is `apt` and the class name is `source`, then the
|
193
|
-
module name will automatically be prepended to the class name (e.g.
|
194
|
-
`apt::source`).
|
195
|
-
|
196
|
-
#### `parameter_name[:parameter_type]`
|
197
|
-
|
198
|
-
If the class should take parameters, they can be specified on the command line
|
199
|
-
to be added to the generated class. Optionally, the data type of the parameter
|
200
|
-
can be specified along with the parameter name, separated by a colon. Any
|
201
|
-
number of parameters can be provided on the command line.
|
202
|
-
|
203
|
-
### `pdk validate` command
|
204
|
-
|
205
|
-
Runs all static validations. Any errors are reported to the console in the format requested. The exit code is non-zero when errors occur.
|
206
|
-
|
207
|
-
Usage:
|
208
|
-
|
209
|
-
```
|
210
|
-
pdk validate --list
|
211
|
-
```
|
212
|
-
|
213
|
-
```
|
214
|
-
pdk validate [--format=format[:target]] [validations] [targets*]
|
215
|
-
```
|
216
|
-
|
217
|
-
#### `--list`
|
218
|
-
|
219
|
-
Displays a list of available validations and their descriptions. Using this option lists the tests without running them.
|
220
|
-
|
221
|
-
#### `--format=format[:target]`
|
222
|
-
|
223
|
-
Specifies the format of the output. Valid values: `junit`, `text`. Default: `text`.
|
224
|
-
|
225
|
-
Optionally, you can specify a target file for the given output format with the syntax: `--format=junit:report.xml`
|
226
|
-
|
227
|
-
Multiple `--format` options can be specified as long as they all have distinct output targets.
|
228
|
-
|
229
|
-
#### `validations`
|
230
|
-
|
231
|
-
Specifies a comma separated list of validations to run (or `all`). See the `--list` output for a list of available validations. Defaults to `all` if not supplied.
|
232
|
-
|
233
|
-
#### `targets`
|
234
|
-
|
235
|
-
Specifies a list of directories or individual files to validate. Validations which are not applicable to individual files will be skipped for those files. Defaults to validating everything.
|
236
|
-
|
237
|
-
#### Additional Examples
|
238
|
-
|
239
|
-
```
|
240
|
-
$ pdk validate metadata
|
241
|
-
Running 'metadata' validation on `new_module`: OK!
|
242
|
-
```
|
243
|
-
|
244
|
-
```
|
245
|
-
$ pdk validate all lib/
|
246
|
-
Running validations on `new_module/lib`:
|
247
|
-
* ruby syntax: OK!
|
248
|
-
* puppet syntax: (no puppet manifests found)
|
249
|
-
```
|
250
|
-
|
251
|
-
### `pdk test unit` command
|
252
|
-
|
253
|
-
Runs unit tests. Any errors are displayed to the console and reported in the report-file, if requested. The exitcode is non-zero when errors occur.
|
254
|
-
|
255
|
-
Usage:
|
256
|
-
|
257
|
-
```
|
258
|
-
pdk test unit [--list] [--tests=test_list] [--format=format[:target]] [runner_options]
|
259
|
-
```
|
260
|
-
|
261
|
-
#### `--list`
|
262
|
-
|
263
|
-
Displays a list of unit tests and their descriptions. Using this option lists the tests without running them.
|
264
|
-
|
265
|
-
#### `--tests=test_list`
|
266
|
-
|
267
|
-
A comma-separated list of tests to run. Use this during development to pinpoint a single failing test. See the `--list` output for allowed values.
|
268
|
-
|
269
|
-
#### `--format=format[:target]`
|
270
|
-
|
271
|
-
Specifies the format of the output. Valid values: `junit`, `text`. Default: `text`.
|
272
|
-
|
273
|
-
Optionally, you can specify a target file for the given output format with the syntax: `--format=junit:report.xml`
|
274
|
-
|
275
|
-
Multiple `--format` options can be specified as long as they all have distinct output targets.
|
276
|
-
|
277
|
-
#### `runner_options`
|
278
|
-
|
279
|
-
<!-- this is a cop-out; alternatives are surfacing the real runner to advanced users, or completely wrapping the runner's interface -->
|
280
|
-
|
281
|
-
Specifies options to pass through to the actual test-runner. In the default template (and most commonly across modules), this is [rspec](https://relishapp.com/rspec/rspec-core/docs/command-line).
|
82
|
+
## Experimental features
|
282
83
|
|
283
84
|
### `pdk bundle` command
|
284
85
|
|
285
|
-
This
|
86
|
+
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 the pdk itself.
|
286
87
|
|
287
|
-
Note that for most
|
88
|
+
Note that for most uses, you must use the `--` to separate bundler options from pdk options. Compare the following two commands:
|
288
89
|
|
289
90
|
```
|
290
91
|
$ pdk bundle exec rake -T
|
@@ -303,21 +104,20 @@ rake build # Build puppet module package
|
|
303
104
|
[...]
|
304
105
|
```
|
305
106
|
|
306
|
-
|
107
|
+
#### Known issues
|
108
|
+
|
109
|
+
* `pdk bundle` command on Windows doesn't allow usage suggested by pdk help [PDK-408](https://tickets.puppetlabs.com/browse/PDK-408)
|
307
110
|
|
308
|
-
|
111
|
+
On Windows, the `pdk bundle` command doesn't allow `--` as a separator between pdk option flags and bundler option flags as suggested by `pdk help bundle`.
|
309
112
|
|
310
|
-
|
311
|
-
* access to new PDK functionality might require an update of the module to the current Template version
|
312
|
-
* access to a new major PDK version might require an update of the module to the current Template version, after a one year deprecation cycle
|
313
|
-
* validation against new Puppet versions might require new PDK functionality, a new major PDK version, and changes to the module itself.
|
113
|
+
The issue is that PDK is consuming command line options meant for the subcommand. To work around this, run `pdk bundle exec` with a string specifying the command you want to run with its command line options.
|
314
114
|
|
315
|
-
|
316
|
-
* In the common case, Puppet and the PDK will be forward-compatible so that minor Puppet updates will not require a new version of the PDK.
|
317
|
-
* Some new Puppet versions will require changes to the PDK. In that case, upgrading the PDK for validation prior to roll-out of Puppet is strongly recommended.
|
115
|
+
For example: `pdk bundle exec "bundle install --binstubs"`
|
318
116
|
|
117
|
+
## Module Compatibility
|
319
118
|
|
119
|
+
**PDK Version Compatibility:** Modules created with PDK version 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)
|
320
120
|
|
321
121
|
## Contributing
|
322
122
|
|
323
|
-
See the [CONTRIBUTING.md](CONTRIBUTING.md) file for development notes.
|
123
|
+
PDK encourages community contributions. See the [CONTRIBUTING.md](CONTRIBUTING.md) file for development notes.
|
data/lib/pdk/cli.rb
CHANGED
@@ -4,6 +4,7 @@ require 'pdk/cli/errors'
|
|
4
4
|
require 'pdk/cli/util'
|
5
5
|
require 'pdk/cli/util/option_normalizer'
|
6
6
|
require 'pdk/cli/util/option_validator'
|
7
|
+
require 'pdk/cli/exec_group'
|
7
8
|
require 'pdk/generators/module'
|
8
9
|
require 'pdk/i18n'
|
9
10
|
require 'pdk/logger'
|
@@ -32,7 +33,7 @@ module PDK::CLI
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def self.template_url_option(dsl)
|
35
|
-
dsl.option nil, 'template-url', _('Specifies the URL to the template to use when creating new modules, and other parts.'), argument: :required, default: PDK::Generate::Module
|
36
|
+
dsl.option nil, 'template-url', _('Specifies the URL to the template to use when creating new modules, and other parts.'), argument: :required, default: PDK::Generate::Module.default_template_url
|
36
37
|
end
|
37
38
|
|
38
39
|
@base_cmd = Cri::Command.define do
|
data/lib/pdk/cli/exec.rb
CHANGED
@@ -73,6 +73,7 @@ module PDK
|
|
73
73
|
attr_reader :context
|
74
74
|
attr_accessor :timeout
|
75
75
|
attr_accessor :environment
|
76
|
+
attr_writer :exec_group
|
76
77
|
|
77
78
|
def initialize(*argv)
|
78
79
|
@argv = argv
|
@@ -91,21 +92,33 @@ module PDK
|
|
91
92
|
|
92
93
|
# Extra environment vars to add to base set.
|
93
94
|
@environment = {}
|
95
|
+
|
96
|
+
# Register the ExecGroup when running in parallel
|
97
|
+
@exec_group = nil
|
94
98
|
end
|
95
99
|
|
96
100
|
def context=(new_context)
|
97
101
|
unless [:system, :module].include?(new_context)
|
98
|
-
raise ArgumentError, _("Expected execution context to be :system or :module but got '%{context}'") % { context:
|
102
|
+
raise ArgumentError, _("Expected execution context to be :system or :module but got '%{context}'") % { context: new_context }
|
99
103
|
end
|
100
104
|
|
101
105
|
@context = new_context
|
102
106
|
end
|
103
107
|
|
108
|
+
def register_spinner(spinner, opts = {})
|
109
|
+
return if PDK.logger.debug?
|
110
|
+
@success_message = opts.delete(:success)
|
111
|
+
@failure_message = opts.delete(:failure)
|
112
|
+
|
113
|
+
@spinner = spinner
|
114
|
+
end
|
115
|
+
|
104
116
|
def add_spinner(message, opts = {})
|
117
|
+
return if PDK.logger.debug?
|
105
118
|
@success_message = opts.delete(:success)
|
106
119
|
@failure_message = opts.delete(:failure)
|
107
120
|
|
108
|
-
@spinner =
|
121
|
+
@spinner = TTY::Spinner.new("[:spinner] #{message}", opts.merge(PDK::CLI::Util.spinner_opts_for_platform))
|
109
122
|
end
|
110
123
|
|
111
124
|
def execute!
|
@@ -135,19 +148,26 @@ module PDK
|
|
135
148
|
end
|
136
149
|
|
137
150
|
# Make sure invocation of Ruby prefers our private installation.
|
138
|
-
@process.environment['PATH'] = [
|
151
|
+
@process.environment['PATH'] = [
|
152
|
+
RbConfig::CONFIG['bindir'],
|
153
|
+
File.join(@process.environment['GEM_HOME'], 'bin'),
|
154
|
+
File.join(@process.environment['GEM_PATH'], 'bin'),
|
155
|
+
ENV['PATH'],
|
156
|
+
].compact.join(File::PATH_SEPARATOR)
|
139
157
|
|
140
158
|
mod_root = PDK::Util.module_root
|
141
159
|
|
142
160
|
unless mod_root
|
143
|
-
@spinner.error
|
161
|
+
@spinner.error if @spinner
|
144
162
|
|
145
163
|
raise PDK::CLI::FatalError, _('Current working directory is not part of a module. (No metadata.json was found.)')
|
146
164
|
end
|
147
165
|
|
148
|
-
Dir.
|
149
|
-
|
150
|
-
|
166
|
+
if Dir.pwd == mod_root
|
167
|
+
run_process_in_clean_env!
|
168
|
+
else
|
169
|
+
Dir.chdir(mod_root) do
|
170
|
+
run_process_in_clean_env!
|
151
171
|
end
|
152
172
|
end
|
153
173
|
else
|
@@ -155,13 +175,7 @@ module PDK
|
|
155
175
|
end
|
156
176
|
|
157
177
|
# Stop spinning when done (if configured).
|
158
|
-
|
159
|
-
if @process.exit_code.zero?
|
160
|
-
@spinner.success(@success_message || '')
|
161
|
-
else
|
162
|
-
@spinner.error(@failure_message || '')
|
163
|
-
end
|
164
|
-
end
|
178
|
+
stop_spinner
|
165
179
|
|
166
180
|
@stdout.rewind
|
167
181
|
@stderr.rewind
|
@@ -181,6 +195,23 @@ module PDK
|
|
181
195
|
|
182
196
|
protected
|
183
197
|
|
198
|
+
def stop_spinner
|
199
|
+
return unless @spinner
|
200
|
+
|
201
|
+
# If it is a single spinner, we need to send it a success/error message
|
202
|
+
if @process.exit_code.zero?
|
203
|
+
@spinner.success(@success_message || '')
|
204
|
+
else
|
205
|
+
@spinner.error(@failure_message || '')
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def run_process_in_clean_env!
|
210
|
+
::Bundler.with_clean_env do
|
211
|
+
run_process!
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
184
215
|
def run_process!
|
185
216
|
command_string = argv.join(' ')
|
186
217
|
PDK.logger.debug(_("Executing '%{command}'") % { command: command_string })
|
@@ -202,30 +233,8 @@ module PDK
|
|
202
233
|
@process.wait
|
203
234
|
end
|
204
235
|
@duration = Time.now - start_time
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
# This is a placeholder until we integrate ansicon into Windows packaging
|
209
|
-
# or come up with some other progress indicator for Windows.
|
210
|
-
class WindowsSpinner
|
211
|
-
def initialize(message, _opts = {})
|
212
|
-
@message = message
|
213
|
-
end
|
214
|
-
|
215
|
-
def auto_spin
|
216
|
-
$stderr.print @message << '...'
|
217
|
-
end
|
218
|
-
|
219
|
-
def success(message = '')
|
220
|
-
message = 'done.' if message.nil? || message.empty?
|
221
|
-
|
222
|
-
$stderr.print message << "\n"
|
223
|
-
end
|
224
|
-
|
225
|
-
def error(message = '')
|
226
|
-
message = 'FAILED' if message.nil? || message.empty?
|
227
|
-
|
228
|
-
$stderr.print message << "\n"
|
236
|
+
PDK.logger.debug(_("Execution of '%{command}' complete (duration: %{duration_in_seconds}s; exit code: %{exit_code})") %
|
237
|
+
{ command: command_string, duration_in_seconds: @duration, exit_code: @process.exit_code })
|
229
238
|
end
|
230
239
|
end
|
231
240
|
end
|