pdk 2.7.1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +10 -50
- data/lib/pdk/analytics/client/google_analytics.rb +22 -26
- data/lib/pdk/analytics/util.rb +0 -1
- data/lib/pdk/analytics.rb +1 -1
- data/lib/pdk/bolt.rb +1 -0
- data/lib/pdk/cli/build.rb +53 -56
- data/lib/pdk/cli/bundle.rb +34 -33
- data/lib/pdk/cli/console.rb +136 -134
- data/lib/pdk/cli/convert.rb +39 -41
- data/lib/pdk/cli/env.rb +49 -47
- data/lib/pdk/cli/errors.rb +1 -2
- data/lib/pdk/cli/exec/command.rb +23 -29
- data/lib/pdk/cli/exec/interactive_command.rb +7 -12
- data/lib/pdk/cli/exec.rb +4 -11
- data/lib/pdk/cli/exec_group.rb +3 -2
- data/lib/pdk/cli/get/config.rb +21 -19
- data/lib/pdk/cli/get.rb +15 -13
- data/lib/pdk/cli/new/class.rb +22 -22
- data/lib/pdk/cli/new/defined_type.rb +22 -22
- data/lib/pdk/cli/new/fact.rb +19 -19
- data/lib/pdk/cli/new/function.rb +20 -20
- data/lib/pdk/cli/new/module.rb +40 -38
- data/lib/pdk/cli/new/provider.rb +19 -19
- data/lib/pdk/cli/new/task.rb +23 -23
- data/lib/pdk/cli/new/test.rb +50 -48
- data/lib/pdk/cli/new/transport.rb +18 -18
- data/lib/pdk/cli/new.rb +11 -9
- data/lib/pdk/cli/release/prep.rb +27 -25
- data/lib/pdk/cli/release/publish.rb +39 -37
- data/lib/pdk/cli/release.rb +152 -149
- data/lib/pdk/cli/remove/config.rb +63 -60
- data/lib/pdk/cli/remove.rb +15 -13
- data/lib/pdk/cli/set/config.rb +91 -89
- data/lib/pdk/cli/set.rb +15 -13
- data/lib/pdk/cli/test/unit.rb +71 -69
- data/lib/pdk/cli/test.rb +9 -7
- data/lib/pdk/cli/update.rb +33 -38
- data/lib/pdk/cli/util/command_redirector.rb +10 -1
- data/lib/pdk/cli/util/interview.rb +11 -4
- data/lib/pdk/cli/util/option_normalizer.rb +3 -5
- data/lib/pdk/cli/util/option_validator.rb +7 -9
- data/lib/pdk/cli/util/update_manager_printer.rb +4 -4
- data/lib/pdk/cli/util.rb +32 -48
- data/lib/pdk/cli/validate.rb +98 -96
- data/lib/pdk/cli.rb +124 -120
- data/lib/pdk/config/ini_file.rb +4 -3
- data/lib/pdk/config/ini_file_setting.rb +6 -10
- data/lib/pdk/config/json.rb +1 -0
- data/lib/pdk/config/json_schema_namespace.rb +5 -10
- data/lib/pdk/config/json_schema_setting.rb +3 -5
- data/lib/pdk/config/json_with_schema.rb +2 -4
- data/lib/pdk/config/namespace.rb +22 -14
- data/lib/pdk/config/setting.rb +5 -6
- data/lib/pdk/config/task_schema.json +116 -0
- data/lib/pdk/config/validator.rb +4 -4
- data/lib/pdk/config/yaml.rb +3 -8
- data/lib/pdk/config/yaml_with_schema.rb +4 -12
- data/lib/pdk/config.rb +47 -51
- data/lib/pdk/context/control_repo.rb +3 -2
- data/lib/pdk/context/module.rb +2 -2
- data/lib/pdk/context/none.rb +2 -2
- data/lib/pdk/context.rb +4 -5
- data/lib/pdk/control_repo.rb +3 -4
- data/lib/pdk/generate/defined_type.rb +3 -3
- data/lib/pdk/generate/fact.rb +3 -2
- data/lib/pdk/generate/function.rb +5 -4
- data/lib/pdk/generate/module.rb +91 -106
- data/lib/pdk/generate/provider.rb +5 -4
- data/lib/pdk/generate/puppet_class.rb +3 -3
- data/lib/pdk/generate/puppet_object.rb +9 -12
- data/lib/pdk/generate/task.rb +11 -10
- data/lib/pdk/generate/transport.rb +8 -7
- data/lib/pdk/generate.rb +1 -1
- data/lib/pdk/logger.rb +3 -2
- data/lib/pdk/module/build.rb +34 -49
- data/lib/pdk/module/convert.rb +13 -22
- data/lib/pdk/module/metadata.rb +53 -61
- data/lib/pdk/module/release.rb +19 -25
- data/lib/pdk/module/update.rb +4 -13
- data/lib/pdk/module/update_manager.rb +18 -25
- data/lib/pdk/module.rb +1 -1
- data/lib/pdk/monkey_patches.rb +268 -0
- data/lib/pdk/report/event.rb +12 -37
- data/lib/pdk/report.rb +11 -7
- data/lib/pdk/template/fetcher/git.rb +7 -8
- data/lib/pdk/template/fetcher/local.rb +1 -0
- data/lib/pdk/template/fetcher.rb +4 -2
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +4 -9
- data/lib/pdk/template/renderer/v1/renderer.rb +19 -20
- data/lib/pdk/template/renderer/v1/template_file.rb +4 -8
- data/lib/pdk/template/renderer/v1.rb +1 -1
- data/lib/pdk/template/renderer.rb +1 -0
- data/lib/pdk/template/template_dir.rb +3 -3
- data/lib/pdk/template.rb +2 -6
- data/lib/pdk/tests/unit.rb +36 -25
- data/lib/pdk/util/bundler.rb +10 -14
- data/lib/pdk/util/changelog_generator.rb +15 -12
- data/lib/pdk/util/env.rb +1 -0
- data/lib/pdk/util/filesystem.rb +18 -17
- data/lib/pdk/util/git.rb +16 -21
- data/lib/pdk/util/json_finder.rb +7 -6
- data/lib/pdk/util/puppet_strings.rb +1 -1
- data/lib/pdk/util/puppet_version.rb +21 -68
- data/lib/pdk/util/ruby_version.rb +9 -13
- data/lib/pdk/util/template_uri.rb +17 -29
- data/lib/pdk/util/vendored_file.rb +5 -18
- data/lib/pdk/util/windows/api_types.rb +70 -64
- data/lib/pdk/util/windows/file.rb +31 -27
- data/lib/pdk/util/windows/process.rb +59 -61
- data/lib/pdk/util/windows/string.rb +19 -12
- data/lib/pdk/util.rb +13 -21
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +1 -1
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +25 -25
- data/lib/pdk/validate/external_command_validator.rb +6 -1
- data/lib/pdk/validate/internal_ruby_validator.rb +5 -4
- data/lib/pdk/validate/invokable_validator.rb +30 -20
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +12 -14
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +13 -15
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +16 -18
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +14 -14
- data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +1 -1
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +16 -18
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -1
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +10 -11
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +1 -1
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +19 -24
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +11 -13
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +1 -1
- data/lib/pdk/validate/validator.rb +4 -2
- data/lib/pdk/validate/validator_group.rb +6 -3
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +27 -36
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +1 -1
- data/lib/pdk/validate.rb +6 -6
- data/lib/pdk/version.rb +2 -2
- data/lib/pdk.rb +12 -12
- metadata +27 -35
- data/lib/pdk/cli/config/get.rb +0 -26
- data/lib/pdk/cli/config.rb +0 -22
- data/lib/pdk/cli/module/build.rb +0 -12
- data/lib/pdk/cli/module/generate.rb +0 -47
- data/lib/pdk/cli/module.rb +0 -14
data/lib/pdk/cli/new/test.rb
CHANGED
@@ -1,51 +1,53 @@
|
|
1
|
-
module PDK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
module PDK
|
2
|
+
module CLI
|
3
|
+
@new_define_cmd = @new_cmd.define_command do
|
4
|
+
name 'test'
|
5
|
+
usage 'test [options] <name>'
|
6
|
+
summary 'Create a new test for the object named <name>'
|
7
|
+
flag :u, :unit, 'Create a new unit test.'
|
8
|
+
PDK::CLI.puppet_version_options(self)
|
9
|
+
PDK::CLI.puppet_dev_option(self)
|
10
|
+
|
11
|
+
run do |opts, args, _cmd|
|
12
|
+
require 'pdk/util/puppet_strings'
|
13
|
+
require 'pdk/util/bundler'
|
14
|
+
|
15
|
+
PDK::CLI::Util.validate_puppet_version_opts(opts)
|
16
|
+
PDK::CLI::Util.ensure_in_module!(
|
17
|
+
message: 'Tests can only be created from inside a valid module directory.',
|
18
|
+
log_level: :info
|
19
|
+
)
|
20
|
+
|
21
|
+
object_name = args[0]
|
22
|
+
|
23
|
+
if object_name.nil? || object_name.empty?
|
24
|
+
puts command.help
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
unless opts[:unit]
|
29
|
+
# At a future time, we'll replace this conditional with an interactive
|
30
|
+
# question to choose the test type.
|
31
|
+
PDK.logger.info 'Test type not specified, assuming unit.'
|
32
|
+
opts[:unit] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
|
36
|
+
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
37
|
+
PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
|
38
|
+
|
39
|
+
begin
|
40
|
+
generator, obj = PDK::Util::PuppetStrings.find_object(object_name)
|
41
|
+
|
42
|
+
PDK::CLI::Util.analytics_screen_view('new_test', opts)
|
43
|
+
|
44
|
+
updates = generator.new(PDK.context, obj['name'], opts.merge(spec_only: true)).run
|
45
|
+
PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
|
46
|
+
rescue PDK::Util::PuppetStrings::NoObjectError
|
47
|
+
raise PDK::CLI::ExitWithError, format('Unable to find anything called "%{object}" to generate unit tests for.', object: object_name)
|
48
|
+
rescue PDK::Util::PuppetStrings::NoGeneratorError => e
|
49
|
+
raise PDK::CLI::ExitWithError, format('PDK does not support generating unit tests for "%{object_type}" objects.', object_type: e.message)
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
module PDK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module PDK
|
2
|
+
module CLI
|
3
|
+
@new_transport_cmd = @new_cmd.define_command do
|
4
|
+
name 'transport'
|
5
|
+
usage 'transport [options] <name>'
|
6
|
+
summary '[experimental] Create a new ruby transport named <name> using given options'
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
run do |opts, args, _cmd|
|
9
|
+
PDK::CLI::Util.ensure_in_module!
|
9
10
|
|
10
|
-
|
11
|
+
transport_name = args[0]
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
if transport_name.nil? || transport_name.empty?
|
14
|
+
puts command.help
|
15
|
+
exit 1
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
raise PDK::CLI::ExitWithError, "'%{name}' is not a valid transport name" % { name: transport_name }
|
19
|
-
end
|
18
|
+
raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid transport name", name: transport_name) unless Util::OptionValidator.valid_transport_name?(transport_name)
|
20
19
|
|
21
|
-
|
20
|
+
require 'pdk/generate/transport'
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
updates = PDK::Generate::Transport.new(PDK.context, transport_name, opts).run
|
23
|
+
PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/pdk/cli/new.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
module PDK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
module PDK
|
2
|
+
module CLI
|
3
|
+
@new_cmd = @base_cmd.define_command do
|
4
|
+
name 'new'
|
5
|
+
usage 'new <thing> [options]'
|
6
|
+
summary 'create a new module, etc.'
|
7
|
+
description 'Creates a new <thing> using relevant options.'
|
8
|
+
default_subcommand 'help'
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
@new_cmd.add_command Cri::Command.new_basic_help
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
require 'pdk/cli/new/class'
|
data/lib/pdk/cli/release/prep.rb
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
require 'pdk/cli/release'
|
2
2
|
|
3
|
-
module PDK
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module PDK
|
4
|
+
module CLI
|
5
|
+
@release_prep_cmd = @release_cmd.define_command do
|
6
|
+
name 'prep'
|
7
|
+
usage 'prep [options]'
|
8
|
+
summary '(Experimental) Performs all the pre-release checks to ensure module is ready to be released'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
flag nil, :force, 'Prepare the module automatically, with no prompts.'
|
11
|
+
flag nil, :'skip-validation', 'Skips the module validation check.'
|
12
|
+
flag nil, :'skip-changelog', 'Skips the automatic changelog generation.'
|
13
|
+
flag nil, :'skip-dependency', 'Skips the module dependency check.'
|
14
|
+
flag nil, :'skip-documentation', 'Skips the documentation update.'
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
option nil, :version, 'Update the module to the specified version prior to release. When not specified, the new version will be computed from the Changelog where possible.',
|
17
|
+
argument: :required
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
run do |opts, _args, cmd|
|
20
|
+
# Make sure build is being run in a valid module directory with a metadata.json
|
21
|
+
PDK::CLI::Util.ensure_in_module!(
|
22
|
+
message: "`pdk release #{cmd.name}` can only be run from inside a valid module with a metadata.json.",
|
23
|
+
log_level: :info
|
24
|
+
)
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
opts[:'skip-build'] = true
|
27
|
+
opts[:'skip-publish'] = true
|
27
28
|
|
28
|
-
|
29
|
+
Release.prepare_interview(opts) unless opts[:force]
|
29
30
|
|
30
|
-
|
31
|
+
Release.send_analytics("release #{cmd.name}", opts)
|
31
32
|
|
32
|
-
|
33
|
+
release = PDK::Module::Release.new(nil, opts)
|
33
34
|
|
34
|
-
|
35
|
+
Release.module_compatibility_checks!(release, opts)
|
35
36
|
|
36
|
-
|
37
|
+
release.run
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -1,46 +1,48 @@
|
|
1
1
|
require 'pdk/cli/release'
|
2
2
|
|
3
|
-
module PDK
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
run do |opts, _args, cmd|
|
17
|
-
# Make sure build is being run in a valid module directory with a metadata.json
|
18
|
-
PDK::CLI::Util.ensure_in_module!(
|
19
|
-
message: "`pdk release #{cmd.name}` can only be run from inside a valid module with a metadata.json.",
|
20
|
-
log_level: :info,
|
21
|
-
)
|
22
|
-
|
23
|
-
opts[:'skip-validation'] = true
|
24
|
-
opts[:'skip-changelog'] = true
|
25
|
-
opts[:'skip-dependency'] = true
|
26
|
-
opts[:'skip-documentation'] = true
|
27
|
-
opts[:'skip-build'] = true
|
28
|
-
opts[:'skip-versionset'] = true
|
29
|
-
opts[:force] = true unless PDK::CLI::Util.interactive?
|
30
|
-
opts[:'forge-token'] ||= PDK::Util::Env['PDK_FORGE_TOKEN']
|
31
|
-
|
32
|
-
if opts[:'forge-token'].nil? || opts[:'forge-token'].empty?
|
33
|
-
PDK.logger.error 'You must supply a Forge API token either via `--forge-token` option or PDK_FORGE_TOKEN environment variable.'
|
34
|
-
exit 1
|
35
|
-
end
|
3
|
+
module PDK
|
4
|
+
module CLI
|
5
|
+
@release_publish_cmd = @release_cmd.define_command do
|
6
|
+
name 'publish'
|
7
|
+
usage 'publish [options] <tarball>'
|
8
|
+
summary '(Experimental) Publishes the module <tarball> to the Forge.'
|
9
|
+
|
10
|
+
flag nil, :force, 'Publish the module automatically, with no prompts.'
|
11
|
+
|
12
|
+
option nil, :'forge-upload-url', 'Set forge upload url path.',
|
13
|
+
argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
|
14
|
+
|
15
|
+
option nil, :'forge-token', 'Set Forge API token (you may also set via environment variable PDK_FORGE_TOKEN)', argument: :required
|
36
16
|
|
37
|
-
|
17
|
+
run do |opts, _args, cmd|
|
18
|
+
# Make sure build is being run in a valid module directory with a metadata.json
|
19
|
+
PDK::CLI::Util.ensure_in_module!(
|
20
|
+
message: "`pdk release #{cmd.name}` can only be run from inside a valid module with a metadata.json.",
|
21
|
+
log_level: :info
|
22
|
+
)
|
38
23
|
|
39
|
-
|
24
|
+
opts[:'skip-validation'] = true
|
25
|
+
opts[:'skip-changelog'] = true
|
26
|
+
opts[:'skip-dependency'] = true
|
27
|
+
opts[:'skip-documentation'] = true
|
28
|
+
opts[:'skip-build'] = true
|
29
|
+
opts[:'skip-versionset'] = true
|
30
|
+
opts[:force] = true unless PDK::CLI::Util.interactive?
|
31
|
+
opts[:'forge-token'] ||= PDK::Util::Env['PDK_FORGE_TOKEN']
|
40
32
|
|
41
|
-
|
33
|
+
if opts[:'forge-token'].nil? || opts[:'forge-token'].empty?
|
34
|
+
PDK.logger.error 'You must supply a Forge API token either via `--forge-token` option or PDK_FORGE_TOKEN environment variable.'
|
35
|
+
exit 1
|
36
|
+
end
|
42
37
|
|
43
|
-
|
38
|
+
Release.prepare_publish_interview(TTY::Prompt.new(help_color: :cyan), opts) unless opts[:force]
|
39
|
+
|
40
|
+
Release.send_analytics("release #{cmd.name}", opts)
|
41
|
+
|
42
|
+
release = PDK::Module::Release.new(nil, opts)
|
43
|
+
|
44
|
+
release.run
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|