pdk 2.6.1 → 2.7.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 +23 -1
- data/lib/pdk/analytics/client/google_analytics.rb +4 -2
- data/lib/pdk/cli/build.rb +17 -21
- data/lib/pdk/cli/bundle.rb +4 -5
- data/lib/pdk/cli/config/get.rb +6 -6
- data/lib/pdk/cli/config.rb +3 -3
- data/lib/pdk/cli/console.rb +7 -7
- data/lib/pdk/cli/convert.rb +11 -11
- data/lib/pdk/cli/env.rb +3 -4
- data/lib/pdk/cli/errors.rb +1 -1
- data/lib/pdk/cli/exec/command.rb +12 -14
- data/lib/pdk/cli/exec/interactive_command.rb +11 -11
- data/lib/pdk/cli/exec.rb +4 -4
- data/lib/pdk/cli/exec_group.rb +1 -3
- data/lib/pdk/cli/get/config.rb +5 -5
- data/lib/pdk/cli/get.rb +2 -2
- data/lib/pdk/cli/module/build.rb +3 -3
- data/lib/pdk/cli/module/generate.rb +4 -4
- data/lib/pdk/cli/module.rb +3 -3
- data/lib/pdk/cli/new/class.rb +4 -4
- data/lib/pdk/cli/new/defined_type.rb +4 -4
- data/lib/pdk/cli/new/fact.rb +3 -3
- data/lib/pdk/cli/new/function.rb +4 -4
- data/lib/pdk/cli/new/module.rb +10 -11
- data/lib/pdk/cli/new/provider.rb +3 -3
- data/lib/pdk/cli/new/task.rb +5 -5
- data/lib/pdk/cli/new/test.rb +7 -7
- data/lib/pdk/cli/new/transport.rb +3 -3
- data/lib/pdk/cli/new.rb +3 -3
- data/lib/pdk/cli/release/prep.rb +9 -9
- data/lib/pdk/cli/release/publish.rb +7 -11
- data/lib/pdk/cli/release.rb +35 -39
- data/lib/pdk/cli/remove/config.rb +15 -15
- data/lib/pdk/cli/remove.rb +2 -2
- data/lib/pdk/cli/set/config.rb +16 -16
- data/lib/pdk/cli/set.rb +2 -2
- data/lib/pdk/cli/test/unit.rb +13 -13
- data/lib/pdk/cli/test.rb +2 -2
- data/lib/pdk/cli/update.rb +19 -29
- data/lib/pdk/cli/util/command_redirector.rb +1 -1
- data/lib/pdk/cli/util/interview.rb +4 -4
- data/lib/pdk/cli/util/option_normalizer.rb +2 -2
- data/lib/pdk/cli/util/option_validator.rb +1 -1
- data/lib/pdk/cli/util.rb +19 -20
- data/lib/pdk/cli/validate.rb +16 -18
- data/lib/pdk/cli.rb +16 -33
- data/lib/pdk/config/ini_file_setting.rb +2 -2
- data/lib/pdk/config/json_schema_namespace.rb +3 -3
- data/lib/pdk/config/json_schema_setting.rb +1 -1
- data/lib/pdk/config/json_with_schema.rb +1 -1
- data/lib/pdk/config/namespace.rb +4 -4
- data/lib/pdk/config/setting.rb +5 -5
- data/lib/pdk/config/validator.rb +2 -2
- data/lib/pdk/config/yaml.rb +2 -2
- data/lib/pdk/config/yaml_with_schema.rb +3 -3
- data/lib/pdk/config.rb +18 -20
- data/lib/pdk/context/control_repo.rb +1 -1
- data/lib/pdk/context/module.rb +1 -1
- data/lib/pdk/context/none.rb +1 -1
- data/lib/pdk/generate/module.rb +52 -64
- data/lib/pdk/generate/puppet_object.rb +6 -6
- data/lib/pdk/generate/task.rb +1 -1
- data/lib/pdk/module/build.rb +11 -16
- data/lib/pdk/module/convert.rb +14 -16
- data/lib/pdk/module/metadata.rb +12 -12
- data/lib/pdk/module/release.rb +20 -19
- data/lib/pdk/module/update.rb +5 -5
- data/lib/pdk/module/update_manager.rb +6 -6
- data/lib/pdk/report/event.rb +11 -11
- data/lib/pdk/template/fetcher/git.rb +4 -4
- data/lib/pdk/template/fetcher.rb +1 -1
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +1 -1
- data/lib/pdk/template/renderer/v1/renderer.rb +5 -7
- data/lib/pdk/template/renderer/v1/template_file.rb +3 -1
- data/lib/pdk/template/template_dir.rb +1 -1
- data/lib/pdk/template.rb +2 -2
- data/lib/pdk/tests/unit.rb +12 -12
- data/lib/pdk/util/bundler.rb +14 -14
- data/lib/pdk/util/changelog_generator.rb +6 -8
- data/lib/pdk/util/filesystem.rb +2 -2
- data/lib/pdk/util/git.rb +5 -5
- data/lib/pdk/util/puppet_strings.rb +2 -2
- data/lib/pdk/util/puppet_version.rb +24 -17
- data/lib/pdk/util/ruby_version.rb +2 -5
- data/lib/pdk/util/template_uri.rb +8 -8
- data/lib/pdk/util/vendored_file.rb +3 -3
- data/lib/pdk/util/windows/api_types.rb +3 -4
- data/lib/pdk/util/windows/file.rb +1 -1
- data/lib/pdk/util/windows/process.rb +5 -8
- data/lib/pdk/util.rb +2 -2
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +5 -5
- data/lib/pdk/validate/invokable_validator.rb +6 -6
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +2 -2
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +2 -2
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +38 -0
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -0
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +1 -1
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +4 -4
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +2 -5
- data/lib/pdk/validate/validator.rb +1 -1
- data/lib/pdk/validate/validator_group.rb +1 -1
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +4 -4
- data/lib/pdk/validate.rb +2 -1
- data/lib/pdk/version.rb +2 -2
- data/lib/pdk.rb +0 -2
- metadata +32 -54
- data/lib/pdk/i18n.rb +0 -4
- data/locales/config.yaml +0 -21
- data/locales/pdk.pot +0 -2111
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff7ec7444ab1a8f6876541359c945180230d9a1b0d6d1496ca012a974f33f4e
|
4
|
+
data.tar.gz: e35b850c844aa4fbb02236f080491b67a020fa52c76ead9a124b5974bb53ecc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc285deba8e2655836f16ddb7e8a121ab06e8e7b3c1ef8988332d605dd60ed95da7bc22f1a23e23ccd6059e913962307d9f6459ff563a5a601cb3b22bb0d99e
|
7
|
+
data.tar.gz: '0419acc5d19400b8908e7fc44b2361159d64ff24a7a328b87400994df9a30276f3bfac1c8dff77e1c6630df0643e8c8e42a205510288392bbd67f27a90e35498'
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,29 @@ 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
|
-
## [v2.
|
8
|
+
## [v2.7.1](https://github.com/puppetlabs/pdk/tree/v2.7.1) - 2023-03-24
|
9
|
+
|
10
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.7.0...v2.7.1)
|
11
|
+
|
12
|
+
## [v2.7.0](https://github.com/puppetlabs/pdk/tree/v2.7.0) - 2023-03-14
|
13
|
+
|
14
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.6.1...v2.7.0)
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- (CONT-694) Bump PDK Template Version [#1216](https://github.com/puppetlabs/pdk/pull/1216) ([chelnak](https://github.com/chelnak))
|
19
|
+
- (CONT-370) Remove i18n support [#1211](https://github.com/puppetlabs/pdk/pull/1211) ([chelnak](https://github.com/chelnak))
|
20
|
+
- Add Puppet validator for plans [#1207](https://github.com/puppetlabs/pdk/pull/1207) ([jay7x](https://github.com/jay7x))
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
|
24
|
+
- (CONT-722) Patch pe to puppet mapping [#1221](https://github.com/puppetlabs/pdk/pull/1221) ([chelnak](https://github.com/chelnak))
|
25
|
+
- (GH-1210) Require uri [#1220](https://github.com/puppetlabs/pdk/pull/1220) ([chelnak](https://github.com/chelnak))
|
26
|
+
- (CONT-720) Fix default version selection [#1219](https://github.com/puppetlabs/pdk/pull/1219) ([chelnak](https://github.com/chelnak))
|
27
|
+
- (CONT-719) Require JSON gem [#1218](https://github.com/puppetlabs/pdk/pull/1218) ([chelnak](https://github.com/chelnak))
|
28
|
+
- (CONT-669) Use bundle info command [#1215](https://github.com/puppetlabs/pdk/pull/1215) ([chelnak](https://github.com/chelnak))
|
29
|
+
|
30
|
+
## [v2.6.1](https://github.com/puppetlabs/pdk/tree/v2.6.1) - 2023-01-26
|
9
31
|
|
10
32
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.6.0...v2.6.1)
|
11
33
|
|
@@ -42,7 +42,7 @@ module PDK
|
|
42
42
|
|
43
43
|
def screen_view(screen, **kwargs)
|
44
44
|
custom_dimensions = walk_keys(kwargs) do |k|
|
45
|
-
CUSTOM_DIMENSIONS[k] || raise(
|
45
|
+
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '%{key}'" % { key: k })
|
46
46
|
end
|
47
47
|
|
48
48
|
screen_view_params = {
|
@@ -57,7 +57,7 @@ module PDK
|
|
57
57
|
|
58
58
|
def event(category, action, label: nil, value: nil, **kwargs)
|
59
59
|
custom_dimensions = walk_keys(kwargs) do |k|
|
60
|
-
CUSTOM_DIMENSIONS[k] || raise(
|
60
|
+
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '%{key}'" % { key: k })
|
61
61
|
end
|
62
62
|
|
63
63
|
event_params = {
|
@@ -92,6 +92,8 @@ module PDK
|
|
92
92
|
# These parameters have terrible names. See this page for complete documentation:
|
93
93
|
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
|
94
94
|
def base_params
|
95
|
+
require 'locale'
|
96
|
+
|
95
97
|
{
|
96
98
|
v: PROTOCOL_VERSION,
|
97
99
|
# Client ID
|
data/lib/pdk/cli/build.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@build_cmd = @base_cmd.define_command do
|
3
3
|
name 'build'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'build [options]'
|
5
|
+
summary 'Builds a package from the module that can be published to the Puppet Forge.'
|
6
6
|
|
7
7
|
option nil, 'target-dir',
|
8
|
-
|
8
|
+
'The target directory where you want PDK to write the package.',
|
9
9
|
argument: :required, default: File.join(Dir.pwd, 'pkg')
|
10
10
|
|
11
|
-
option nil, 'force',
|
11
|
+
option nil, 'force', 'Skips the prompts and builds the module package.'
|
12
12
|
|
13
13
|
run do |opts, _args, _cmd|
|
14
14
|
require 'pdk/module/build'
|
@@ -17,7 +17,7 @@ module PDK::CLI
|
|
17
17
|
|
18
18
|
# Make sure build is being run in a valid module directory with a metadata.json
|
19
19
|
PDK::CLI::Util.ensure_in_module!(
|
20
|
-
message:
|
20
|
+
message: '`pdk build` can only be run from inside a valid module with a metadata.json.',
|
21
21
|
log_level: :info,
|
22
22
|
)
|
23
23
|
|
@@ -30,12 +30,8 @@ module PDK::CLI
|
|
30
30
|
#
|
31
31
|
unless module_metadata.forge_ready?
|
32
32
|
if opts[:force]
|
33
|
-
PDK.logger.warn
|
34
|
-
|
35
|
-
'These missing fields may affect the visibility of the module on the Forge.',
|
36
|
-
) % {
|
37
|
-
fields: module_metadata.missing_fields.join(', '),
|
38
|
-
}
|
33
|
+
PDK.logger.warn "This module is missing the following fields in the metadata.json: #{module_metadata.missing_fields.join(', ')}. " \
|
34
|
+
'These missing fields may affect the visibility of the module on the Forge.'
|
39
35
|
else
|
40
36
|
module_metadata.interview_for_forge!
|
41
37
|
module_metadata.write!('metadata.json')
|
@@ -46,34 +42,34 @@ module PDK::CLI
|
|
46
42
|
|
47
43
|
unless opts[:force]
|
48
44
|
if builder.package_already_exists?
|
49
|
-
PDK.logger.info
|
45
|
+
PDK.logger.info "The file '%{package}' already exists." % { package: builder.package_file }
|
50
46
|
|
51
|
-
unless PDK::CLI::Util.prompt_for_yes(
|
52
|
-
PDK.logger.info
|
47
|
+
unless PDK::CLI::Util.prompt_for_yes('Overwrite?', default: false)
|
48
|
+
PDK.logger.info 'Build cancelled; exiting.'
|
53
49
|
exit 0
|
54
50
|
end
|
55
51
|
end
|
56
52
|
|
57
53
|
unless builder.module_pdk_compatible?
|
58
|
-
PDK.logger.info
|
59
|
-
|
60
|
-
|
54
|
+
PDK.logger.info 'This module is not compatible with PDK, so PDK can not validate or test this build. ' \
|
55
|
+
'Unvalidated modules may have errors when uploading to the Forge. ' \
|
56
|
+
'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.'
|
61
57
|
|
62
|
-
unless PDK::CLI::Util.prompt_for_yes(
|
63
|
-
PDK.logger.info
|
58
|
+
unless PDK::CLI::Util.prompt_for_yes('Continue build without converting?')
|
59
|
+
PDK.logger.info 'Build cancelled; exiting.'
|
64
60
|
exit 0
|
65
61
|
end
|
66
62
|
end
|
67
63
|
end
|
68
64
|
|
69
|
-
PDK.logger.info
|
65
|
+
PDK.logger.info 'Building %{module_name} version %{module_version}' % {
|
70
66
|
module_name: module_metadata.data['name'],
|
71
67
|
module_version: module_metadata.data['version'],
|
72
68
|
}
|
73
69
|
|
74
70
|
builder.build
|
75
71
|
|
76
|
-
PDK.logger.info
|
72
|
+
PDK.logger.info 'Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}' % {
|
77
73
|
package_name: module_metadata.data['name'],
|
78
74
|
package_path: builder.package_file,
|
79
75
|
}
|
data/lib/pdk/cli/bundle.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@bundle_cmd = @base_cmd.define_command do
|
3
3
|
name 'bundle'
|
4
|
-
usage
|
5
|
-
summary
|
6
|
-
description
|
4
|
+
usage 'bundle [bundler_options]'
|
5
|
+
summary '(Experimental) Command pass-through to bundler'
|
6
|
+
description <<-EOF
|
7
7
|
[experimental] For advanced users, pdk bundle runs arbitrary commands in the bundler environment that pdk manages.
|
8
8
|
Careless use of this command can lead to errors that pdk can't help recover from.
|
9
9
|
EOF
|
10
|
-
)
|
11
10
|
skip_option_parsing
|
12
11
|
|
13
12
|
run do |_opts, args, _cmd|
|
@@ -15,7 +14,7 @@ EOF
|
|
15
14
|
require 'pdk/util/bundler'
|
16
15
|
|
17
16
|
PDK::CLI::Util.ensure_in_module!(
|
18
|
-
message:
|
17
|
+
message: '`pdk bundle` can only be run from inside a valid module directory.',
|
19
18
|
)
|
20
19
|
|
21
20
|
PDK::CLI::Util.validate_puppet_version_opts({})
|
data/lib/pdk/cli/config/get.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@config_get_cmd = @config_cmd.define_command do
|
3
3
|
name 'get'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'config get [name]'
|
5
|
+
summary '(Deprecated) Retrieve the configuration for <name>. If not specified, retrieve all configuration settings'
|
6
6
|
|
7
7
|
run do |_opts, args, _cmd|
|
8
|
-
PDK.logger.warn
|
8
|
+
PDK.logger.warn 'The \'pdk config get\' command is deprecated, please use \'pdk get config\' instead.'
|
9
9
|
|
10
10
|
item_name = args[0]
|
11
11
|
resolved_config = PDK.config.resolve(item_name)
|
12
12
|
# If the user wanted to know a setting but it doesn't exist, raise an error
|
13
13
|
if resolved_config.empty? && !item_name.nil?
|
14
|
-
PDK.logger.error(
|
14
|
+
PDK.logger.error("Configuration item '%{name}' does not exist" % { name: item_name })
|
15
15
|
exit 1
|
16
16
|
end
|
17
17
|
# If the user requested a setting and it's the only one resolved, then just output the value
|
18
18
|
if resolved_config.count == 1 && resolved_config.keys[0] == item_name
|
19
|
-
puts
|
19
|
+
puts '%{value}' % { value: resolved_config.values[0] }
|
20
20
|
exit 0
|
21
21
|
end
|
22
22
|
# Otherwise just output everything
|
23
|
-
resolved_config.keys.sort.each { |key| puts
|
23
|
+
resolved_config.keys.sort.each { |key| puts '%{name}=%{value}' % { name: key, value: resolved_config[key] } }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/pdk/cli/config.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@config_cmd = @base_cmd.define_command do
|
3
3
|
name 'config'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'config [subcommand] [options]'
|
5
|
+
summary '(Deprecated) Configure the Puppet Development Kit.'
|
6
6
|
default_subcommand 'help'
|
7
7
|
|
8
8
|
run do |_opts, args, _cmd|
|
9
|
-
PDK.logger.warn
|
9
|
+
PDK.logger.warn 'The \'pdk config\' command is deprecated, please use \'pdk get config\' and \'pdk set config\' instead.'
|
10
10
|
|
11
11
|
if args == ['help']
|
12
12
|
PDK::CLI.run(%w[config --help])
|
data/lib/pdk/cli/console.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@console_cmd = @base_cmd.define_command do
|
3
3
|
name 'console'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'console [console_options]'
|
5
|
+
summary '(Experimental) Start a session of the puppet debugger console.'
|
6
6
|
default_subcommand 'help'
|
7
|
-
description
|
7
|
+
description <<-EOF
|
8
8
|
The pdk console runs a interactive session of the puppet debugger tool to test out snippets of code, run
|
9
9
|
language evaluations, datatype prototyping and much more. A virtual playground for your puppet code!
|
10
10
|
For usage details see the puppet debugger docs at https://docs.puppet-debugger.com.
|
11
11
|
|
12
12
|
EOF
|
13
|
-
|
13
|
+
|
14
14
|
PDK::CLI.puppet_version_options(self)
|
15
15
|
PDK::CLI.puppet_dev_option(self)
|
16
16
|
# we have to skip option parsing because it is expected the user
|
@@ -23,7 +23,7 @@ EOF
|
|
23
23
|
require 'pdk/util'
|
24
24
|
|
25
25
|
PDK::CLI::Util.ensure_in_module!(
|
26
|
-
message:
|
26
|
+
message: 'Console can only be run from inside a valid module directory',
|
27
27
|
log_level: :fatal,
|
28
28
|
)
|
29
29
|
|
@@ -78,7 +78,7 @@ EOF
|
|
78
78
|
lock_file = ::Bundler::LockfileParser.new(::Bundler.read_file(lock_file_path))
|
79
79
|
!lock_file.specs.find { |spec| spec.name.eql?(gem_name) }.nil?
|
80
80
|
rescue ::Bundler::GemfileNotFound => e
|
81
|
-
PDK.logger.debug
|
81
|
+
PDK.logger.debug e.message
|
82
82
|
false
|
83
83
|
end
|
84
84
|
|
@@ -86,7 +86,7 @@ EOF
|
|
86
86
|
existing_path = base_module_path.split(':').find do |path|
|
87
87
|
PDK::Util::Filesystem.directory?(path) && Dir.entries(path).length > 2
|
88
88
|
end
|
89
|
-
PDK.logger.warn
|
89
|
+
PDK.logger.warn 'Module fixtures not found, please run pdk bundle exec rake spec_prep.' unless existing_path
|
90
90
|
end
|
91
91
|
|
92
92
|
# @return [Array] - array of split options [{:"puppet-version"=>"6.9.0"}, ['--loglevel=debug']]
|
data/lib/pdk/cli/convert.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@convert_cmd = @base_cmd.define_command do
|
3
3
|
name 'convert'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'convert [options]'
|
5
|
+
summary 'Convert an existing module to be compatible with the PDK.'
|
6
6
|
|
7
7
|
PDK::CLI.template_url_option(self)
|
8
8
|
PDK::CLI.template_ref_option(self)
|
9
9
|
PDK::CLI.skip_interview_option(self)
|
10
10
|
PDK::CLI.full_interview_option(self)
|
11
|
-
flag nil, :noop,
|
12
|
-
flag nil, :force,
|
13
|
-
flag nil, :'add-tests',
|
14
|
-
flag nil, :'default-template',
|
11
|
+
flag nil, :noop, 'Do not convert the module, just output what would be done.'
|
12
|
+
flag nil, :force, 'Convert the module automatically, with no prompts.'
|
13
|
+
flag nil, :'add-tests', 'Add any missing tests while converting the module.'
|
14
|
+
flag nil, :'default-template', 'Convert the module to use the default PDK template.'
|
15
15
|
|
16
16
|
run do |opts, _args, _cmd|
|
17
17
|
# Write the context information to the debug log
|
18
18
|
PDK.context.to_debug_log
|
19
19
|
|
20
20
|
unless PDK.context.is_a?(PDK::Context::Module)
|
21
|
-
raise PDK::CLI::ExitWithError,
|
21
|
+
raise PDK::CLI::ExitWithError, '`pdk convert` can only be run from inside a valid module directory.'
|
22
22
|
end
|
23
23
|
|
24
24
|
if opts[:noop] && opts[:force]
|
25
|
-
raise PDK::CLI::ExitWithError,
|
25
|
+
raise PDK::CLI::ExitWithError, 'You can not specify --noop and --force when converting a module'
|
26
26
|
end
|
27
27
|
|
28
28
|
if opts[:'default-template']
|
29
|
-
raise PDK::CLI::ExitWithError,
|
29
|
+
raise PDK::CLI::ExitWithError, 'You can not specify --template-url and --default-template.' if opts[:'template-url']
|
30
30
|
|
31
31
|
opts[:'template-url'] = PDK::Util::TemplateURI.default_template_addressable_uri.to_s
|
32
32
|
PDK.config.set(%w[user module_defaults template-url], nil)
|
@@ -37,12 +37,12 @@ module PDK::CLI
|
|
37
37
|
PDK::CLI::Util.analytics_screen_view('convert', opts)
|
38
38
|
|
39
39
|
if opts[:'skip-interview'] && opts[:'full-interview']
|
40
|
-
PDK.logger.info
|
40
|
+
PDK.logger.info 'Ignoring --full-interview and continuing with --skip-interview.'
|
41
41
|
opts[:'full-interview'] = false
|
42
42
|
end
|
43
43
|
|
44
44
|
if opts[:force] && opts[:'full-interview']
|
45
|
-
PDK.logger.info
|
45
|
+
PDK.logger.info 'Ignoring --full-interview and continuing with --force.'
|
46
46
|
opts[:'full-interview'] = false
|
47
47
|
end
|
48
48
|
|
data/lib/pdk/cli/env.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@env_cmd = @base_cmd.define_command do
|
3
3
|
name 'env'
|
4
|
-
usage
|
5
|
-
summary
|
6
|
-
description
|
4
|
+
usage 'env'
|
5
|
+
summary '(Experimental) Output environment variables for specific Puppet context'
|
6
|
+
description <<-EOF
|
7
7
|
[experimental] Aids in setting a CLI context for a specified version of Puppet by outputting export commands for necessary environment variables.
|
8
8
|
EOF
|
9
|
-
)
|
10
9
|
|
11
10
|
PDK::CLI.puppet_version_options(self)
|
12
11
|
PDK::CLI.puppet_dev_option(self)
|
data/lib/pdk/cli/errors.rb
CHANGED
@@ -5,7 +5,7 @@ module PDK
|
|
5
5
|
class FatalError < StandardError
|
6
6
|
attr_reader :exit_code
|
7
7
|
|
8
|
-
def initialize(msg =
|
8
|
+
def initialize(msg = 'An unexpected error has occurred. Try running the command again with --debug', opts = {})
|
9
9
|
@exit_code = opts.fetch(:exit_code, 1)
|
10
10
|
super(msg)
|
11
11
|
end
|
data/lib/pdk/cli/exec/command.rb
CHANGED
@@ -57,7 +57,7 @@ module PDK
|
|
57
57
|
|
58
58
|
def context=(new_context)
|
59
59
|
unless [:system, :module, :pwd].include?(new_context)
|
60
|
-
raise ArgumentError,
|
60
|
+
raise ArgumentError, "Expected execution context to be :system or :module but got '%{context}'." % { context: new_context }
|
61
61
|
end
|
62
62
|
|
63
63
|
@context = new_context
|
@@ -108,7 +108,7 @@ module PDK
|
|
108
108
|
unless mod_root
|
109
109
|
@spinner.error if @spinner
|
110
110
|
|
111
|
-
raise PDK::CLI::FatalError,
|
111
|
+
raise PDK::CLI::FatalError, 'Current working directory is not part of a module. (No metadata.json was found.)'
|
112
112
|
end
|
113
113
|
|
114
114
|
if Dir.pwd == mod_root || context == :pwd
|
@@ -135,10 +135,10 @@ module PDK
|
|
135
135
|
duration: @duration,
|
136
136
|
}
|
137
137
|
|
138
|
-
PDK.logger.debug
|
138
|
+
PDK.logger.debug 'STDOUT: %{output}' % {
|
139
139
|
output: process_data[:stdout].empty? ? 'N/A' : "\n#{process_data[:stdout]}",
|
140
140
|
}
|
141
|
-
PDK.logger.debug
|
141
|
+
PDK.logger.debug 'STDERR: %{output}' % {
|
142
142
|
output: process_data[:stderr].empty? ? 'N/A' : "\n#{process_data[:stderr]}",
|
143
143
|
}
|
144
144
|
|
@@ -152,16 +152,14 @@ module PDK
|
|
152
152
|
|
153
153
|
def warn_on_legacy_env_vars!
|
154
154
|
if PDK::Util::Env['PUPPET_GEM_VERSION']
|
155
|
-
PDK.logger.warn_once
|
156
|
-
|
157
|
-
|
158
|
-
'or set the PDK_PUPPET_VERSION environment variable instead',
|
159
|
-
)
|
155
|
+
PDK.logger.warn_once 'PUPPET_GEM_VERSION is not supported by PDK. ' \
|
156
|
+
'Use the --puppet-version option on your PDK command ' \
|
157
|
+
'or set the PDK_PUPPET_VERSION environment variable instead'
|
160
158
|
end
|
161
159
|
|
162
160
|
%w[FACTER HIERA].each do |gem|
|
163
161
|
if PDK::Util::Env["#{gem}_GEM_VERSION"]
|
164
|
-
PDK.logger.warn_once
|
162
|
+
PDK.logger.warn_once '%{varname} is not supported by PDK.' % { varname: "#{gem}_GEM_VERSION" }
|
165
163
|
end
|
166
164
|
end
|
167
165
|
end
|
@@ -232,10 +230,10 @@ module PDK
|
|
232
230
|
def run_process!
|
233
231
|
command_string = argv.join(' ')
|
234
232
|
|
235
|
-
PDK.logger.debug(
|
233
|
+
PDK.logger.debug("Executing '%{command}'" % { command: command_string })
|
236
234
|
|
237
235
|
if context == :module
|
238
|
-
PDK.logger.debug(
|
236
|
+
PDK.logger.debug('Command environment:')
|
239
237
|
@process.environment.each do |var, val|
|
240
238
|
PDK.logger.debug(" #{var}: #{val}")
|
241
239
|
end
|
@@ -246,7 +244,7 @@ module PDK
|
|
246
244
|
begin
|
247
245
|
@process.start
|
248
246
|
rescue ChildProcess::LaunchError => e
|
249
|
-
raise PDK::CLI::FatalError,
|
247
|
+
raise PDK::CLI::FatalError, "Failed to execute '%{command}': %{message}" % { command: command_string, message: e.message }
|
250
248
|
end
|
251
249
|
|
252
250
|
if timeout
|
@@ -262,7 +260,7 @@ module PDK
|
|
262
260
|
|
263
261
|
@duration = Time.now - start_time
|
264
262
|
|
265
|
-
PDK.logger.debug(
|
263
|
+
PDK.logger.debug("Execution of '%{command}' complete (duration: %{duration_in_seconds}s; exit code: %{exit_code})" %
|
266
264
|
{ command: command_string, duration_in_seconds: @duration, exit_code: @process.exit_code })
|
267
265
|
end
|
268
266
|
|
@@ -15,23 +15,23 @@ module PDK
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def register_spinner(_spinner, _opts = {})
|
18
|
-
raise
|
18
|
+
raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
|
19
19
|
end
|
20
20
|
|
21
21
|
def add_spinner(_message, _opts = {})
|
22
|
-
raise
|
22
|
+
raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
|
23
23
|
end
|
24
24
|
|
25
25
|
def timeout
|
26
|
-
raise
|
26
|
+
raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
|
27
27
|
end
|
28
28
|
|
29
29
|
def timeout=(_val)
|
30
|
-
raise
|
30
|
+
raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
|
31
31
|
end
|
32
32
|
|
33
33
|
def exec_group=(_val)
|
34
|
-
raise
|
34
|
+
raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
|
35
35
|
end
|
36
36
|
|
37
37
|
def execute!
|
@@ -43,7 +43,7 @@ module PDK
|
|
43
43
|
mod_root = PDK::Util.module_root
|
44
44
|
|
45
45
|
unless mod_root
|
46
|
-
raise PDK::CLI::FatalError,
|
46
|
+
raise PDK::CLI::FatalError, 'Current working directory is not part of a module. (No metadata.json was found.)'
|
47
47
|
end
|
48
48
|
|
49
49
|
unless context == :pwd || Dir.pwd == mod_root
|
@@ -72,10 +72,10 @@ module PDK
|
|
72
72
|
# TODO: debug logging
|
73
73
|
def run_process!
|
74
74
|
command_string = argv.join(' ')
|
75
|
-
PDK.logger.debug(
|
75
|
+
PDK.logger.debug("Executing '%{command}' interactively" % { command: command_string })
|
76
76
|
|
77
77
|
if context == :module
|
78
|
-
PDK.logger.debug(
|
78
|
+
PDK.logger.debug('Command environment:')
|
79
79
|
@resolved_env.each do |var, val|
|
80
80
|
PDK.logger.debug(" #{var}: #{val}")
|
81
81
|
end
|
@@ -88,8 +88,8 @@ module PDK
|
|
88
88
|
exit_code = child_status.exitstatus
|
89
89
|
duration = Time.now - start_time
|
90
90
|
|
91
|
-
PDK.logger.debug(
|
92
|
-
%{duration_in_seconds}s; exit code: %{exit_code})"
|
91
|
+
PDK.logger.debug("Execution of '%{command}' complete (duration: \
|
92
|
+
%{duration_in_seconds}s; exit code: %{exit_code})" %
|
93
93
|
{
|
94
94
|
command: command_string,
|
95
95
|
exit_code: exit_code,
|
@@ -106,7 +106,7 @@ module PDK
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def stop_spinner
|
109
|
-
raise
|
109
|
+
raise 'This method is not implemented for PDK::CLI::Exec::InteractiveCommand'
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
data/lib/pdk/cli/exec.rb
CHANGED
@@ -33,7 +33,7 @@ module PDK
|
|
33
33
|
def self.ensure_bin_present!(bin_path, bin_name)
|
34
34
|
require 'tty-which'
|
35
35
|
|
36
|
-
message =
|
36
|
+
message = 'Unable to find `%{name}`. Check that it is installed and try again.' % {
|
37
37
|
name: bin_name,
|
38
38
|
}
|
39
39
|
|
@@ -59,7 +59,7 @@ module PDK
|
|
59
59
|
require 'pdk/util'
|
60
60
|
|
61
61
|
unless PDK::Util.package_install?
|
62
|
-
PDK.logger.debug(
|
62
|
+
PDK.logger.debug("PDK package installation not found. Trying '%{fallback}' from the system PATH instead." % {
|
63
63
|
fallback: fallback,
|
64
64
|
})
|
65
65
|
return fallback
|
@@ -69,14 +69,14 @@ module PDK
|
|
69
69
|
|
70
70
|
require 'pdk/util/filesystem'
|
71
71
|
unless PDK::Util::Filesystem.exist?(vendored_bin_full_path)
|
72
|
-
PDK.logger.debug(
|
72
|
+
PDK.logger.debug("Could not find '%{vendored_bin}' in PDK package. Trying '%{fallback}' from the system PATH instead." % {
|
73
73
|
fallback: fallback,
|
74
74
|
vendored_bin: vendored_bin_full_path,
|
75
75
|
})
|
76
76
|
return fallback
|
77
77
|
end
|
78
78
|
|
79
|
-
PDK.logger.debug
|
79
|
+
PDK.logger.debug "Using '%{vendored_bin}' from PDK package." % { vendored_bin: vendored_bin_full_path }
|
80
80
|
vendored_bin_full_path
|
81
81
|
end
|
82
82
|
end
|
data/lib/pdk/cli/exec_group.rb
CHANGED
@@ -38,7 +38,7 @@ module PDK
|
|
38
38
|
#
|
39
39
|
# @api private
|
40
40
|
def register(&_block)
|
41
|
-
raise PDK::CLI::FatalError,
|
41
|
+
raise PDK::CLI::FatalError, 'No block registered' unless block_given?
|
42
42
|
end
|
43
43
|
|
44
44
|
# The return code of running all registered blocks
|
@@ -88,8 +88,6 @@ module PDK
|
|
88
88
|
# and only starts on the call to exit_code
|
89
89
|
# e.g. max_threads = No. of CPUs
|
90
90
|
@threads << Thread.new do
|
91
|
-
GettextSetup.initialize(File.absolute_path('../../../locales', File.dirname(__FILE__)))
|
92
|
-
GettextSetup.negotiate_locale!(GettextSetup.candidate_locales)
|
93
91
|
@exit_codes << yield
|
94
92
|
end
|
95
93
|
end
|
data/lib/pdk/cli/get/config.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@get_config_cmd = @get_cmd.define_command do
|
3
3
|
name 'config'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'config [name]'
|
5
|
+
summary 'Retrieve the configuration for <name>. If not specified, retrieve all configuration settings'
|
6
6
|
|
7
7
|
run do |_opts, args, _cmd|
|
8
8
|
item_name = args[0]
|
9
9
|
resolved_config = PDK.config.resolve(item_name)
|
10
10
|
# If the user wanted to know a setting but it doesn't exist, raise an error
|
11
11
|
if resolved_config.empty? && !item_name.nil?
|
12
|
-
PDK.logger.error(
|
12
|
+
PDK.logger.error("Configuration item '%{name}' does not exist" % { name: item_name })
|
13
13
|
exit 1
|
14
14
|
end
|
15
15
|
# If the user requested a setting and it's the only one resolved, then just output the value
|
16
16
|
if resolved_config.count == 1 && resolved_config.keys[0] == item_name
|
17
|
-
puts
|
17
|
+
puts '%{value}' % { value: resolved_config.values[0] }
|
18
18
|
exit 0
|
19
19
|
end
|
20
20
|
# Otherwise just output everything
|
21
|
-
resolved_config.keys.sort.each { |key| puts
|
21
|
+
resolved_config.keys.sort.each { |key| puts '%{name}=%{value}' % { name: key, value: resolved_config[key] } }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/pdk/cli/get.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@get_cmd = @base_cmd.define_command do
|
3
3
|
name 'get'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'get [subcommand] [options]'
|
5
|
+
summary 'Retrieve information about the PDK or current project.'
|
6
6
|
default_subcommand 'help'
|
7
7
|
|
8
8
|
run do |_opts, args, _cmd|
|
data/lib/pdk/cli/module/build.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@module_build_cmd = @module_cmd.define_command do
|
3
3
|
name 'build'
|
4
|
-
usage
|
5
|
-
summary
|
4
|
+
usage 'build'
|
5
|
+
summary 'This command is now \'pdk build\'.'
|
6
6
|
|
7
7
|
run do |_opts, _args, _cmd|
|
8
|
-
PDK.logger.warn(
|
8
|
+
PDK.logger.warn("Modules are built using the 'pdk build' command.")
|
9
9
|
exit 1
|
10
10
|
end
|
11
11
|
end
|