pdk 1.14.1 → 1.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +155 -2
  3. data/lib/pdk.rb +28 -19
  4. data/lib/pdk/answer_file.rb +2 -95
  5. data/lib/pdk/bolt.rb +19 -0
  6. data/lib/pdk/cli.rb +4 -5
  7. data/lib/pdk/cli/bundle.rb +5 -1
  8. data/lib/pdk/cli/config.rb +3 -1
  9. data/lib/pdk/cli/config/get.rb +3 -1
  10. data/lib/pdk/cli/console.rb +1 -1
  11. data/lib/pdk/cli/convert.rb +16 -10
  12. data/lib/pdk/cli/exec.rb +2 -1
  13. data/lib/pdk/cli/exec/command.rb +45 -4
  14. data/lib/pdk/cli/exec_group.rb +78 -43
  15. data/lib/pdk/cli/get.rb +20 -0
  16. data/lib/pdk/cli/get/config.rb +24 -0
  17. data/lib/pdk/cli/module/build.rb +1 -1
  18. data/lib/pdk/cli/module/generate.rb +1 -1
  19. data/lib/pdk/cli/new/class.rb +2 -2
  20. data/lib/pdk/cli/new/defined_type.rb +2 -2
  21. data/lib/pdk/cli/new/provider.rb +2 -2
  22. data/lib/pdk/cli/new/task.rb +2 -2
  23. data/lib/pdk/cli/new/test.rb +2 -2
  24. data/lib/pdk/cli/new/transport.rb +2 -2
  25. data/lib/pdk/cli/release.rb +192 -0
  26. data/lib/pdk/cli/release/prep.rb +39 -0
  27. data/lib/pdk/cli/release/publish.rb +40 -0
  28. data/lib/pdk/cli/remove.rb +20 -0
  29. data/lib/pdk/cli/remove/config.rb +80 -0
  30. data/lib/pdk/cli/set.rb +20 -0
  31. data/lib/pdk/cli/set/config.rb +119 -0
  32. data/lib/pdk/cli/update.rb +18 -8
  33. data/lib/pdk/cli/util.rb +7 -3
  34. data/lib/pdk/cli/util/update_manager_printer.rb +82 -0
  35. data/lib/pdk/cli/validate.rb +26 -44
  36. data/lib/pdk/config.rb +265 -8
  37. data/lib/pdk/config/ini_file.rb +183 -0
  38. data/lib/pdk/config/ini_file_setting.rb +39 -0
  39. data/lib/pdk/config/namespace.rb +26 -6
  40. data/lib/pdk/config/setting.rb +3 -2
  41. data/lib/pdk/context.rb +99 -0
  42. data/lib/pdk/context/control_repo.rb +60 -0
  43. data/lib/pdk/context/module.rb +28 -0
  44. data/lib/pdk/context/none.rb +22 -0
  45. data/lib/pdk/control_repo.rb +90 -0
  46. data/lib/pdk/generate.rb +1 -0
  47. data/lib/pdk/generate/defined_type.rb +25 -32
  48. data/lib/pdk/generate/module.rb +42 -35
  49. data/lib/pdk/generate/provider.rb +16 -65
  50. data/lib/pdk/generate/puppet_class.rb +25 -31
  51. data/lib/pdk/generate/puppet_object.rb +84 -189
  52. data/lib/pdk/generate/resource_api_object.rb +55 -0
  53. data/lib/pdk/generate/task.rb +28 -46
  54. data/lib/pdk/generate/transport.rb +21 -75
  55. data/lib/pdk/module.rb +1 -1
  56. data/lib/pdk/module/build.rb +38 -25
  57. data/lib/pdk/module/convert.rb +61 -42
  58. data/lib/pdk/module/metadata.rb +1 -3
  59. data/lib/pdk/module/release.rb +254 -0
  60. data/lib/pdk/module/update.rb +24 -16
  61. data/lib/pdk/module/update_manager.rb +8 -1
  62. data/lib/pdk/report.rb +18 -12
  63. data/lib/pdk/report/event.rb +6 -3
  64. data/lib/pdk/template.rb +59 -0
  65. data/lib/pdk/template/fetcher.rb +98 -0
  66. data/lib/pdk/template/fetcher/git.rb +85 -0
  67. data/lib/pdk/template/fetcher/local.rb +28 -0
  68. data/lib/pdk/template/renderer.rb +96 -0
  69. data/lib/pdk/template/renderer/v1.rb +25 -0
  70. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -0
  71. data/lib/pdk/template/renderer/v1/renderer.rb +132 -0
  72. data/lib/pdk/template/renderer/v1/template_file.rb +102 -0
  73. data/lib/pdk/template/template_dir.rb +67 -0
  74. data/lib/pdk/tests/unit.rb +5 -0
  75. data/lib/pdk/util.rb +55 -45
  76. data/lib/pdk/util/bundler.rb +9 -9
  77. data/lib/pdk/util/changelog_generator.rb +120 -0
  78. data/lib/pdk/util/env.rb +28 -11
  79. data/lib/pdk/util/filesystem.rb +62 -2
  80. data/lib/pdk/util/git.rb +60 -8
  81. data/lib/pdk/util/json_finder.rb +84 -0
  82. data/lib/pdk/util/puppet_strings.rb +3 -3
  83. data/lib/pdk/util/puppet_version.rb +4 -5
  84. data/lib/pdk/util/ruby_version.rb +9 -6
  85. data/lib/pdk/util/template_uri.rb +60 -48
  86. data/lib/pdk/util/version.rb +4 -4
  87. data/lib/pdk/validate.rb +79 -25
  88. data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -0
  89. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -0
  90. data/lib/pdk/validate/external_command_validator.rb +208 -0
  91. data/lib/pdk/validate/internal_ruby_validator.rb +100 -0
  92. data/lib/pdk/validate/invokable_validator.rb +215 -0
  93. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -0
  94. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -0
  95. data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -0
  96. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -0
  97. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -0
  98. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -0
  99. data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -0
  100. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -0
  101. data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -0
  102. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -0
  103. data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -0
  104. data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -0
  105. data/lib/pdk/validate/validator.rb +118 -0
  106. data/lib/pdk/validate/validator_group.rb +104 -0
  107. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -0
  108. data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -0
  109. data/lib/pdk/version.rb +1 -1
  110. data/locales/pdk.pot +755 -319
  111. metadata +66 -24
  112. data/lib/pdk/module/templatedir.rb +0 -391
  113. data/lib/pdk/template_file.rb +0 -96
  114. data/lib/pdk/validate/base_validator.rb +0 -215
  115. data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -82
  116. data/lib/pdk/validate/metadata/metadata_syntax.rb +0 -111
  117. data/lib/pdk/validate/metadata_validator.rb +0 -26
  118. data/lib/pdk/validate/puppet/puppet_epp.rb +0 -137
  119. data/lib/pdk/validate/puppet/puppet_lint.rb +0 -64
  120. data/lib/pdk/validate/puppet/puppet_syntax.rb +0 -137
  121. data/lib/pdk/validate/puppet_validator.rb +0 -26
  122. data/lib/pdk/validate/ruby/rubocop.rb +0 -72
  123. data/lib/pdk/validate/ruby_validator.rb +0 -26
  124. data/lib/pdk/validate/tasks/metadata_lint.rb +0 -130
  125. data/lib/pdk/validate/tasks/name.rb +0 -90
  126. data/lib/pdk/validate/tasks_validator.rb +0 -29
  127. data/lib/pdk/validate/yaml/syntax.rb +0 -125
  128. data/lib/pdk/validate/yaml_validator.rb +0 -28
