pdk 2.1.0 → 2.4.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 +1329 -1292
- data/LICENSE +201 -201
- data/README.md +163 -163
- data/exe/pdk +10 -10
- data/lib/pdk/analytics/client/google_analytics.rb +143 -143
- data/lib/pdk/analytics/client/noop.rb +25 -25
- data/lib/pdk/analytics/util.rb +19 -19
- data/lib/pdk/analytics.rb +30 -30
- data/lib/pdk/answer_file.rb +12 -12
- data/lib/pdk/bolt.rb +19 -19
- data/lib/pdk/cli/build.rb +82 -82
- data/lib/pdk/cli/bundle.rb +48 -48
- data/lib/pdk/cli/config/get.rb +26 -26
- data/lib/pdk/cli/config.rb +22 -22
- data/lib/pdk/cli/console.rb +148 -148
- data/lib/pdk/cli/convert.rb +52 -52
- data/lib/pdk/cli/env.rb +52 -52
- data/lib/pdk/cli/errors.rb +25 -25
- data/lib/pdk/cli/exec/command.rb +293 -283
- data/lib/pdk/cli/exec/interactive_command.rb +114 -114
- data/lib/pdk/cli/exec.rb +84 -84
- data/lib/pdk/cli/exec_group.rb +104 -104
- data/lib/pdk/cli/get/config.rb +24 -24
- data/lib/pdk/cli/get.rb +20 -20
- data/lib/pdk/cli/module/build.rb +12 -12
- data/lib/pdk/cli/module/generate.rb +47 -47
- data/lib/pdk/cli/module.rb +14 -14
- data/lib/pdk/cli/new/class.rb +32 -32
- data/lib/pdk/cli/new/defined_type.rb +32 -32
- data/lib/pdk/cli/new/fact.rb +29 -29
- data/lib/pdk/cli/new/function.rb +29 -29
- data/lib/pdk/cli/new/module.rb +53 -53
- data/lib/pdk/cli/new/provider.rb +29 -29
- data/lib/pdk/cli/new/task.rb +34 -34
- data/lib/pdk/cli/new/test.rb +52 -52
- data/lib/pdk/cli/new/transport.rb +27 -27
- data/lib/pdk/cli/new.rb +21 -21
- data/lib/pdk/cli/release/prep.rb +39 -39
- data/lib/pdk/cli/release/publish.rb +50 -50
- data/lib/pdk/cli/release.rb +194 -192
- data/lib/pdk/cli/remove/config.rb +80 -80
- data/lib/pdk/cli/remove.rb +20 -20
- data/lib/pdk/cli/set/config.rb +119 -119
- data/lib/pdk/cli/set.rb +20 -20
- data/lib/pdk/cli/test/unit.rb +90 -90
- data/lib/pdk/cli/test.rb +11 -11
- data/lib/pdk/cli/update.rb +64 -64
- data/lib/pdk/cli/util/command_redirector.rb +27 -27
- data/lib/pdk/cli/util/interview.rb +72 -72
- data/lib/pdk/cli/util/option_normalizer.rb +55 -55
- data/lib/pdk/cli/util/option_validator.rb +68 -68
- data/lib/pdk/cli/util/spinner.rb +13 -13
- data/lib/pdk/cli/util/update_manager_printer.rb +82 -82
- data/lib/pdk/cli/util.rb +305 -305
- data/lib/pdk/cli/validate.rb +116 -116
- data/lib/pdk/cli.rb +175 -175
- data/lib/pdk/config/analytics_schema.json +26 -26
- data/lib/pdk/config/errors.rb +5 -5
- data/lib/pdk/config/ini_file.rb +183 -183
- data/lib/pdk/config/ini_file_setting.rb +39 -39
- data/lib/pdk/config/json.rb +34 -34
- data/lib/pdk/config/json_schema_namespace.rb +142 -142
- data/lib/pdk/config/json_schema_setting.rb +53 -53
- data/lib/pdk/config/json_with_schema.rb +49 -49
- data/lib/pdk/config/namespace.rb +354 -354
- data/lib/pdk/config/setting.rb +135 -135
- data/lib/pdk/config/validator.rb +31 -31
- data/lib/pdk/config/yaml.rb +46 -42
- data/lib/pdk/config/yaml_with_schema.rb +59 -59
- data/lib/pdk/config.rb +390 -384
- data/lib/pdk/context/control_repo.rb +60 -60
- data/lib/pdk/context/module.rb +28 -28
- data/lib/pdk/context/none.rb +22 -22
- data/lib/pdk/context.rb +99 -99
- data/lib/pdk/control_repo.rb +90 -90
- data/lib/pdk/generate/defined_type.rb +43 -43
- data/lib/pdk/generate/fact.rb +25 -25
- data/lib/pdk/generate/function.rb +48 -48
- data/lib/pdk/generate/module.rb +352 -352
- data/lib/pdk/generate/provider.rb +28 -28
- data/lib/pdk/generate/puppet_class.rb +43 -43
- data/lib/pdk/generate/puppet_object.rb +232 -232
- data/lib/pdk/generate/task.rb +68 -68
- data/lib/pdk/generate/transport.rb +33 -33
- data/lib/pdk/generate.rb +24 -24
- data/lib/pdk/i18n.rb +4 -4
- data/lib/pdk/logger.rb +45 -45
- data/lib/pdk/module/build.rb +322 -322
- data/lib/pdk/module/convert.rb +296 -296
- data/lib/pdk/module/metadata.rb +202 -202
- data/lib/pdk/module/release.rb +260 -254
- data/lib/pdk/module/update.rb +131 -131
- data/lib/pdk/module/update_manager.rb +227 -227
- data/lib/pdk/module.rb +30 -30
- data/lib/pdk/report/event.rb +370 -370
- data/lib/pdk/report.rb +121 -121
- data/lib/pdk/template/fetcher/git.rb +85 -85
- data/lib/pdk/template/fetcher/local.rb +28 -28
- data/lib/pdk/template/fetcher.rb +98 -98
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -116
- data/lib/pdk/template/renderer/v1/renderer.rb +132 -132
- data/lib/pdk/template/renderer/v1/template_file.rb +102 -102
- data/lib/pdk/template/renderer/v1.rb +25 -25
- data/lib/pdk/template/renderer.rb +96 -96
- data/lib/pdk/template/template_dir.rb +67 -67
- data/lib/pdk/template.rb +59 -59
- data/lib/pdk/tests/unit.rb +252 -252
- data/lib/pdk/util/bundler.rb +259 -259
- data/lib/pdk/util/changelog_generator.rb +137 -124
- data/lib/pdk/util/env.rb +47 -47
- data/lib/pdk/util/filesystem.rb +138 -138
- data/lib/pdk/util/git.rb +179 -179
- data/lib/pdk/util/json_finder.rb +85 -84
- data/lib/pdk/util/puppet_strings.rb +125 -125
- data/lib/pdk/util/puppet_version.rb +266 -266
- data/lib/pdk/util/ruby_version.rb +179 -179
- data/lib/pdk/util/template_uri.rb +295 -295
- data/lib/pdk/util/vendored_file.rb +93 -93
- data/lib/pdk/util/version.rb +43 -43
- data/lib/pdk/util/windows/api_types.rb +82 -82
- data/lib/pdk/util/windows/file.rb +36 -36
- data/lib/pdk/util/windows/process.rb +79 -79
- data/lib/pdk/util/windows/string.rb +16 -16
- data/lib/pdk/util/windows.rb +15 -15
- data/lib/pdk/util.rb +278 -277
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -23
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -98
- data/lib/pdk/validate/external_command_validator.rb +208 -208
- data/lib/pdk/validate/internal_ruby_validator.rb +100 -100
- data/lib/pdk/validate/invokable_validator.rb +228 -220
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -86
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -78
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -20
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -133
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -66
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -137
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -21
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -80
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -19
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -88
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -50
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -20
- data/lib/pdk/validate/validator.rb +118 -118
- data/lib/pdk/validate/validator_group.rb +104 -104
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -95
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -19
- data/lib/pdk/validate.rb +94 -94
- data/lib/pdk/version.rb +4 -4
- data/lib/pdk.rb +76 -76
- data/locales/config.yaml +21 -21
- data/locales/pdk.pot +2094 -2094
- metadata +19 -13
data/README.md
CHANGED
@@ -1,163 +1,163 @@
|
|
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
|
-
|
3
|
-
* [Installation](#installation)
|
4
|
-
* [Basic usage](#basic-usage)
|
5
|
-
* [Experimental features](#experimental-features)
|
6
|
-
* [Module compatibility](#module-compatibility)
|
7
|
-
* [Contributing](#contributing)
|
8
|
-
* [Contact Information](#contact-information)
|
9
|
-
|
10
|
-
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.
|
11
|
-
|
12
|
-
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
|
-
|
14
|
-
PDK includes the following tools:
|
15
|
-
|
16
|
-
Tool | Description
|
17
|
-
----------------|-------------------------
|
18
|
-
metadata-json-lint | Validates and lints `metadata.json` files in modules against Puppet's module metadatastyle guidelines.
|
19
|
-
pdk | Command line tool for generating and testing modules
|
20
|
-
puppet-lint | Checks your Puppet code against the recommendations in the Puppet Language style guide.
|
21
|
-
puppet-syntax | Checks for correct syntax in Puppet manifests, templates, and Hiera YAML.
|
22
|
-
puppetlabs_spec_helper | Provides classes, methods, and Rake tasks to help with spec testing Puppet code.
|
23
|
-
rspec-puppet | Tests the behavior of Puppet when it compiles your manifests into a catalog of Puppet resources.
|
24
|
-
rspec-puppet-facts | Adds support for running rspec-puppet tests against the facts for your supported operating systems.
|
25
|
-
puppet-debugger | Provides a REPL based debugger console.
|
26
|
-
|
27
|
-
|
28
|
-
## Installation
|
29
|
-
|
30
|
-
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.
|
31
|
-
|
32
|
-
For complete installation information, see the [PDK documentation](https://puppet.com/docs/pdk/latest/pdk_install.html).
|
33
|
-
|
34
|
-
## Basic usage
|
35
|
-
|
36
|
-
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://puppet.com/docs/pdk/latest/pdk_install.html).
|
37
|
-
|
38
|
-
### Generate a module
|
39
|
-
|
40
|
-
Generates the basic components of a module and set up an infrastructure for testing it with PDK.
|
41
|
-
|
42
|
-
1. Run the `pdk new module` command, specifying the name of the new module:
|
43
|
-
|
44
|
-
```
|
45
|
-
pdk new module my_module
|
46
|
-
```
|
47
|
-
|
48
|
-
This command asks a series of metadata questions and then generates the basic components of a new module.
|
49
|
-
|
50
|
-
### Generate a class
|
51
|
-
|
52
|
-
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.
|
53
|
-
|
54
|
-
1. From the command line, in your module's directory, run:
|
55
|
-
```
|
56
|
-
pdk new class class_name
|
57
|
-
```
|
58
|
-
|
59
|
-
PDK creates the new class manifest and a test file (as `class_name_spec.rb`) in your module's `/spec/classes` directory.
|
60
|
-
|
61
|
-
### Generate a defined type
|
62
|
-
|
63
|
-
To generate a defined type in your module, use the `pdk new defined_type` command, specifying the name of your new defined type.
|
64
|
-
|
65
|
-
1. From the command line, in your module's directory, run:
|
66
|
-
```
|
67
|
-
pdk new defined_type defined_type_name
|
68
|
-
```
|
69
|
-
|
70
|
-
PDK creates the new defined\_type manifest and a test file (as `defined_type_name_spec.rb`) in your module's `/spec/defines` directory.
|
71
|
-
|
72
|
-
### Generate a task
|
73
|
-
|
74
|
-
To generate a task in your module, use the `pdk new task` command, specifying the name of your new task.
|
75
|
-
|
76
|
-
1. From the command line, in your module's directory, run:
|
77
|
-
```
|
78
|
-
pdk new task task_name
|
79
|
-
```
|
80
|
-
|
81
|
-
PDK creates the new task file and metadata.
|
82
|
-
|
83
|
-
### Validating a module
|
84
|
-
|
85
|
-
PDK can validate the well-formedness of the module and style and syntax of its files.
|
86
|
-
|
87
|
-
1. In the module's directory, run:
|
88
|
-
|
89
|
-
```
|
90
|
-
pdk validate
|
91
|
-
```
|
92
|
-
|
93
|
-
This command validates the metadata, Puppet code syntax and style, and Ruby syntax and style for the entire module.
|
94
|
-
|
95
|
-
### Run unit tests
|
96
|
-
|
97
|
-
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/rodjek/rspec-puppet/) for catalog-level unit testing.
|
98
|
-
|
99
|
-
In the module's directory, run unit tests with:
|
100
|
-
|
101
|
-
```
|
102
|
-
pdk test unit
|
103
|
-
```
|
104
|
-
|
105
|
-
This command runs all available unit tests.
|
106
|
-
|
107
|
-
## Experimental features
|
108
|
-
|
109
|
-
### `pdk console` command
|
110
|
-
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)
|
111
|
-
|
112
|
-
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.
|
113
|
-
|
114
|
-
Example (from within a module):
|
115
|
-
|
116
|
-
* `pdk console --puppet-version=5`
|
117
|
-
* `pdk console --pe-version=2018.1`
|
118
|
-
|
119
|
-
The `pdk console` command will also pass through any puppet debugger arguments you wish to use.
|
120
|
-
|
121
|
-
Example:
|
122
|
-
|
123
|
-
* `pdk console --no-facterdb`
|
124
|
-
* `pdk console --play https://gist.github.com/logicminds/4f6bcfd723c92aad1f01f6a800319fa4`
|
125
|
-
* `pdk console -e "md5('sdfasdfasdf')" --run-once --quiet`
|
126
|
-
|
127
|
-
Use `pdk console -h` for a further explanation of pass through arguments.
|
128
|
-
|
129
|
-
If you receive the following error you do not have the puppet-debugger gem installed.
|
130
|
-
|
131
|
-
```
|
132
|
-
pdk console -h
|
133
|
-
Error: Unknown Puppet subcommand 'debugger'
|
134
|
-
See 'puppet help' for help on available puppet subcommands
|
135
|
-
```
|
136
|
-
|
137
|
-
To fix this you will need to add the following entry to your .sync.yml file and run pdk update:
|
138
|
-
|
139
|
-
```
|
140
|
-
Gemfile:
|
141
|
-
required:
|
142
|
-
":development":
|
143
|
-
- gem: puppet-debugger
|
144
|
-
version: "~> 0.14"
|
145
|
-
```
|
146
|
-
|
147
|
-
**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.
|
148
|
-
|
149
|
-
### `pdk bundle` command
|
150
|
-
|
151
|
-
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.
|
152
|
-
|
153
|
-
## Module Compatibility
|
154
|
-
|
155
|
-
**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)
|
156
|
-
|
157
|
-
## Contributing
|
158
|
-
|
159
|
-
PDK encourages community contributions. See the [CONTRIBUTING.md](CONTRIBUTING.md) file for development notes.
|
160
|
-
|
161
|
-
## Contact Information
|
162
|
-
|
163
|
-
To contact us with questions: [pdk-maintainers@puppet.com](mailto:pdk-maintainers@puppet.com)
|
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
|
+
|
3
|
+
* [Installation](#installation)
|
4
|
+
* [Basic usage](#basic-usage)
|
5
|
+
* [Experimental features](#experimental-features)
|
6
|
+
* [Module compatibility](#module-compatibility)
|
7
|
+
* [Contributing](#contributing)
|
8
|
+
* [Contact Information](#contact-information)
|
9
|
+
|
10
|
+
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.
|
11
|
+
|
12
|
+
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
|
+
|
14
|
+
PDK includes the following tools:
|
15
|
+
|
16
|
+
Tool | Description
|
17
|
+
----------------|-------------------------
|
18
|
+
metadata-json-lint | Validates and lints `metadata.json` files in modules against Puppet's module metadatastyle guidelines.
|
19
|
+
pdk | Command line tool for generating and testing modules
|
20
|
+
puppet-lint | Checks your Puppet code against the recommendations in the Puppet Language style guide.
|
21
|
+
puppet-syntax | Checks for correct syntax in Puppet manifests, templates, and Hiera YAML.
|
22
|
+
puppetlabs_spec_helper | Provides classes, methods, and Rake tasks to help with spec testing Puppet code.
|
23
|
+
rspec-puppet | Tests the behavior of Puppet when it compiles your manifests into a catalog of Puppet resources.
|
24
|
+
rspec-puppet-facts | Adds support for running rspec-puppet tests against the facts for your supported operating systems.
|
25
|
+
puppet-debugger | Provides a REPL based debugger console.
|
26
|
+
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
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.
|
31
|
+
|
32
|
+
For complete installation information, see the [PDK documentation](https://puppet.com/docs/pdk/latest/pdk_install.html).
|
33
|
+
|
34
|
+
## Basic usage
|
35
|
+
|
36
|
+
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://puppet.com/docs/pdk/latest/pdk_install.html).
|
37
|
+
|
38
|
+
### Generate a module
|
39
|
+
|
40
|
+
Generates the basic components of a module and set up an infrastructure for testing it with PDK.
|
41
|
+
|
42
|
+
1. Run the `pdk new module` command, specifying the name of the new module:
|
43
|
+
|
44
|
+
```
|
45
|
+
pdk new module my_module
|
46
|
+
```
|
47
|
+
|
48
|
+
This command asks a series of metadata questions and then generates the basic components of a new module.
|
49
|
+
|
50
|
+
### Generate a class
|
51
|
+
|
52
|
+
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.
|
53
|
+
|
54
|
+
1. From the command line, in your module's directory, run:
|
55
|
+
```
|
56
|
+
pdk new class class_name
|
57
|
+
```
|
58
|
+
|
59
|
+
PDK creates the new class manifest and a test file (as `class_name_spec.rb`) in your module's `/spec/classes` directory.
|
60
|
+
|
61
|
+
### Generate a defined type
|
62
|
+
|
63
|
+
To generate a defined type in your module, use the `pdk new defined_type` command, specifying the name of your new defined type.
|
64
|
+
|
65
|
+
1. From the command line, in your module's directory, run:
|
66
|
+
```
|
67
|
+
pdk new defined_type defined_type_name
|
68
|
+
```
|
69
|
+
|
70
|
+
PDK creates the new defined\_type manifest and a test file (as `defined_type_name_spec.rb`) in your module's `/spec/defines` directory.
|
71
|
+
|
72
|
+
### Generate a task
|
73
|
+
|
74
|
+
To generate a task in your module, use the `pdk new task` command, specifying the name of your new task.
|
75
|
+
|
76
|
+
1. From the command line, in your module's directory, run:
|
77
|
+
```
|
78
|
+
pdk new task task_name
|
79
|
+
```
|
80
|
+
|
81
|
+
PDK creates the new task file and metadata.
|
82
|
+
|
83
|
+
### Validating a module
|
84
|
+
|
85
|
+
PDK can validate the well-formedness of the module and style and syntax of its files.
|
86
|
+
|
87
|
+
1. In the module's directory, run:
|
88
|
+
|
89
|
+
```
|
90
|
+
pdk validate
|
91
|
+
```
|
92
|
+
|
93
|
+
This command validates the metadata, Puppet code syntax and style, and Ruby syntax and style for the entire module.
|
94
|
+
|
95
|
+
### Run unit tests
|
96
|
+
|
97
|
+
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/rodjek/rspec-puppet/) for catalog-level unit testing.
|
98
|
+
|
99
|
+
In the module's directory, run unit tests with:
|
100
|
+
|
101
|
+
```
|
102
|
+
pdk test unit
|
103
|
+
```
|
104
|
+
|
105
|
+
This command runs all available unit tests.
|
106
|
+
|
107
|
+
## Experimental features
|
108
|
+
|
109
|
+
### `pdk console` command
|
110
|
+
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)
|
111
|
+
|
112
|
+
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.
|
113
|
+
|
114
|
+
Example (from within a module):
|
115
|
+
|
116
|
+
* `pdk console --puppet-version=5`
|
117
|
+
* `pdk console --pe-version=2018.1`
|
118
|
+
|
119
|
+
The `pdk console` command will also pass through any puppet debugger arguments you wish to use.
|
120
|
+
|
121
|
+
Example:
|
122
|
+
|
123
|
+
* `pdk console --no-facterdb`
|
124
|
+
* `pdk console --play https://gist.github.com/logicminds/4f6bcfd723c92aad1f01f6a800319fa4`
|
125
|
+
* `pdk console -e "md5('sdfasdfasdf')" --run-once --quiet`
|
126
|
+
|
127
|
+
Use `pdk console -h` for a further explanation of pass through arguments.
|
128
|
+
|
129
|
+
If you receive the following error you do not have the puppet-debugger gem installed.
|
130
|
+
|
131
|
+
```
|
132
|
+
pdk console -h
|
133
|
+
Error: Unknown Puppet subcommand 'debugger'
|
134
|
+
See 'puppet help' for help on available puppet subcommands
|
135
|
+
```
|
136
|
+
|
137
|
+
To fix this you will need to add the following entry to your .sync.yml file and run pdk update:
|
138
|
+
|
139
|
+
```
|
140
|
+
Gemfile:
|
141
|
+
required:
|
142
|
+
":development":
|
143
|
+
- gem: puppet-debugger
|
144
|
+
version: "~> 0.14"
|
145
|
+
```
|
146
|
+
|
147
|
+
**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.
|
148
|
+
|
149
|
+
### `pdk bundle` command
|
150
|
+
|
151
|
+
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.
|
152
|
+
|
153
|
+
## Module Compatibility
|
154
|
+
|
155
|
+
**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)
|
156
|
+
|
157
|
+
## Contributing
|
158
|
+
|
159
|
+
PDK encourages community contributions. See the [CONTRIBUTING.md](CONTRIBUTING.md) file for development notes.
|
160
|
+
|
161
|
+
## Contact Information
|
162
|
+
|
163
|
+
To contact us with questions: [pdk-maintainers@puppet.com](mailto:pdk-maintainers@puppet.com)
|
data/exe/pdk
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pdk/cli'
|
4
|
-
|
5
|
-
begin
|
6
|
-
PDK::CLI.run(ARGV)
|
7
|
-
rescue Interrupt
|
8
|
-
warn "\nAborted!"
|
9
|
-
exit 1
|
10
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pdk/cli'
|
4
|
+
|
5
|
+
begin
|
6
|
+
PDK::CLI.run(ARGV)
|
7
|
+
rescue Interrupt
|
8
|
+
warn "\nAborted!"
|
9
|
+
exit 1
|
10
|
+
end
|
@@ -1,143 +1,143 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Analytics
|
5
|
-
module Client
|
6
|
-
class GoogleAnalytics
|
7
|
-
PROTOCOL_VERSION = 1
|
8
|
-
TRACKING_URL = 'https://google-analytics.com/collect'.freeze
|
9
|
-
CUSTOM_DIMENSIONS = {
|
10
|
-
operating_system: :cd1,
|
11
|
-
output_format: :cd2,
|
12
|
-
ruby_version: :cd3,
|
13
|
-
cli_options: :cd4,
|
14
|
-
env_vars: :cd5,
|
15
|
-
}.freeze
|
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
|
23
|
-
|
24
|
-
def initialize(opts)
|
25
|
-
# lazy-load expensive gem code
|
26
|
-
require 'concurrent/configuration'
|
27
|
-
require 'concurrent/future'
|
28
|
-
require 'httpclient'
|
29
|
-
require 'locale'
|
30
|
-
require 'pdk/analytics/util'
|
31
|
-
|
32
|
-
@http = HTTPClient.new
|
33
|
-
@user_id = opts[:user_id]
|
34
|
-
@executor = Concurrent.global_io_executor
|
35
|
-
@os = PDK::Analytics::Util.fetch_os_async
|
36
|
-
@logger = opts[:logger]
|
37
|
-
@app_name = opts[:app_name]
|
38
|
-
@app_id = opts[:app_id]
|
39
|
-
@app_version = opts[:app_version]
|
40
|
-
@app_installer = opts[:app_installer]
|
41
|
-
end
|
42
|
-
|
43
|
-
def screen_view(screen, **kwargs)
|
44
|
-
custom_dimensions = walk_keys(kwargs) do |k|
|
45
|
-
CUSTOM_DIMENSIONS[k] || raise(_("Unknown analytics key '%{key}'") % { key: k })
|
46
|
-
end
|
47
|
-
|
48
|
-
screen_view_params = {
|
49
|
-
# Type
|
50
|
-
t: 'screenview',
|
51
|
-
# Screen Name
|
52
|
-
cd: screen,
|
53
|
-
}.merge(custom_dimensions)
|
54
|
-
|
55
|
-
submit(base_params.merge(screen_view_params))
|
56
|
-
end
|
57
|
-
|
58
|
-
def event(category, action, label: nil, value: nil, **kwargs)
|
59
|
-
custom_dimensions = walk_keys(kwargs) do |k|
|
60
|
-
CUSTOM_DIMENSIONS[k] || raise(_("Unknown analytics key '%{key}'") % { key: k })
|
61
|
-
end
|
62
|
-
|
63
|
-
event_params = {
|
64
|
-
# Type
|
65
|
-
t: 'event',
|
66
|
-
# Event Category
|
67
|
-
ec: category,
|
68
|
-
# Event Action
|
69
|
-
ea: action,
|
70
|
-
}.merge(custom_dimensions)
|
71
|
-
|
72
|
-
# Event Label
|
73
|
-
event_params[:el] = label if label
|
74
|
-
# Event Value
|
75
|
-
event_params[:ev] = value if value
|
76
|
-
|
77
|
-
submit(base_params.merge(event_params))
|
78
|
-
end
|
79
|
-
|
80
|
-
def submit(params)
|
81
|
-
# Handle analytics submission in the background to avoid blocking the
|
82
|
-
# app or polluting the log with errors
|
83
|
-
Concurrent::Future.execute(executor: @executor) do
|
84
|
-
require 'json'
|
85
|
-
|
86
|
-
logger.debug "Submitting analytics: #{JSON.pretty_generate(params)}"
|
87
|
-
@http.post(TRACKING_URL, params)
|
88
|
-
logger.debug 'Completed analytics submission'
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# These parameters have terrible names. See this page for complete documentation:
|
93
|
-
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
|
94
|
-
def base_params
|
95
|
-
{
|
96
|
-
v: PROTOCOL_VERSION,
|
97
|
-
# Client ID
|
98
|
-
cid: user_id,
|
99
|
-
# Tracking ID
|
100
|
-
tid: app_id,
|
101
|
-
# Application Name
|
102
|
-
an: app_name,
|
103
|
-
# Application Version
|
104
|
-
av: app_version,
|
105
|
-
# Application Installer ID
|
106
|
-
aiid: app_installer,
|
107
|
-
# Anonymize IPs
|
108
|
-
aip: true,
|
109
|
-
# User locale
|
110
|
-
ul: Locale.current.to_rfc,
|
111
|
-
# Custom Dimension 1 (Operating System)
|
112
|
-
cd1: @os.value,
|
113
|
-
}
|
114
|
-
end
|
115
|
-
|
116
|
-
# If the user is running a very fast command, there may not be time for
|
117
|
-
# analytics submission to complete before the command is finished. In
|
118
|
-
# that case, we give a little buffer for any stragglers to finish up.
|
119
|
-
# 250ms strikes a balance between accomodating slower networks while not
|
120
|
-
# introducing a noticeable "hang".
|
121
|
-
def finish
|
122
|
-
@executor.shutdown
|
123
|
-
@executor.wait_for_termination(0.25)
|
124
|
-
end
|
125
|
-
|
126
|
-
private
|
127
|
-
|
128
|
-
def walk_keys(data, &block)
|
129
|
-
if data.is_a?(Hash)
|
130
|
-
data.each_with_object({}) do |(k, v), acc|
|
131
|
-
v = walk_keys(v, &block)
|
132
|
-
acc[yield(k)] = v
|
133
|
-
end
|
134
|
-
elsif data.is_a?(Array)
|
135
|
-
data.map { |v| walk_keys(v, &block) }
|
136
|
-
else
|
137
|
-
data
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Analytics
|
5
|
+
module Client
|
6
|
+
class GoogleAnalytics
|
7
|
+
PROTOCOL_VERSION = 1
|
8
|
+
TRACKING_URL = 'https://google-analytics.com/collect'.freeze
|
9
|
+
CUSTOM_DIMENSIONS = {
|
10
|
+
operating_system: :cd1,
|
11
|
+
output_format: :cd2,
|
12
|
+
ruby_version: :cd3,
|
13
|
+
cli_options: :cd4,
|
14
|
+
env_vars: :cd5,
|
15
|
+
}.freeze
|
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
|
23
|
+
|
24
|
+
def initialize(opts)
|
25
|
+
# lazy-load expensive gem code
|
26
|
+
require 'concurrent/configuration'
|
27
|
+
require 'concurrent/future'
|
28
|
+
require 'httpclient'
|
29
|
+
require 'locale'
|
30
|
+
require 'pdk/analytics/util'
|
31
|
+
|
32
|
+
@http = HTTPClient.new
|
33
|
+
@user_id = opts[:user_id]
|
34
|
+
@executor = Concurrent.global_io_executor
|
35
|
+
@os = PDK::Analytics::Util.fetch_os_async
|
36
|
+
@logger = opts[:logger]
|
37
|
+
@app_name = opts[:app_name]
|
38
|
+
@app_id = opts[:app_id]
|
39
|
+
@app_version = opts[:app_version]
|
40
|
+
@app_installer = opts[:app_installer]
|
41
|
+
end
|
42
|
+
|
43
|
+
def screen_view(screen, **kwargs)
|
44
|
+
custom_dimensions = walk_keys(kwargs) do |k|
|
45
|
+
CUSTOM_DIMENSIONS[k] || raise(_("Unknown analytics key '%{key}'") % { key: k })
|
46
|
+
end
|
47
|
+
|
48
|
+
screen_view_params = {
|
49
|
+
# Type
|
50
|
+
t: 'screenview',
|
51
|
+
# Screen Name
|
52
|
+
cd: screen,
|
53
|
+
}.merge(custom_dimensions)
|
54
|
+
|
55
|
+
submit(base_params.merge(screen_view_params))
|
56
|
+
end
|
57
|
+
|
58
|
+
def event(category, action, label: nil, value: nil, **kwargs)
|
59
|
+
custom_dimensions = walk_keys(kwargs) do |k|
|
60
|
+
CUSTOM_DIMENSIONS[k] || raise(_("Unknown analytics key '%{key}'") % { key: k })
|
61
|
+
end
|
62
|
+
|
63
|
+
event_params = {
|
64
|
+
# Type
|
65
|
+
t: 'event',
|
66
|
+
# Event Category
|
67
|
+
ec: category,
|
68
|
+
# Event Action
|
69
|
+
ea: action,
|
70
|
+
}.merge(custom_dimensions)
|
71
|
+
|
72
|
+
# Event Label
|
73
|
+
event_params[:el] = label if label
|
74
|
+
# Event Value
|
75
|
+
event_params[:ev] = value if value
|
76
|
+
|
77
|
+
submit(base_params.merge(event_params))
|
78
|
+
end
|
79
|
+
|
80
|
+
def submit(params)
|
81
|
+
# Handle analytics submission in the background to avoid blocking the
|
82
|
+
# app or polluting the log with errors
|
83
|
+
Concurrent::Future.execute(executor: @executor) do
|
84
|
+
require 'json'
|
85
|
+
|
86
|
+
logger.debug "Submitting analytics: #{JSON.pretty_generate(params)}"
|
87
|
+
@http.post(TRACKING_URL, params)
|
88
|
+
logger.debug 'Completed analytics submission'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# These parameters have terrible names. See this page for complete documentation:
|
93
|
+
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
|
94
|
+
def base_params
|
95
|
+
{
|
96
|
+
v: PROTOCOL_VERSION,
|
97
|
+
# Client ID
|
98
|
+
cid: user_id,
|
99
|
+
# Tracking ID
|
100
|
+
tid: app_id,
|
101
|
+
# Application Name
|
102
|
+
an: app_name,
|
103
|
+
# Application Version
|
104
|
+
av: app_version,
|
105
|
+
# Application Installer ID
|
106
|
+
aiid: app_installer,
|
107
|
+
# Anonymize IPs
|
108
|
+
aip: true,
|
109
|
+
# User locale
|
110
|
+
ul: Locale.current.to_rfc,
|
111
|
+
# Custom Dimension 1 (Operating System)
|
112
|
+
cd1: @os.value,
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
# If the user is running a very fast command, there may not be time for
|
117
|
+
# analytics submission to complete before the command is finished. In
|
118
|
+
# that case, we give a little buffer for any stragglers to finish up.
|
119
|
+
# 250ms strikes a balance between accomodating slower networks while not
|
120
|
+
# introducing a noticeable "hang".
|
121
|
+
def finish
|
122
|
+
@executor.shutdown
|
123
|
+
@executor.wait_for_termination(0.25)
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def walk_keys(data, &block)
|
129
|
+
if data.is_a?(Hash)
|
130
|
+
data.each_with_object({}) do |(k, v), acc|
|
131
|
+
v = walk_keys(v, &block)
|
132
|
+
acc[yield(k)] = v
|
133
|
+
end
|
134
|
+
elsif data.is_a?(Array)
|
135
|
+
data.map { |v| walk_keys(v, &block) }
|
136
|
+
else
|
137
|
+
data
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|