pdk 2.7.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +2 -48
  4. data/lib/pdk/analytics/client/google_analytics.rb +22 -26
  5. data/lib/pdk/analytics/util.rb +0 -1
  6. data/lib/pdk/analytics.rb +1 -1
  7. data/lib/pdk/bolt.rb +1 -0
  8. data/lib/pdk/cli/build.rb +53 -56
  9. data/lib/pdk/cli/bundle.rb +34 -33
  10. data/lib/pdk/cli/console.rb +136 -134
  11. data/lib/pdk/cli/convert.rb +39 -41
  12. data/lib/pdk/cli/env.rb +49 -47
  13. data/lib/pdk/cli/errors.rb +1 -2
  14. data/lib/pdk/cli/exec/command.rb +23 -29
  15. data/lib/pdk/cli/exec/interactive_command.rb +7 -12
  16. data/lib/pdk/cli/exec.rb +4 -11
  17. data/lib/pdk/cli/exec_group.rb +3 -2
  18. data/lib/pdk/cli/get/config.rb +21 -19
  19. data/lib/pdk/cli/get.rb +15 -13
  20. data/lib/pdk/cli/new/class.rb +22 -22
  21. data/lib/pdk/cli/new/defined_type.rb +22 -22
  22. data/lib/pdk/cli/new/fact.rb +19 -19
  23. data/lib/pdk/cli/new/function.rb +20 -20
  24. data/lib/pdk/cli/new/module.rb +40 -38
  25. data/lib/pdk/cli/new/provider.rb +19 -19
  26. data/lib/pdk/cli/new/task.rb +23 -23
  27. data/lib/pdk/cli/new/test.rb +50 -48
  28. data/lib/pdk/cli/new/transport.rb +18 -18
  29. data/lib/pdk/cli/new.rb +11 -9
  30. data/lib/pdk/cli/release/prep.rb +27 -25
  31. data/lib/pdk/cli/release/publish.rb +39 -37
  32. data/lib/pdk/cli/release.rb +152 -149
  33. data/lib/pdk/cli/remove/config.rb +63 -60
  34. data/lib/pdk/cli/remove.rb +15 -13
  35. data/lib/pdk/cli/set/config.rb +91 -89
  36. data/lib/pdk/cli/set.rb +15 -13
  37. data/lib/pdk/cli/test/unit.rb +71 -69
  38. data/lib/pdk/cli/test.rb +9 -7
  39. data/lib/pdk/cli/update.rb +33 -38
  40. data/lib/pdk/cli/util/command_redirector.rb +10 -1
  41. data/lib/pdk/cli/util/interview.rb +11 -4
  42. data/lib/pdk/cli/util/option_normalizer.rb +2 -4
  43. data/lib/pdk/cli/util/option_validator.rb +7 -9
  44. data/lib/pdk/cli/util/update_manager_printer.rb +4 -4
  45. data/lib/pdk/cli/util.rb +32 -48
  46. data/lib/pdk/cli/validate.rb +98 -96
  47. data/lib/pdk/cli.rb +124 -120
  48. data/lib/pdk/config/ini_file.rb +4 -3
  49. data/lib/pdk/config/ini_file_setting.rb +6 -10
  50. data/lib/pdk/config/json.rb +1 -0
  51. data/lib/pdk/config/json_schema_namespace.rb +5 -10
  52. data/lib/pdk/config/json_schema_setting.rb +3 -5
  53. data/lib/pdk/config/json_with_schema.rb +2 -4
  54. data/lib/pdk/config/namespace.rb +19 -13
  55. data/lib/pdk/config/setting.rb +5 -6
  56. data/lib/pdk/config/task_schema.json +116 -0
  57. data/lib/pdk/config/validator.rb +4 -4
  58. data/lib/pdk/config/yaml.rb +3 -8
  59. data/lib/pdk/config/yaml_with_schema.rb +4 -12
  60. data/lib/pdk/config.rb +47 -51
  61. data/lib/pdk/context/control_repo.rb +3 -2
  62. data/lib/pdk/context/module.rb +2 -2
  63. data/lib/pdk/context/none.rb +2 -2
  64. data/lib/pdk/context.rb +4 -5
  65. data/lib/pdk/control_repo.rb +3 -4
  66. data/lib/pdk/generate/defined_type.rb +3 -3
  67. data/lib/pdk/generate/fact.rb +3 -2
  68. data/lib/pdk/generate/function.rb +5 -4
  69. data/lib/pdk/generate/module.rb +91 -106
  70. data/lib/pdk/generate/provider.rb +5 -4
  71. data/lib/pdk/generate/puppet_class.rb +3 -3
  72. data/lib/pdk/generate/puppet_object.rb +9 -12
  73. data/lib/pdk/generate/task.rb +11 -10
  74. data/lib/pdk/generate/transport.rb +8 -7
  75. data/lib/pdk/generate.rb +1 -1
  76. data/lib/pdk/logger.rb +3 -2
  77. data/lib/pdk/module/build.rb +34 -49
  78. data/lib/pdk/module/convert.rb +13 -22
  79. data/lib/pdk/module/metadata.rb +53 -61
  80. data/lib/pdk/module/release.rb +19 -25
  81. data/lib/pdk/module/update.rb +4 -13
  82. data/lib/pdk/module/update_manager.rb +18 -25
  83. data/lib/pdk/module.rb +1 -1
  84. data/lib/pdk/monkey_patches.rb +268 -0
  85. data/lib/pdk/report/event.rb +12 -37
  86. data/lib/pdk/report.rb +4 -4
  87. data/lib/pdk/template/fetcher/git.rb +7 -8
  88. data/lib/pdk/template/fetcher/local.rb +1 -0
  89. data/lib/pdk/template/fetcher.rb +4 -2
  90. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +4 -9
  91. data/lib/pdk/template/renderer/v1/renderer.rb +19 -20
  92. data/lib/pdk/template/renderer/v1/template_file.rb +4 -8
  93. data/lib/pdk/template/renderer/v1.rb +1 -1
  94. data/lib/pdk/template/renderer.rb +1 -0
  95. data/lib/pdk/template/template_dir.rb +3 -3
  96. data/lib/pdk/template.rb +2 -6
  97. data/lib/pdk/tests/unit.rb +36 -25
  98. data/lib/pdk/util/bundler.rb +10 -14
  99. data/lib/pdk/util/changelog_generator.rb +15 -12
  100. data/lib/pdk/util/env.rb +1 -0
  101. data/lib/pdk/util/filesystem.rb +18 -17
  102. data/lib/pdk/util/git.rb +16 -21
  103. data/lib/pdk/util/json_finder.rb +7 -6
  104. data/lib/pdk/util/puppet_strings.rb +1 -1
  105. data/lib/pdk/util/puppet_version.rb +16 -67
  106. data/lib/pdk/util/ruby_version.rb +9 -13
  107. data/lib/pdk/util/template_uri.rb +17 -29
  108. data/lib/pdk/util/vendored_file.rb +5 -18
  109. data/lib/pdk/util/windows/api_types.rb +70 -64
  110. data/lib/pdk/util/windows/file.rb +31 -27
  111. data/lib/pdk/util/windows/process.rb +59 -61
  112. data/lib/pdk/util/windows/string.rb +19 -12
  113. data/lib/pdk/util.rb +12 -20
  114. data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +1 -1
  115. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +25 -25
  116. data/lib/pdk/validate/external_command_validator.rb +6 -1
  117. data/lib/pdk/validate/internal_ruby_validator.rb +5 -4
  118. data/lib/pdk/validate/invokable_validator.rb +30 -20
  119. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +12 -14
  120. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +13 -15
  121. data/lib/pdk/validate/metadata/metadata_validator_group.rb +1 -1
  122. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +16 -18
  123. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +14 -14
  124. data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +1 -1
  125. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +16 -18
  126. data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -1
  127. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +10 -11
  128. data/lib/pdk/validate/ruby/ruby_validator_group.rb +1 -1
  129. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +19 -24
  130. data/lib/pdk/validate/tasks/tasks_name_validator.rb +11 -13
  131. data/lib/pdk/validate/tasks/tasks_validator_group.rb +1 -1
  132. data/lib/pdk/validate/validator.rb +4 -2
  133. data/lib/pdk/validate/validator_group.rb +6 -3
  134. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +27 -36
  135. data/lib/pdk/validate/yaml/yaml_validator_group.rb +1 -1
  136. data/lib/pdk/validate.rb +6 -6
  137. data/lib/pdk/version.rb +2 -2
  138. data/lib/pdk.rb +12 -12
  139. metadata +27 -35
  140. data/lib/pdk/cli/config/get.rb +0 -26
  141. data/lib/pdk/cli/config.rb +0 -22
  142. data/lib/pdk/cli/module/build.rb +0 -12
  143. data/lib/pdk/cli/module/generate.rb +0 -47
  144. data/lib/pdk/cli/module.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 979dd75e73b7f8116815ac2bcea591015552d39bd270839b1463699b155749b8