@@ -0,0 +1,20 @@
1
+ module PDK::CLI
2
+ @get_cmd = @base_cmd.define_command do
3
+ name 'get'
4
+ usage _('get [subcommand] [options]')
5
+ summary _('Retrieve information about the PDK or current project.')
6
+ default_subcommand 'help'
7
+
8
+ run do |_opts, args, _cmd|
9
+ if args == ['help']
10
+ PDK::CLI.run(%w[get --help])
11
+ exit 0
12
+ end
13
+
14
+ PDK::CLI.run(%w[get help]) if args.empty?
15
+ end
16
+ end
17
+ @get_cmd.add_command Cri::Command.new_basic_help
18
+ end
19
+
20
+ require 'pdk/cli/get/config'
@@ -0,0 +1,24 @@
1
+ module PDK::CLI
2
+ @get_config_cmd = @get_cmd.define_command do
3
+ name 'config'
4
+ usage _('config [name]')
5
+ summary _('Retrieve the configuration for <name>. If not specified, retrieve all configuration settings')
6
+
7
+ run do |_opts, args, _cmd|
8
+ item_name = args[0]
9
+ resolved_config = PDK.config.resolve(item_name)
10
+ # If the user wanted to know a setting but it doesn't exist, raise an error
11
+ if resolved_config.empty? && !item_name.nil?
12
+ PDK.logger.error(_("Configuration item '%{name}' does not exist") % { name: item_name })
13
+ exit 1
14
+ end
15
+ # If the user requested a setting and it's the only one resolved, then just output the value
16
+ if resolved_config.count == 1 && resolved_config.keys[0] == item_name
17
+ puts _('%{value}') % { value: resolved_config.values[0] }
18
+ exit 0
19
+ end
20
+ # Otherwise just output everything
21
+ resolved_config.keys.sort.each { |key| puts _('%{name}=%{value}') % { name: key, value: resolved_config[key] } }
22
+ end
23
+ end
24
+ end
@@ -5,7 +5,7 @@ module PDK::CLI
5
5
  summary _('This command is now \'pdk build\'.')
