pdk 2.4.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +803 -1329
  3. data/LICENSE +201 -201
  4. data/README.md +165 -163
  5. data/exe/pdk +10 -10
  6. data/lib/pdk/analytics/client/google_analytics.rb +143 -143
  7. data/lib/pdk/analytics/client/noop.rb +25 -25
  8. data/lib/pdk/analytics/util.rb +19 -19
  9. data/lib/pdk/analytics.rb +30 -30
  10. data/lib/pdk/answer_file.rb +12 -12
  11. data/lib/pdk/bolt.rb +19 -19
  12. data/lib/pdk/cli/build.rb +82 -82
  13. data/lib/pdk/cli/bundle.rb +48 -48
  14. data/lib/pdk/cli/config/get.rb +26 -26
  15. data/lib/pdk/cli/config.rb +22 -22
  16. data/lib/pdk/cli/console.rb +148 -148
  17. data/lib/pdk/cli/convert.rb +52 -52
  18. data/lib/pdk/cli/env.rb +52 -52
  19. data/lib/pdk/cli/errors.rb +25 -25
  20. data/lib/pdk/cli/exec/command.rb +293 -293
  21. data/lib/pdk/cli/exec/interactive_command.rb +114 -114
  22. data/lib/pdk/cli/exec.rb +84 -84
  23. data/lib/pdk/cli/exec_group.rb +104 -104
  24. data/lib/pdk/cli/get/config.rb +24 -24
  25. data/lib/pdk/cli/get.rb +20 -20
  26. data/lib/pdk/cli/module/build.rb +12 -12
  27. data/lib/pdk/cli/module/generate.rb +47 -47
  28. data/lib/pdk/cli/module.rb +14 -14
  29. data/lib/pdk/cli/new/class.rb +32 -32
  30. data/lib/pdk/cli/new/defined_type.rb +32 -32
  31. data/lib/pdk/cli/new/fact.rb +29 -29
  32. data/lib/pdk/cli/new/function.rb +29 -29
  33. data/lib/pdk/cli/new/module.rb +53 -53
  34. data/lib/pdk/cli/new/provider.rb +29 -29
  35. data/lib/pdk/cli/new/task.rb +34 -34
  36. data/lib/pdk/cli/new/test.rb +52 -52
  37. data/lib/pdk/cli/new/transport.rb +27 -27
  38. data/lib/pdk/cli/new.rb +21 -21
  39. data/lib/pdk/cli/release/prep.rb +39 -39
  40. data/lib/pdk/cli/release/publish.rb +50 -50
  41. data/lib/pdk/cli/release.rb +194 -194
  42. data/lib/pdk/cli/remove/config.rb +80 -80
  43. data/lib/pdk/cli/remove.rb +20 -20
  44. data/lib/pdk/cli/set/config.rb +119 -119
  45. data/lib/pdk/cli/set.rb +20 -20
  46. data/lib/pdk/cli/test/unit.rb +90 -90
  47. data/lib/pdk/cli/test.rb +11 -11
  48. data/lib/pdk/cli/update.rb +64 -64
  49. data/lib/pdk/cli/util/command_redirector.rb +27 -27
  50. data/lib/pdk/cli/util/interview.rb +72 -72
  51. data/lib/pdk/cli/util/option_normalizer.rb +55 -55
  52. data/lib/pdk/cli/util/option_validator.rb +68 -68
  53. data/lib/pdk/cli/util/spinner.rb +13 -13
  54. data/lib/pdk/cli/util/update_manager_printer.rb +82 -82
  55. data/lib/pdk/cli/util.rb +305 -305
  56. data/lib/pdk/cli/validate.rb +116 -116
  57. data/lib/pdk/cli.rb +175 -175
  58. data/lib/pdk/config/analytics_schema.json +26 -26
  59. data/lib/pdk/config/errors.rb +5 -5
  60. data/lib/pdk/config/ini_file.rb +183 -183
  61. data/lib/pdk/config/ini_file_setting.rb +39 -39
  62. data/lib/pdk/config/json.rb +34 -34
  63. data/lib/pdk/config/json_schema_namespace.rb +142 -142
  64. data/lib/pdk/config/json_schema_setting.rb +53 -53
  65. data/lib/pdk/config/json_with_schema.rb +49 -49
  66. data/lib/pdk/config/namespace.rb +354 -354
  67. data/lib/pdk/config/setting.rb +135 -135
  68. data/lib/pdk/config/validator.rb +31 -31
  69. data/lib/pdk/config/yaml.rb +46 -46
  70. data/lib/pdk/config/yaml_with_schema.rb +59 -59
  71. data/lib/pdk/config.rb +390 -390
  72. data/lib/pdk/context/control_repo.rb +60 -60
  73. data/lib/pdk/context/module.rb +28 -28
  74. data/lib/pdk/context/none.rb +22 -22
  75. data/lib/pdk/context.rb +99 -99
  76. data/lib/pdk/control_repo.rb +90 -90
  77. data/lib/pdk/generate/defined_type.rb +43 -43
  78. data/lib/pdk/generate/fact.rb +25 -25
  79. data/lib/pdk/generate/function.rb +48 -48
  80. data/lib/pdk/generate/module.rb +352 -352
  81. data/lib/pdk/generate/provider.rb +28 -28
  82. data/lib/pdk/generate/puppet_class.rb +43 -43
  83. data/lib/pdk/generate/puppet_object.rb +232 -232
  84. data/lib/pdk/generate/task.rb +68 -68
  85. data/lib/pdk/generate/transport.rb +33 -33
  86. data/lib/pdk/generate.rb +24 -24
  87. data/lib/pdk/i18n.rb +4 -4
  88. data/lib/pdk/logger.rb +45 -45
  89. data/lib/pdk/module/build.rb +322 -322
  90. data/lib/pdk/module/convert.rb +296 -296
  91. data/lib/pdk/module/metadata.rb +202 -202
  92. data/lib/pdk/module/release.rb +260 -260
  93. data/lib/pdk/module/update.rb +131 -131
  94. data/lib/pdk/module/update_manager.rb +227 -227
  95. data/lib/pdk/module.rb +30 -30
  96. data/lib/pdk/report/event.rb +370 -370
  97. data/lib/pdk/report.rb +121 -121
  98. data/lib/pdk/template/fetcher/git.rb +85 -85
  99. data/lib/pdk/template/fetcher/local.rb +28 -28
  100. data/lib/pdk/template/fetcher.rb +98 -98
  101. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -116
  102. data/lib/pdk/template/renderer/v1/renderer.rb +132 -132
  103. data/lib/pdk/template/renderer/v1/template_file.rb +102 -102
  104. data/lib/pdk/template/renderer/v1.rb +25 -25
  105. data/lib/pdk/template/renderer.rb +96 -96
  106. data/lib/pdk/template/template_dir.rb +67 -67
  107. data/lib/pdk/template.rb +59 -59
  108. data/lib/pdk/tests/unit.rb +252 -252
  109. data/lib/pdk/util/bundler.rb +259 -259
  110. data/lib/pdk/util/changelog_generator.rb +137 -137
  111. data/lib/pdk/util/env.rb +47 -47
  112. data/lib/pdk/util/filesystem.rb +138 -138
  113. data/lib/pdk/util/git.rb +179 -179
  114. data/lib/pdk/util/json_finder.rb +85 -85
  115. data/lib/pdk/util/puppet_strings.rb +125 -125
  116. data/lib/pdk/util/puppet_version.rb +266 -266
  117. data/lib/pdk/util/ruby_version.rb +179 -179
  118. data/lib/pdk/util/template_uri.rb +295 -295
  119. data/lib/pdk/util/vendored_file.rb +93 -93
  120. data/lib/pdk/util/version.rb +43 -43
  121. data/lib/pdk/util/windows/api_types.rb +82 -82
  122. data/lib/pdk/util/windows/file.rb +36 -36
  123. data/lib/pdk/util/windows/process.rb +79 -79
  124. data/lib/pdk/util/windows/string.rb +16 -16
  125. data/lib/pdk/util/windows.rb +15 -15
  126. data/lib/pdk/util.rb +278 -278
  127. data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -23
  128. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -98
  129. data/lib/pdk/validate/external_command_validator.rb +208 -208
  130. data/lib/pdk/validate/internal_ruby_validator.rb +100 -100
  131. data/lib/pdk/validate/invokable_validator.rb +228 -228
  132. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -86
  133. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -78
  134. data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -20
  135. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -133
  136. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -66
  137. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -137
  138. data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -21
  139. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -80
  140. data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -19
  141. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -88
  142. data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -50
  143. data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -20
  144. data/lib/pdk/validate/validator.rb +118 -118
  145. data/lib/pdk/validate/validator_group.rb +104 -104
  146. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -95
  147. data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -19
  148. data/lib/pdk/validate.rb +94 -94
  149. data/lib/pdk/version.rb +4 -4
  150. data/lib/pdk.rb +76 -76
  151. data/locales/config.yaml +21 -21
  152. data/locales/pdk.pot +2111 -2094
  153. metadata +3 -3