4
- data.tar.gz: 38db198043dbc6972a40e6c7fe0cab03831ac2e14c262a34620df6edc8c54bbf
3
+ metadata.gz: e9684e766d6debf57befee1e394ab0302121b091d910a673665b96f879cb910d
4
+ data.tar.gz: 4b9aa80e2c4b57a6c5fce2bd67a6b9b78a6143ca8c9f7d47f15ce2e80ca4ea11
5
5
  SHA512:
6
- metadata.gz: 3fda4ce44de952a03a892d511eed80f843ac0436c5758c0447d7acc1e732e8303aecee89680638329b974c995167dc197349c1e1def0faa5378a200abf3eaeb9
7
- data.tar.gz: 01220e3d45975f58517af8e066063d36827058236ecd4f5a518b4c9b413a0e2f6008faeb05097246d3c8485661b9d66f1f7421d1287feeb2b1462c1326e6a5ff
6
+ metadata.gz: b9635f26c76cff37e9d474a06e844cfc48cc16eb4f3e0367811b2a29e8cf997ff58b10ecec83325b1ae9826a53156fa6da4303667fab481d1cdeaf3e5c753640
7
+ data.tar.gz: e8c2cc3bde2e7c5a5142521d6dece6ef72f16c144f94dcf009900bad7f52ac1c0e3656e9e5d5f9636d5e5ddfb0c719e08dca9f4bcc86ad26791610374f91bc40
data/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ 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
+ ## [v3.0.0](https://github.com/puppetlabs/pdk/tree/v3.0.0) - 2023-07-04
9
+
10
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.7.1...v3.0.0)
11
+
12
+ ### Added
13
+
14
+ - (CONT-1053) Update bundle command [#1255](https://github.com/puppetlabs/pdk/pull/1255) ([chelnak](https://github.com/chelnak))
15
+ - (ISS-1123) Verbose output w/ junit file [#1246](https://github.com/puppetlabs/pdk/pull/1246) ([coreymbe](https://github.com/coreymbe))
16
+ - Take "operatingsystem_support" parameter from answer.json [#1165](https://github.com/puppetlabs/pdk/pull/1165) ([me-minus](https://github.com/me-minus))
17
+
18
+ ### Changed
19
+ - (CONT-1134) Bump PDK Templates REF [#1264](https://github.com/puppetlabs/pdk/pull/1264) ([chelnak](https://github.com/chelnak))
20
+ - (CONT-1154) Disable console command [#1263](https://github.com/puppetlabs/pdk/pull/1263) ([chelnak](https://github.com/chelnak))
21
+ - (CONT-1130) Bump PDK gem version [#1260](https://github.com/puppetlabs/pdk/pull/1260) ([chelnak](https://github.com/chelnak))
22
+ - (CONT-1027) Deprecate pe-version option [#1252](https://github.com/puppetlabs/pdk/pull/1252) ([chelnak](https://github.com/chelnak))
23
+ - (CONT-1025) Remove module command [#1250](https://github.com/puppetlabs/pdk/pull/1250) ([chelnak](https://github.com/chelnak))
24
+ - (CONT-1024) Remove config command [#1249](https://github.com/puppetlabs/pdk/pull/1249) ([chelnak](https://github.com/chelnak))
25
+ - (CONT-755) - Bump gem version [#1240](https://github.com/puppetlabs/pdk/pull/1240) ([chelnak](https://github.com/chelnak))
26
+ - (CONT-755) Ruby 3 / Puppet 8 support [#1230](https://github.com/puppetlabs/pdk/pull/1230) ([chelnak](https://github.com/chelnak))
27
+
28
+ ### Fixed
29
+
30
+ - (CONT-1069) Update compatibility handling [#1259](https://github.com/puppetlabs/pdk/pull/1259) ([chelnak](https://github.com/chelnak))
31
+ - (CONT-935) Fix issues with PDK package and tests [#1248](https://github.com/puppetlabs/pdk/pull/1248) ([chelnak](https://github.com/chelnak))
32
+
33
+ ## [v2.7.1](https://github.com/puppetlabs/pdk/tree/v2.7.1) - 2023-03-24
34
+
35
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.7.0...v2.7.1)
36
+
8
37
  ## [v2.7.0](https://github.com/puppetlabs/pdk/tree/v2.7.0) - 2023-03-14
9
38
 
10
39
  [Full Changelog](https://github.com/puppetlabs/pdk/compare/v2.6.1...v2.7.0)
data/README.md CHANGED
@@ -20,7 +20,6 @@ PDK includes the following tools:
20
20
  |facterdb|A gem that contains facts for Operating Systems.| N |
21
21
  |metadata-json-lint|Validates and lints `metadata.json` files in modules against Puppet module metadata style guidelines.| N |
22
22
  |pdk|Tool to generate and test modules and module content, such as classes, from the command line.| Y |
23
- |puppet-debugger|Provides a REPL based debugger console.| N |
24
23
  |puppet-lint|Checks your Puppet code against the recommendations in the Puppet language style guide.| Y |
25
24
  |puppet-syntax|Checks for correct syntax in Puppet manifests, templates, and Hiera YAML.| N |
26
25
  |puppetlabs_spec_helper|Provides classes, methods, and Rake tasks to help with spec testing Puppet code.| Y |
@@ -107,52 +106,6 @@ pdk test unit
107
106
 
108
107
  This command runs all available unit tests.
109
108
 
110
- ## Experimental features
111
-
112
- ### `pdk console` command
113
- The pdk console command executes a session of the puppet debugger when inside a module and allows for exploration of puppet code. See the official [puppet debugger site](https://www.puppet-debugger.com) for more info and the official docs [site here.](https://docs.puppet-debugger.com)
114
-
115
- To use, execute `pdk console` from inside your module directory. You can also supply the `--puppet-version` or `--pe-version` or `--puppet-dev` to swap out the puppet version when using the console.
116
-
117
- Example (from within a module):
118
-
119
- * `pdk console --puppet-version=5`
120
- * `pdk console --pe-version=2018.1`
121
-
122
- The `pdk console` command will also pass through any puppet debugger arguments you wish to use.
123
-
124
- Example:
125
-
126
- * `pdk console --no-facterdb`
127
- * `pdk console --play https://gist.github.com/logicminds/4f6bcfd723c92aad1f01f6a800319fa4`
128
- * `pdk console -e "md5('sdfasdfasdf')" --run-once --quiet`
129
-
130
- Use `pdk console -h` for a further explanation of pass through arguments.
131
-
132
- If you receive the following error you do not have the puppet-debugger gem installed.
133
-
134
- ```
135
- pdk console -h
136
- Error: Unknown Puppet subcommand 'debugger'
137
- See 'puppet help' for help on available puppet subcommands
138
- ```
139
-
140
- To fix this you will need to add the following entry to your .sync.yml file and run pdk update:
141
-
142
- ```
143
- Gemfile:
144
- required:
145
- ":development":
146
- - gem: puppet-debugger
147
- version: "~> 0.14"
148
- ```
149
-
150
- **NOTE**: The puppet-debugger gem has been added to the [puppet-module-* gems](https://github.com/puppetlabs/puppet-module-gems/pull/117), so once you get the gem update you no longer need the .sync.yml entry.
151
-
152
- ### `pdk bundle` command
153
-
154
- This command executes arbitrary commands in a bundler context within the module you're currently working on. Arguments to this command are passed straight through to bundler. This command is experimental and can lead to errors that can't be resolved by PDK itself.
155
-
156
109
  ## Module Compatibility
157
110
 
158
111
  **PDK Version Compatibility:** Modules created with PDK validate against and run on all Puppet and Ruby version combinations currently under maintenance (see https://docs.puppet.com/puppet/latest/about_agent.html and https://puppet.com/misc/puppet-enterprise-lifecycle)
@@ -163,4 +116,5 @@ PDK encourages community contributions. See the [CONTRIBUTING.md](CONTRIBUTING.m
163
116
 
164
117
  ## Contact Information
165
118
 
166
- To contact us with questions: [pdk-maintainers@puppet.com](mailto:pdk-maintainers@puppet.com)
119
+ * [For reporting bugs](https://github.com/puppetlabs/pdk/blob/main/CONTRIBUTING.md#reporting-bugs)
120
+ * To contact us with questions, [join the Puppet Community on Slack](https://slack.puppet.com/)
@@ -8,18 +8,13 @@ module PDK
8
8
  TRACKING_URL = 'https://google-analytics.com/collect'.freeze
9
9
  CUSTOM_DIMENSIONS = {
10
10
  operating_system: :cd1,
11
- output_format: :cd2,
12
- ruby_version: :cd3,
13
- cli_options: :cd4,
14
- env_vars: :cd5,
11
+ output_format: :cd2,
12
+ ruby_version: :cd3,
13
+ cli_options: :cd4,
14
+ env_vars: :cd5
15
15
  }.freeze
16
16
 
17
- attr_reader :user_id
18
- attr_reader :logger
19
- attr_reader :app_name
20
- attr_reader :app_id
21
- attr_reader :app_version
22
- attr_reader :app_installer
17
+ attr_reader :user_id, :logger, :app_name, :app_id, :app_version, :app_installer
23
18
 
24
19
  def initialize(opts)
25
20
  # lazy-load expensive gem code
@@ -42,14 +37,14 @@ module PDK
42
37
 
43
38
  def screen_view(screen, **kwargs)
44
39
  custom_dimensions = walk_keys(kwargs) do |k|
45
- CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '%{key}'" % { key: k })
40
+ CUSTOM_DIMENSIONS[k] || raise(format("Unknown analytics key '%{key}'", key: k))
46
41
  end
47
42
 
48
43
  screen_view_params = {
49
44
  # Type
50
- t: 'screenview',
45
+ t: 'screenview',
51
46
  # Screen Name
52
- cd: screen,
47
+ cd: screen
53
48
  }.merge(custom_dimensions)
54
49
 
55
50
  submit(base_params.merge(screen_view_params))
@@ -57,16 +52,16 @@ module PDK
57
52
 
58
53
  def event(category, action, label: nil, value: nil, **kwargs)
59
54
  custom_dimensions = walk_keys(kwargs) do |k|
60
- CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '%{key}'" % { key: k })
55
+ CUSTOM_DIMENSIONS[k] || raise(format("Unknown analytics key '%{key}'", key: k))
61
56
  end
62
57
 
63
58
  event_params = {
64
59
  # Type
65
- t: 'event',
60
+ t: 'event',
66
61
  # Event Category
67
62
  ec: category,
68
63
  # Event Action
69
- ea: action,
64
+ ea: action
70
65
  }.merge(custom_dimensions)
71
66
 
72
67
  # Event Label
@@ -95,23 +90,23 @@ module PDK
95
90
  require 'locale'
96
91
 
97
92
  {
98
- v: PROTOCOL_VERSION,
93
+ v: PROTOCOL_VERSION,
99
94
  # Client ID
100
- cid: user_id,
95
+ cid: user_id,
101
96
  # Tracking ID
102
- tid: app_id,
97
+ tid: app_id,
103
98
  # Application Name
104
- an: app_name,
99
+ an: app_name,
105
100
  # Application Version
106
- av: app_version,
101
+ av: app_version,
107
102
  # Application Installer ID
108
103
  aiid: app_installer,
109
104
  # Anonymize IPs
110
- aip: true,
105
+ aip: true,
111
106
  # User locale
112
- ul: Locale.current.to_rfc,
107
+ ul: Locale.current.to_rfc,
113
108
  # Custom Dimension 1 (Operating System)
114
- cd1: @os.value,
109
+ cd1: @os.value
115
110
  }
116
111
  end
117
112
 
@@ -128,12 +123,13 @@ module PDK
128
123
  private
129
124
 
130
125
  def walk_keys(data, &block)
131
- if data.is_a?(Hash)
126
+ case data
127
+ when Hash
132
128
  data.each_with_object({}) do |(k, v), acc|
133
129
  v = walk_keys(v, &block)
134
130
  acc[yield(k)] = v
135
131
  end
136
- elsif data.is_a?(Array)
132
+ when Array
137
133
  data.map { |v| walk_keys(v, &block) }
138
134
  else
139
135
  data
@@ -8,7 +8,6 @@ module PDK
8
8
  require 'concurrent/future'
9
9
 
10
10
  Concurrent::Future.execute(executor: :io) do
11
- require 'facter'
12
11
  os = Facter.value('os')
13
12
 
14
13
  os.nil? ? 'unknown' : "#{os['name']} #{os.fetch('release', {}).fetch('major', '')}".strip
data/lib/pdk/analytics.rb CHANGED
@@ -12,7 +12,7 @@ module PDK
12
12
  end
13
13
 
14
14
  def self.build_client(opts = {})
15
- opts[:logger] ||= ::Logger.new(STDERR)
15
+ opts[:logger] ||= ::Logger.new($stderr)
16
16
  opts[:client] ||= :noop
17
17
 
18
18
  if opts[:disabled]
data/lib/pdk/bolt.rb CHANGED
@@ -12,6 +12,7 @@ module PDK
12
12
  #
13
13
  def bolt_project_root?(path = Dir.pwd)
14
14
  return true if File.basename(path) == 'Boltdir' && PDK::Util::Filesystem.directory?(path)
15
+
15
16
  PDK::Util::Filesystem.file?(File.join(path, 'bolt.yaml'))
16
17
  end
17
18
  module_function :bolt_project_root?
data/lib/pdk/cli/build.rb CHANGED
@@ -1,78 +1,75 @@
1
- module PDK::CLI
2
- @build_cmd = @base_cmd.define_command do
3
- name 'build'
4
- usage 'build [options]'
5
- summary 'Builds a package from the module that can be published to the Puppet Forge.'
1
+ module PDK
2
+ module CLI
3
+ @build_cmd = @base_cmd.define_command do
4
+ name 'build'
5
+ usage 'build [options]'
6
+ summary 'Builds a package from the module that can be published to the Puppet Forge.'
6
7
 
7
- option nil, 'target-dir',
8
- 'The target directory where you want PDK to write the package.',
9
- argument: :required, default: File.join(Dir.pwd, 'pkg')
8
+ option nil, 'target-dir',
9
+ 'The target directory where you want PDK to write the package.',
10
+ argument: :required, default: File.join(Dir.pwd, 'pkg')
10
11
 
11
- option nil, 'force', 'Skips the prompts and builds the module package.'
12
+ option nil, 'force', 'Skips the prompts and builds the module package.'
12
13
 
13
- run do |opts, _args, _cmd|
14
- require 'pdk/module/build'
15
- require 'pdk/module/metadata'
16
- require 'pdk/cli/util'
14
+ run do |opts, _args, _cmd|
15
+ require 'pdk/module/build'
16
+ require 'pdk/module/metadata'
17
+ require 'pdk/cli/util'
17
18
 
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 build` can only be run from inside a valid module with a metadata.json.',
21
- log_level: :info,
22
- )
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 build` can only be run from inside a valid module with a metadata.json.',
22
+ log_level: :info
23
+ )
23
24
 
24
- PDK::CLI::Util.analytics_screen_view('build', opts)
25
+ PDK::CLI::Util.analytics_screen_view('build', opts)
25
26
 
26
- module_metadata = PDK::Module::Metadata.from_file('metadata.json')
27
+ module_metadata = PDK::Module::Metadata.from_file('metadata.json')
27
28
 
28
- # TODO: Ensure forge metadata has been set, or call out to interview
29
- # to set it.
30
- #
31
- unless module_metadata.forge_ready?
32
- if opts[:force]
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.'
35
- else
36
- module_metadata.interview_for_forge!
37
- module_metadata.write!('metadata.json')
29
+ # TODO: Ensure forge metadata has been set, or call out to interview
30
+ # to set it.
31
+ #
32
+ unless module_metadata.forge_ready?
33
+ if opts[:force]
34
+ PDK.logger.warn "This module is missing the following fields in the metadata.json: #{module_metadata.missing_fields.join(', ')}. " \
35
+ 'These missing fields may affect the visibility of the module on the Forge.'
36
+ else
37
+ module_metadata.interview_for_forge!
38
+ module_metadata.write!('metadata.json')
39
+ end
38
40
  end
39
- end
40
41
 
41
- builder = PDK::Module::Build.new(opts)
42
+ builder = PDK::Module::Build.new(opts)
42
43
 
43
- unless opts[:force]
44
- if builder.package_already_exists?
45
- PDK.logger.info "The file '%{package}' already exists." % { package: builder.package_file }
44
+ unless opts[:force]
45
+ if builder.package_already_exists?
46
+ PDK.logger.info format("The file '%{package}' already exists.", package: builder.package_file)
46
47
 
47
- unless PDK::CLI::Util.prompt_for_yes('Overwrite?', default: false)
48
- PDK.logger.info 'Build cancelled; exiting.'
49
- exit 0
48
+ unless PDK::CLI::Util.prompt_for_yes('Overwrite?', default: false)
49
+ PDK.logger.info 'Build cancelled; exiting.'
50
+ exit 0
51
+ end
50
52
  end
51
- end
52
53
 
53
- unless builder.module_pdk_compatible?
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`.'
54
+ unless builder.module_pdk_compatible?
55
+ PDK.logger.info 'This module is not compatible with PDK, so PDK can not validate or test this build. ' \
56
+ 'Unvalidated modules may have errors when uploading to the Forge. ' \
57
+ 'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.'
57
58
 
58
- unless PDK::CLI::Util.prompt_for_yes('Continue build without converting?')
59
- PDK.logger.info 'Build cancelled; exiting.'
60
- exit 0
59
+ unless PDK::CLI::Util.prompt_for_yes('Continue build without converting?')
60
+ PDK.logger.info 'Build cancelled; exiting.'
61
+ exit 0
62
+ end
61
63
  end
62
64
  end
63
- end
64
65
 
65
- PDK.logger.info 'Building %{module_name} version %{module_version}' % {
66
- module_name: module_metadata.data['name'],
67
- module_version: module_metadata.data['version'],
68
- }
66
+ PDK.logger.info format('Building %{module_name} version %{module_version}', module_name: module_metadata.data['name'], module_version: module_metadata.data['version'])
69
67
 
70
- builder.build
68
+ builder.build
71
69
 
72
- PDK.logger.info 'Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}' % {
73
- package_name: module_metadata.data['name'],
74
- package_path: builder.package_file,
75
- }
70
+ PDK.logger.info format('Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}', package_name: module_metadata.data['name'],
71
+ package_path: builder.package_file)
72
+ end
76
73
  end
77
74
  end
78
75
  end
@@ -1,47 +1,48 @@
1
- module PDK::CLI
2
- @bundle_cmd = @base_cmd.define_command do
3
- name 'bundle'
4
- usage 'bundle [bundler_options]'
5
- summary '(Experimental) Command pass-through to bundler'
6
- description <<-EOF
7
- [experimental] For advanced users, pdk bundle runs arbitrary commands in the bundler environment that pdk manages.
8
- Careless use of this command can lead to errors that pdk can't help recover from.
9
- EOF
10
- skip_option_parsing
1
+ module PDK
2
+ module CLI
3
+ @bundle_cmd = @base_cmd.define_command do
4
+ name 'bundle'
5
+ usage 'bundle [bundler_options]'
6
+ summary 'Command pass-through to bundler'
7
+ description <<~EOF
8
+ For advanced users, pdk bundle runs arbitrary commands in the bundler environment that pdk manages.
9
+ Careless use of this command can lead to errors that pdk can't help recover from.
10
+ EOF
11
+ skip_option_parsing
11
12
 
12
- run do |_opts, args, _cmd|
13
- require 'pdk/cli/exec/interactive_command'
14
- require 'pdk/util/bundler'
13
+ run do |_opts, args, _cmd|
14
+ require 'pdk/util/bundler'
15
15
 
16
- PDK::CLI::Util.ensure_in_module!(
17
- message: '`pdk bundle` can only be run from inside a valid module directory.',
18
- )
16
+ PDK::CLI::Util.ensure_in_module!(
17
+ message: '`pdk bundle` can only be run from inside a valid module directory.'
18
+ )
19
19
 
20
- PDK::CLI::Util.validate_puppet_version_opts({})
20
+ PDK::CLI::Util.validate_puppet_version_opts({})
21
21
 
22
- screen_view_name = ['bundle']
23
- screen_view_name << args[0] if args.size >= 1
24
- screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'
22
+ screen_view_name = ['bundle']
23
+ screen_view_name << args[0] if args.size >= 1
24
+ screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'
25
25
 
26
- PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))
26
+ PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))
27
27
 
28
- # Ensure that the correct Ruby is activated before running command.
29
- puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
30
- PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
28
+ # Ensure that the correct Ruby is activated before running command.
29
+ puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
30
+ PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
31
31
 
32
- gemfile_env = PDK::Util::Bundler::BundleHelper.gemfile_env(puppet_env[:gemset])
32
+ gemfile_env = PDK::Util::Bundler::BundleHelper.gemfile_env(puppet_env[:gemset])
33
33
 
34
- require 'pdk/cli/exec'
35
- require 'pdk/cli/exec/interactive_command'
34
+ require 'pdk/cli/exec'
35
+ require 'pdk/cli/exec/interactive_command'
36
36
 
37
- command = PDK::CLI::Exec::InteractiveCommand.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
38
- c.context = :pwd
39
- c.update_environment(gemfile_env)
40
- end
37
+ command = PDK::CLI::Exec::InteractiveCommand.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
38
+ c.context = :pwd
39
+ c.update_environment(gemfile_env)
40
+ end
41
41
 
42
- result = command.execute!
42
+ result = command.execute!
43
43
 
44
- exit result[:exit_code]
44
+ exit result[:exit_code]
45
+ end
45
46
  end
46
47
  end
47
48
  end