6
6
 
7
7
  run do |_opts, _args, _cmd|
8
- PDK.logger.warn(_('Modules are built using the pdk build command.'))
8
+ PDK.logger.warn(_("Modules are built using the 'pdk build' command."))
9
9
  exit 1
10
10
  end
11
11
  end
@@ -21,7 +21,7 @@ module PDK::CLI
21
21
 
22
22
  PDK::CLI::Util.validate_template_opts(opts)
23
23
 
24
- PDK.logger.info(_('New modules are created using the pdk new module command.'))
24
+ PDK.logger.info(_("New modules are created using the 'pdk new module' command."))
25
25
  prompt = TTY::Prompt.new(help_color: :cyan)
26
26
  redirect = PDK::CLI::Util::CommandRedirector.new(prompt)
27
27
  redirect.target_command('pdk new module')
@@ -13,7 +13,6 @@ module PDK::CLI
13
13
  )
14
14
 
15
15
  class_name = args[0]
16
- module_dir = Dir.pwd
17
16
 
18
17
  if class_name.nil? || class_name.empty?
19
18
  puts command.help
@@ -26,7 +25,8 @@ module PDK::CLI
26
25
 
27
26
  PDK::CLI::Util.analytics_screen_view('new_class', opts)
28
27
 
29
- PDK::Generate::PuppetClass.new(module_dir, class_name, opts).run
28
+ updates = PDK::Generate::PuppetClass.new(PDK.context, class_name, opts).run
29
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
30
30
  end
31
31
  end
32
32
  end
@@ -11,7 +11,6 @@ module PDK::CLI
11
11
  )
12
12
 
13
13
  defined_type_name = args[0]
14
- module_dir = Dir.pwd
15
14
 
16
15
  if defined_type_name.nil? || defined_type_name.empty?
17
16
  puts command.help
@@ -26,7 +25,8 @@ module PDK::CLI
26
25
 
27
26
  require 'pdk/generate/defined_type'
28
27
 
29
- PDK::Generate::DefinedType.new(module_dir, defined_type_name, opts).run
28
+ updates = PDK::Generate::DefinedType.new(PDK.context, defined_type_name, opts).run
29
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
30
30
  end
31
31
  end
32
32
  end
@@ -8,7 +8,6 @@ module PDK::CLI
8
8
  PDK::CLI::Util.ensure_in_module!
9
9
 
10
10
  provider_name = args[0]
11
- module_dir = Dir.pwd
12
11
 
13
12
  if provider_name.nil? || provider_name.empty?
14
13
  puts command.help
@@ -23,7 +22,8 @@ module PDK::CLI
23
22
 
24
23
  require 'pdk/generate/provider'
25
24
 
26
- PDK::Generate::Provider.new(module_dir, provider_name, opts).run
25
+ updates = PDK::Generate::Provider.new(PDK.context, provider_name, opts).run
26
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
27
27
  end
28
28
  end
29
29
  end
@@ -15,7 +15,6 @@ module PDK::CLI
15
15
  )
16
16
 
17
17
  task_name = args[0]
18
- module_dir = Dir.pwd
19
18
 
20
19
  if task_name.nil? || task_name.empty?
21
20
  puts command.help
@@ -28,7 +27,8 @@ module PDK::CLI
28
27
 
29
28
  PDK::CLI::Util.analytics_screen_view('new_task', opts)
30
29
 
31
- PDK::Generate::Task.new(module_dir, task_name, opts).run
30
+ updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
31
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
32
32
  end
33
33
  end
34
34
  end
@@ -18,7 +18,6 @@ module PDK::CLI
18
18
  )
19
19
 
20
20
  object_name = args[0]
21
- module_dir = Dir.pwd
22
21
 
23
22
  if object_name.nil? || object_name.empty?
24
23
  puts command.help
@@ -41,7 +40,8 @@ module PDK::CLI
41
40
 
42
41
  PDK::CLI::Util.analytics_screen_view('new_test', opts)
43
42
 