@@ -1,34 +1,34 @@
1
- module PDK::CLI
2
- @new_task_cmd = @new_cmd.define_command do
3
- name 'task'
4
- usage _('task [options] <name>')
5
- summary _('Create a new task named <name> using given options')
6
-
7
- option nil, :description, _('A short description of the purpose of the task'), argument: :required
8
-
9
- run do |opts, args, _cmd|
10
- require 'pdk/generate/task'
11
-
12
- PDK::CLI::Util.ensure_in_module!(
13
- message: _('Tasks can only be created from inside a valid module directory.'),
14
- log_level: :info,
15
- )
16
-
17
- task_name = args[0]
18
-
19
- if task_name.nil? || task_name.empty?
20
- puts command.help
21
- exit 1
22
- end
23
-
24
- unless Util::OptionValidator.valid_task_name?(task_name)
25
- raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid task name") % { name: task_name }
26
- end
27
-
28
- PDK::CLI::Util.analytics_screen_view('new_task', opts)
29
-
30
- updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
31
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
32
- end
33
- end
34
- end
1
+ module PDK::CLI
2
+ @new_task_cmd = @new_cmd.define_command do
3
+ name 'task'
4
+ usage _('task [options] <name>')
5
+ summary _('Create a new task named <name> using given options')
6
+
7
+ option nil, :description, _('A short description of the purpose of the task'), argument: :required
8
+
9
+ run do |opts, args, _cmd|
10
+ require 'pdk/generate/task'
11
+
12
+ PDK::CLI::Util.ensure_in_module!(
13
+ message: _('Tasks can only be created from inside a valid module directory.'),
14
+ log_level: :info,
15
+ )
16
+
17
+ task_name = args[0]
18
+
19
+ if task_name.nil? || task_name.empty?
20
+ puts command.help
21
+ exit 1
22
+ end
23
+
24
+ unless Util::OptionValidator.valid_task_name?(task_name)
25
+ raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid task name") % { name: task_name }
26
+ end
27
+
28
+ PDK::CLI::Util.analytics_screen_view('new_task', opts)
29
+
30
+ updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
31
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
32
+ end
33
+ end
34
+ end
@@ -1,52 +1,52 @@
1
- module PDK::CLI
2
- @new_define_cmd = @new_cmd.define_command do
3
- name 'test'
4
- usage _('test [options] <name>')
5
- summary _('Create a new test for the object named <name>')
6
- flag :u, :unit, _('Create a new unit test.')
7
- PDK::CLI.puppet_version_options(self)
8
- PDK::CLI.puppet_dev_option(self)
9
-
10
- run do |opts, args, _cmd|
11
- require 'pdk/util/puppet_strings'
12
- require 'pdk/util/bundler'
13
-
14
- PDK::CLI::Util.validate_puppet_version_opts(opts)
15
- PDK::CLI::Util.ensure_in_module!(
16
- message: _('Tests can only be created from inside a valid module directory.'),
17
- log_level: :info,
18
- )
19
-
20
- object_name = args[0]
21
-
22
- if object_name.nil? || object_name.empty?
23
- puts command.help
24
- exit 1
25
- end
26
-
27
- unless opts[:unit]
28
- # At a future time, we'll replace this conditional with an interactive
29
- # question to choose the test type.
30
- PDK.logger.info _('Test type not specified, assuming unit.')
31
- opts[:unit] = true
32
- end
33
-
34
- puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
35
- PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
36
- PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
37
-
38
- begin
39
- generator, obj = PDK::Util::PuppetStrings.find_object(object_name)
40
-
41
- PDK::CLI::Util.analytics_screen_view('new_test', opts)
42
-
43
- updates = generator.new(PDK.context, obj['name'], opts.merge(spec_only: true)).run
44
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
45
- rescue PDK::Util::PuppetStrings::NoObjectError
46
- raise PDK::CLI::ExitWithError, _('Unable to find anything called "%{object}" to generate unit tests for.') % { object: object_name }
47
- rescue PDK::Util::PuppetStrings::NoGeneratorError => e
48
- raise PDK::CLI::ExitWithError, _('PDK does not support generating unit tests for "%{object_type}" objects.') % { object_type: e.message }
49
- end
50
- end
51
- end
52
- end
1
+ module PDK::CLI
2
+ @new_define_cmd = @new_cmd.define_command do
3
+ name 'test'
4
+ usage _('test [options] <name>')
5
+ summary _('Create a new test for the object named <name>')
6
+ flag :u, :unit, _('Create a new unit test.')
7
+ PDK::CLI.puppet_version_options(self)
8
+ PDK::CLI.puppet_dev_option(self)
9
+
10
+ run do |opts, args, _cmd|
11
+ require 'pdk/util/puppet_strings'
12
+ require 'pdk/util/bundler'
13
+
14
+ PDK::CLI::Util.validate_puppet_version_opts(opts)
15
+ PDK::CLI::Util.ensure_in_module!(
16
+ message: _('Tests can only be created from inside a valid module directory.'),
17
+ log_level: :info,
18
+ )
19
+
20
+ object_name = args[0]
21
+
22
+ if object_name.nil? || object_name.empty?
23
+ puts command.help
24
+ exit 1
25
+ end
26
+
27
+ unless opts[:unit]
28
+ # At a future time, we'll replace this conditional with an interactive
29
+ # question to choose the test type.
30
+ PDK.logger.info _('Test type not specified, assuming unit.')
31
+ opts[:unit] = true
32
+ end
33
+
34
+ puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
35
+ PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
36
+ PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
37
+
38
+ begin
39
+ generator, obj = PDK::Util::PuppetStrings.find_object(object_name)
40
+
41
+ PDK::CLI::Util.analytics_screen_view('new_test', opts)
42
+
43
+ updates = generator.new(PDK.context, obj['name'], opts.merge(spec_only: true)).run
44
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
45
+ rescue PDK::Util::PuppetStrings::NoObjectError
46
+ raise PDK::CLI::ExitWithError, _('Unable to find anything called "%{object}" to generate unit tests for.') % { object: object_name }
47
+ rescue PDK::Util::PuppetStrings::NoGeneratorError => e
48
+ raise PDK::CLI::ExitWithError, _('PDK does not support generating unit tests for "%{object_type}" objects.') % { object_type: e.message }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,27 +1,27 @@
1
- module PDK::CLI
2
- @new_transport_cmd = @new_cmd.define_command do
3
- name 'transport'
4
- usage _('transport [options] <name>')
5
- summary _('[experimental] Create a new ruby transport named <name> using given options')
6
-
7
- run do |opts, args, _cmd|
8
- PDK::CLI::Util.ensure_in_module!
9
-
10
- transport_name = args[0]
11
-
12
- if transport_name.nil? || transport_name.empty?
13
- puts command.help
14
- exit 1
15
- end
16
-
17
- unless Util::OptionValidator.valid_transport_name?(transport_name)
18
- raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid transport name") % { name: transport_name }
19
- end
20
-
21
- require 'pdk/generate/transport'
22
-
23
- updates = PDK::Generate::Transport.new(PDK.context, transport_name, opts).run
24
- PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
25
- end
26
- end
27
- end
1
+ module PDK::CLI
2
+ @new_transport_cmd = @new_cmd.define_command do
3
+ name 'transport'
4
+ usage _('transport [options] <name>')
5
+ summary _('[experimental] Create a new ruby transport named <name> using given options')
6
+
7
+ run do |opts, args, _cmd|
8
+ PDK::CLI::Util.ensure_in_module!
9
+
10
+ transport_name = args[0]
11
+
12
+ if transport_name.nil? || transport_name.empty?
13
+ puts command.help
14
+ exit 1
15
+ end
16
+
17
+ unless Util::OptionValidator.valid_transport_name?(transport_name)
18
+ raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid transport name") % { name: transport_name }
19
+ end
20
+
21
+ require 'pdk/generate/transport'
22
+
23
+ updates = PDK::Generate::Transport.new(PDK.context, transport_name, opts).run
24
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
25
+ end
26
+ end
27
+ end
data/lib/pdk/cli/new.rb CHANGED
@@ -1,21 +1,21 @@
1
- module PDK::CLI
2
- @new_cmd = @base_cmd.define_command do
3
- name 'new'
4
- usage _('new <thing> [options]')
5
- summary _('create a new module, etc.')
6
- description _('Creates a new <thing> using relevant options.')
7
- default_subcommand 'help'
8
- end
9
-
10
- @new_cmd.add_command Cri::Command.new_basic_help
11
- end
12
-
13
- require 'pdk/cli/new/class'
14
- require 'pdk/cli/new/defined_type'
15
- require 'pdk/cli/new/module'
16
- require 'pdk/cli/new/provider'
17
- require 'pdk/cli/new/task'
18
- require 'pdk/cli/new/test'
19
- require 'pdk/cli/new/transport'
20
- require 'pdk/cli/new/fact'
21
- require 'pdk/cli/new/function'
1
+ module PDK::CLI
2
+ @new_cmd = @base_cmd.define_command do
3
+ name 'new'
4
+ usage _('new <thing> [options]')
5
+ summary _('create a new module, etc.')
6
+ description _('Creates a new <thing> using relevant options.')
7
+ default_subcommand 'help'
8
+ end
9
+
10
+ @new_cmd.add_command Cri::Command.new_basic_help
11
+ end
12
+
13
+ require 'pdk/cli/new/class'
14
+ require 'pdk/cli/new/defined_type'
15
+ require 'pdk/cli/new/module'
16
+ require 'pdk/cli/new/provider'
17
+ require 'pdk/cli/new/task'
18
+ require 'pdk/cli/new/test'
19
+ require 'pdk/cli/new/transport'
20
+ require 'pdk/cli/new/fact'
21
+ require 'pdk/cli/new/function'
@@ -1,39 +1,39 @@
1
- require 'pdk/cli/release'
2
-
3
- module PDK::CLI
4
- @release_prep_cmd = @release_cmd.define_command do
5
- name 'prep'
6
- usage _('prep [options]')
7
- summary _('(Experimental) Performs all the pre-release checks to ensure module is ready to be released')
8
-
9
- flag nil, :force, _('Prepare the module automatically, with no prompts.')
10
- flag nil, :'skip-validation', _('Skips the module validation check.')
11
- flag nil, :'skip-changelog', _('Skips the automatic changelog generation.')
12
- flag nil, :'skip-dependency', _('Skips the module dependency check.')
13
- flag nil, :'skip-documentation', _('Skips the documentation update.')
14
-
15
- 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.'),
16
- argument: :required
17
-
18
- run do |opts, _args, cmd|
19
- # Make sure build is being run in a valid module directory with a metadata.json
20
- PDK::CLI::Util.ensure_in_module!(
21
- message: _("`pdk release #{cmd.name}` can only be run from inside a valid module with a metadata.json."),
22
- log_level: :info,
23
- )
24
-
25
- opts[:'skip-build'] = true
26
- opts[:'skip-publish'] = true
27
-
28
- Release.prepare_interview(opts) unless opts[:force]
29
-
30
- Release.send_analytics("release #{cmd.name}", opts)
31
-
32
- release = PDK::Module::Release.new(nil, opts)
33
-
34
- Release.module_compatibility_checks!(release, opts)
35
-
36
- release.run
37
- end
38
- end
39
- end
1
+ require 'pdk/cli/release'
2
+
3
+ module PDK::CLI
4
+ @release_prep_cmd = @release_cmd.define_command do
5
+ name 'prep'
6
+ usage _('prep [options]')
7
+ summary _('(Experimental) Performs all the pre-release checks to ensure module is ready to be released')
8
+
9
+ flag nil, :force, _('Prepare the module automatically, with no prompts.')
10
+ flag nil, :'skip-validation', _('Skips the module validation check.')
11
+ flag nil, :'skip-changelog', _('Skips the automatic changelog generation.')
12
+ flag nil, :'skip-dependency', _('Skips the module dependency check.')
13
+ flag nil, :'skip-documentation', _('Skips the documentation update.')
14
+
15
+ 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.'),
16
+ argument: :required
17
+
18
+ run do |opts, _args, cmd|
19
+ # Make sure build is being run in a valid module directory with a metadata.json
20
+ PDK::CLI::Util.ensure_in_module!(
21
+ message: _("`pdk release #{cmd.name}` can only be run from inside a valid module with a metadata.json."),
22
+ log_level: :info,
23
+ )
24
+
25
+ opts[:'skip-build'] = true
26
+ opts[:'skip-publish'] = true
27
+
28
+ Release.prepare_interview(opts) unless opts[:force]
29
+
30
+ Release.send_analytics("release #{cmd.name}", opts)
31
+
32
+ release = PDK::Module::Release.new(nil, opts)
33
+
34
+ Release.module_compatibility_checks!(release, opts)
35
+
36
+ release.run
37
+ end
38
+ end
39
+ end
@@ -1,50 +1,50 @@
1
- require 'pdk/cli/release'
2
-
3
- module PDK::CLI
4
- @release_publish_cmd = @release_cmd.define_command do
5
- name 'publish'
6
- usage _('publish [options] <tarball>')
7
- summary _('(Experimental) Publishes the module <tarball> to the Forge.')
8
-
9
- flag nil, :force, _('Publish the module automatically, with no prompts.')
10
-
11
- option nil, :'forge-upload-url', _('Set forge upload url path.'),
12
- argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
13
-
14
- option nil, :'forge-token', _('Set Forge API token (you may also set via environment variable PDK_FORGE_TOKEN)'), argument: :required
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 _(
34
- 'You must supply a Forge API token either via `--forge-token` option ' \
35
- 'or PDK_FORGE_TOKEN environment variable.',
36
- )
37
-
38
- exit 1
39
- end
40
-
41
- Release.prepare_publish_interview(TTY::Prompt.new(help_color: :cyan), opts) unless opts[:force]
42
-
43
- Release.send_analytics("release #{cmd.name}", opts)
44
-
45
- release = PDK::Module::Release.new(nil, opts)
46
-
47
- release.run
48
- end
49
- end
50
- end
1
+ require 'pdk/cli/release'
2
+
3
+ module PDK::CLI
4
+ @release_publish_cmd = @release_cmd.define_command do
5
+ name 'publish'
6
+ usage _('publish [options] <tarball>')
7
+ summary _('(Experimental) Publishes the module <tarball> to the Forge.')
8
+
9
+ flag nil, :force, _('Publish the module automatically, with no prompts.')
10
+
11
+ option nil, :'forge-upload-url', _('Set forge upload url path.'),
12
+ argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
13
+
14
+ option nil, :'forge-token', _('Set Forge API token (you may also set via environment variable PDK_FORGE_TOKEN)'), argument: :required
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 _(
34
+ 'You must supply a Forge API token either via `--forge-token` option ' \
35
+ 'or PDK_FORGE_TOKEN environment variable.',
36
+ )
37
+
38
+ exit 1
39
+ end
40
+
41
+ Release.prepare_publish_interview(TTY::Prompt.new(help_color: :cyan), opts) unless opts[:force]
42
+
43
+ Release.send_analytics("release #{cmd.name}", opts)
44
+
45
+ release = PDK::Module::Release.new(nil, opts)
46
+
47
+ release.run
48
+ end
49
+ end
50
+ end