44
- generator.new(module_dir, obj['name'], opts.merge(spec_only: true)).run
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
45
  rescue PDK::Util::PuppetStrings::NoObjectError
46
46
  raise PDK::CLI::ExitWithError, _('Unable to find anything called "%{object}" to generate unit tests for.') % { object: object_name }
47
47
  rescue PDK::Util::PuppetStrings::NoGeneratorError => e
@@ -8,7 +8,6 @@ module PDK::CLI
8
8
  PDK::CLI::Util.ensure_in_module!
9
9
 
10
10
  transport_name = args[0]
11
- module_dir = Dir.pwd
12
11
 
13
12
  if transport_name.nil? || transport_name.empty?
14
13
  puts command.help
@@ -21,7 +20,8 @@ module PDK::CLI
21
20
 
22
21
  require 'pdk/generate/transport'
23
22
 
24
- PDK::Generate::Transport.new(module_dir, transport_name, opts).run
23
+ updates = PDK::Generate::Transport.new(PDK.context, transport_name, opts).run
24
+ PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,192 @@
1
+ require 'pdk/cli/util'
2
+ require 'pdk/validate'
3
+ require 'pdk/util/bundler'
4
+ require 'pdk/cli/util/interview'
5
+ require 'pdk/util/changelog_generator'
6
+ require 'pdk/module/build'
7
+
8
+ module PDK::CLI
9
+ @release_cmd = @base_cmd.define_command do
10
+ name 'release'
11
+ usage _('release [options]')
12
+ summary _('(Experimental) Release a module to the Puppet Forge.')
13
+
14
+ flag nil, :force, _('Release the module automatically, with no prompts.')
15
+ flag nil, :'skip-validation', _('Skips the module validation check.')
16
+ flag nil, :'skip-changelog', _('Skips the automatic changelog generation.')
17
+ flag nil, :'skip-dependency', _('Skips the module dependency check.')
18
+ flag nil, :'skip-documentation', _('Skips the documentation update.')
19
+ flag nil, :'skip-build', _('Skips module build.')
20
+ flag nil, :'skip-publish', _('Skips publishing the module to the forge.')
21
+
22
+ option nil, :'forge-upload-url', _('Set forge upload url path.'),
23
+ argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
24
+
25
+ option nil, :'forge-token', _('Set Forge API token.'), argument: :required, default: nil
26
+
27
+ 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.'),
28
+ argument: :required
29
+
30
+ option nil, :file, _('Path to the built module to push to the Forge. This option can only be used when --skip-build is also used. Defaults to pkg/<module version>.tar.gz'),
31
+ argument: :required
32
+
33
+ run do |opts, _args, _cmd|
34
+ # Make sure build is being run in a valid module directory with a metadata.json
35
+ PDK::CLI::Util.ensure_in_module!(
36
+ message: _('`pdk release` can only be run from inside a valid module with a metadata.json.'),
37
+ log_level: :info,
38
+ )
39
+
40
+ Release.prepare_interview(opts) unless opts[:force]
41
+
42
+ Release.send_analytics('release', opts)
43
+
44
+ release = PDK::Module::Release.new(nil, opts)
45
+
46
+ Release.module_compatibility_checks!(release, opts)
47
+
48
+ release.run
49
+ end
50
+ end
51
+
52
+ module Release
53
+ # Checks whether the module is compatible with PDK release process
54
+ # @param release PDK::Module::Release Object representing the release
55
+ # @param opts Options Hash from Cri
56
+ def self.module_compatibility_checks!(release, opts)
57
+ unless release.module_metadata.forge_ready?
58
+ if opts[:force]
59
+ PDK.logger.warn _(
60
+ 'This module is missing the following fields in the metadata.json: %{fields}. ' \
61
+ 'These missing fields may affect the visibility of the module on the Forge.',
62
+ ) % {
63
+ fields: release.module_metadata.missing_fields.join(', '),
64
+ }
65
+ else
66
+ release.module_metadata.interview_for_forge!
67
+ release.write_module_metadata!
68
+ end
69
+ end
70
+
71
+ unless release.pdk_compatible? # rubocop:disable Style/GuardClause Nope!
72
+ if opts[:force]
73
+ PDK.logger.warn _('This module is not compatible with PDK, so PDK can not validate or test this build.')
74
+ else
75
+ PDK.logger.info _('This module is not compatible with PDK, so PDK can not validate or test this build. ' \
76
+ 'Unvalidated modules may have errors when uploading to the Forge. ' \
77
+ 'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.')
78
+ unless PDK::CLI::Util.prompt_for_yes(_('Continue build without converting?'))
79
+ PDK.logger.info _('Build cancelled; exiting.')
80
+ PDK::Util.exit_process(1)
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ # Send_analytics for the given command and Cri options
87
+ def self.send_analytics(command, opts)
88
+ # Don't pass tokens to analytics
89
+ PDK::CLI::Util.analytics_screen_view(command, opts.reject { |k, _| k == :'forge-token' })
90
+ end
91
+
92
+ def self.prepare_interview(opts)
93
+ questions = []
94
+
95
+ unless opts[:'skip-validation']
96
+ questions << {
97
+ name: 'validation',
98
+ question: _('Do you want to run the module validation ?'),
99
+ type: :yes,
100
+ }
101
+ end
102
+ unless opts[:'skip-changelog']
103
+ questions << {
104
+ name: 'changelog',
105
+ question: _('Do you want to run the automatic changelog generation ?'),
106
+ type: :yes,
107
+ }
108
+ end
109
+ unless opts[:version]
110
+ questions << {
111
+ name: 'setversion',
112
+ question: _('Do you want to set the module version ?'),
113
+ type: :yes,
114
+ }
115
+ end
116
+ unless opts[:'skip-dependency']
117
+ questions << {
118
+ name: 'dependency',
119
+ question: _('Do you want to run the dependency-checker on this module?'),
120
+ type: :yes,
121
+ }
122
+ end
123
+ unless opts[:'skip-documentation']
124
+ questions << {
125
+ name: 'documentation',
126
+ question: _('Do you want to update the documentation for this module?'),
127
+ type: :yes,
128
+ }
129
+ end
130
+ unless opts[:'skip-publish']
131
+ questions << {
132
+ name: 'publish',
133
+ question: _('Do you want to publish the module on the Puppet Forge?'),
134
+ type: :yes,
135
+ }
136
+ end
137
+
138
+ prompt = TTY::Prompt.new(help_color: :cyan)
139
+ interview = PDK::CLI::Util::Interview.new(prompt)
140
+ interview.add_questions(questions)
141
+ answers = interview.run
142
+
143
+ unless answers.nil?
144
+ opts[:'skip-validation'] = !answers['validation']
145
+ opts[:'skip-changelog'] = !answers['changelog']
146
+ opts[:'skip-dependency'] = !answers['dependency']
147
+ opts[:'skip-documentation'] = !answers['documentation']
148
+
149
+ prepare_version_interview(prompt, opts) if answers['setversion']
150
+
151
+ prepare_publish_interview(prompt, opts) if answers['publish']
152
+ end
153
+ answers
154
+ end
155
+
156
+ def self.prepare_version_interview(prompt, opts)
157
+ questions = [
158
+ {
159
+ name: 'version',
160
+ question: _('Please set the module version'),
161
+ help: _('This value is the version that will be used in the changelog generator and building of the module.'),
162
+ required: true,
163
+ validate_pattern: %r{(\*|\d+(\.\d+){0,2}(\.\*)?)$}i,
164
+ validate_message: _('The version format should be in the format x.y.z where x represents the major version, y the minor version and z the build number.'),
165
+ },
166
+ ]
167
+ interview = PDK::CLI::Util::Interview.new(prompt)
168
+ interview.add_questions(questions)
169
+ ver_answer = interview.run
170
+ opts[:version] = ver_answer['version']
171
+ end
172
+
173
+ def self.prepare_publish_interview(prompt, opts)
174
+ return if opts[:'forge-token']
175
+ questions = [
176
+ {
177
+ name: 'apikey',
178
+ question: _('Please set the api key(authorization token) to upload on the Puppet Forge'),
179
+ help: _('This value is used for authentication on the Puppet Forge to upload your module tarball.'),
180
+ required: true,
181
+ },
182
+ ]
183
+ interview = PDK::CLI::Util::Interview.new(prompt)
184
+ interview.add_questions(questions)
185
+ api_answer = interview.run
186
+ opts[:'forge-token'] = api_answer['apikey']
187
+ end
188
+ end
189
+ end
190
+
191
+ require 'pdk/cli/release/prep'
192
+ require 'pdk/cli/release/publish'
@@ -0,0 +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
@@ -0,0 +1,40 @@
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.'), argument: :required, default: nil
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
+
31
+ Release.prepare_publish_interview(TTY::Prompt.new(help_color: :cyan), opts) unless opts[:force]
32
+
33
+ Release.send_analytics("release #{cmd.name}", opts)
34
+
35
+ release = PDK::Module::Release.new(nil, opts)
36
+
37
+ release.run
38
+ end
39
+ end
40
+ end