pdk 2.3.0 → 2.4.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 +1329 -1321
  3. data/LICENSE +201 -201
  4. data/README.md +163 -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 -277
  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 +2094 -2094
  153. metadata +5 -6
@@ -1,25 +1,25 @@
1
- require 'pdk'
2
-
3
- module PDK
4
- module Analytics
5
- module Client
6
- class Noop
7
- attr_reader :logger
8
-
9
- def initialize(opts)
10
- @logger = opts[:logger]
11
- end
12
-
13
- def screen_view(screen, **_kwargs)
14
- logger.debug "Skipping submission of '#{screen}' screenview because analytics is disabled"
15
- end
16
-
17
- def event(category, action, **_kwargs)
18
- logger.debug "Skipping submission of '#{category} #{action}' event because analytics is disabled"
19
- end
20
-
21
- def finish; end
22
- end
23
- end
24
- end
25
- end
1
+ require 'pdk'
2
+
3
+ module PDK
4
+ module Analytics
5
+ module Client
6
+ class Noop
7
+ attr_reader :logger
8
+
9
+ def initialize(opts)
10
+ @logger = opts[:logger]
11
+ end
12
+
13
+ def screen_view(screen, **_kwargs)
14
+ logger.debug "Skipping submission of '#{screen}' screenview because analytics is disabled"
15
+ end
16
+
17
+ def event(category, action, **_kwargs)
18
+ logger.debug "Skipping submission of '#{category} #{action}' event because analytics is disabled"
19
+ end
20
+
21
+ def finish; end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,19 +1,19 @@
1
- require 'pdk'
2
-
3
- module PDK
4
- module Analytics
5
- module Util
6
- def self.fetch_os_async
7
- require 'concurrent/configuration'
8
- require 'concurrent/future'
9
-
10
- Concurrent::Future.execute(executor: :io) do
11
- require 'facter'
12
- os = Facter.value('os')
13
-
14
- os.nil? ? 'unknown' : "#{os['name']} #{os.fetch('release', {}).fetch('major', '')}".strip
15
- end
16
- end
17
- end
18
- end
19
- end
1
+ require 'pdk'
2
+
3
+ module PDK
4
+ module Analytics
5
+ module Util
6
+ def self.fetch_os_async
7
+ require 'concurrent/configuration'
8
+ require 'concurrent/future'
9
+
10
+ Concurrent::Future.execute(executor: :io) do
11
+ require 'facter'
12
+ os = Facter.value('os')
13
+
14
+ os.nil? ? 'unknown' : "#{os['name']} #{os.fetch('release', {}).fetch('major', '')}".strip
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/pdk/analytics.rb CHANGED
@@ -1,30 +1,30 @@
1
- require 'pdk'
2
-
3
- autoload :Logger, 'logger'
4
-
5
- module PDK
6
- module Analytics
7
- autoload :Util, 'pdk/analytics/util'
8
-
9
- module Client
10
- autoload :Noop, 'pdk/analytics/client/noop'
11
- autoload :GoogleAnalytics, 'pdk/analytics/client/google_analytics'
12
- end
13
-
14
- def self.build_client(opts = {})
15
- opts[:logger] ||= ::Logger.new(STDERR)
16
- opts[:client] ||= :noop
17
-
18
- if opts[:disabled]
19
- opts[:logger].debug 'Analytics opt-out is set, analytics will be disabled'
20
- opts[:client] = :noop
21
- end
22
-
23
- client_const = opts[:client].to_s.split('_').map(&:capitalize).join
24
- PDK::Analytics::Client.const_get(client_const).new(opts)
25
- rescue StandardError => e
26
- opts[:logger].debug "Failed to initialize analytics client, analytics will be disabled: #{e}"
27
- PDK::Analytics::Client::Noop.new(opts)
28
- end
29
- end
30
- end
1
+ require 'pdk'
2
+
3
+ autoload :Logger, 'logger'
4
+
5
+ module PDK
6
+ module Analytics
7
+ autoload :Util, 'pdk/analytics/util'
8
+
9
+ module Client
10
+ autoload :Noop, 'pdk/analytics/client/noop'
11
+ autoload :GoogleAnalytics, 'pdk/analytics/client/google_analytics'
12
+ end
13
+
14
+ def self.build_client(opts = {})
15
+ opts[:logger] ||= ::Logger.new(STDERR)
16
+ opts[:client] ||= :noop
17
+
18
+ if opts[:disabled]
19
+ opts[:logger].debug 'Analytics opt-out is set, analytics will be disabled'
20
+ opts[:client] = :noop
21
+ end
22
+
23
+ client_const = opts[:client].to_s.split('_').map(&:capitalize).join
24
+ PDK::Analytics::Client.const_get(client_const).new(opts)
25
+ rescue StandardError => e
26
+ opts[:logger].debug "Failed to initialize analytics client, analytics will be disabled: #{e}"
27
+ PDK::Analytics::Client::Noop.new(opts)
28
+ end
29
+ end
30
+ end
@@ -1,12 +1,12 @@
1
- require 'pdk'
2
-
3
- module PDK
4
- class AnswerFile
5
- # Determine the default path to the answer file.
6
- #
7
- # @return [String] The path on disk to the default answer file.
8
- def self.default_answer_file_path
9
- PDK::Util::Filesystem.expand_path(File.join(PDK::Util.cachedir, 'answers.json'))
10
- end
11
- end
12
- end
1
+ require 'pdk'
2
+
3
+ module PDK
4
+ class AnswerFile
5
+ # Determine the default path to the answer file.
6
+ #
7
+ # @return [String] The path on disk to the default answer file.
8
+ def self.default_answer_file_path
9
+ PDK::Util::Filesystem.expand_path(File.join(PDK::Util.cachedir, 'answers.json'))
10
+ end
11
+ end
12
+ end
data/lib/pdk/bolt.rb CHANGED
@@ -1,19 +1,19 @@
1
- require 'pdk'
2
-
3
- module PDK
4
- module Bolt
5
- # Returns true or false depending on if any of the common files and directories in
6
- # a Bolt Project are found in the specified directory. If a directory is not specified,
7
- # the current working directory is used.
8
- #
9
- # @see https://puppet.com/docs/bolt/latest/bolt_project_directories.html
10
- #
11
- # @return [boolean] True if any bolt specific files or directories are present
12
- #
13
- def bolt_project_root?(path = Dir.pwd)
14
- return true if File.basename(path) == 'Boltdir' && PDK::Util::Filesystem.directory?(path)
15
- PDK::Util::Filesystem.file?(File.join(path, 'bolt.yaml'))
16
- end
17
- module_function :bolt_project_root?
18
- end
19
- end
1
+ require 'pdk'
2
+
3
+ module PDK
4
+ module Bolt
5
+ # Returns true or false depending on if any of the common files and directories in
6
+ # a Bolt Project are found in the specified directory. If a directory is not specified,
7
+ # the current working directory is used.
8
+ #
9
+ # @see https://puppet.com/docs/bolt/latest/bolt_project_directories.html
10
+ #
11
+ # @return [boolean] True if any bolt specific files or directories are present
12
+ #
13
+ def bolt_project_root?(path = Dir.pwd)
14
+ return true if File.basename(path) == 'Boltdir' && PDK::Util::Filesystem.directory?(path)
15
+ PDK::Util::Filesystem.file?(File.join(path, 'bolt.yaml'))
16
+ end
17
+ module_function :bolt_project_root?
18
+ end
19
+ end
data/lib/pdk/cli/build.rb CHANGED
@@ -1,82 +1,82 @@
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.')
6
-
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')
10
-
11
- option nil, 'force', _('Skips the prompts and builds the module package.')
12
-
13
- run do |opts, _args, _cmd|
14
- require 'pdk/module/build'
15
- require 'pdk/module/metadata'
16
- require 'pdk/cli/util'
17
-
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
- )
23
-
24
- PDK::CLI::Util.analytics_screen_view('build', opts)
25
-
26
- module_metadata = PDK::Module::Metadata.from_file('metadata.json')
27
-
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 _(
34
- 'This module is missing the following fields in the metadata.json: %{fields}. ' \
35
- 'These missing fields may affect the visibility of the module on the Forge.',
36
- ) % {
37
- fields: module_metadata.missing_fields.join(', '),
38
- }
39
- else
40
- module_metadata.interview_for_forge!
41
- module_metadata.write!('metadata.json')
42
- end
43
- end
44
-
45
- builder = PDK::Module::Build.new(opts)
46
-
47
- unless opts[:force]
48
- if builder.package_already_exists?
49
- PDK.logger.info _("The file '%{package}' already exists.") % { package: builder.package_file }
50
-
51
- unless PDK::CLI::Util.prompt_for_yes(_('Overwrite?'), default: false)
52
- PDK.logger.info _('Build cancelled; exiting.')
53
- exit 0
54
- end
55
- end
56
-
57
- unless builder.module_pdk_compatible?
58
- PDK.logger.info _('This module is not compatible with PDK, so PDK can not validate or test this build. ' \
59
- 'Unvalidated modules may have errors when uploading to the Forge. ' \
60
- 'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.')
61
-
62
- unless PDK::CLI::Util.prompt_for_yes(_('Continue build without converting?'))
63
- PDK.logger.info _('Build cancelled; exiting.')
64
- exit 0
65
- end
66
- end
67
- end
68
-
69
- PDK.logger.info _('Building %{module_name} version %{module_version}') % {
70
- module_name: module_metadata.data['name'],
71
- module_version: module_metadata.data['version'],
72
- }
73
-
74
- builder.build
75
-
76
- PDK.logger.info _('Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}') % {
77
- package_name: module_metadata.data['name'],
78
- package_path: builder.package_file,
79
- }
80
- end
81
- end
82
- end
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.')
6
+
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')
10
+
11
+ option nil, 'force', _('Skips the prompts and builds the module package.')
12
+
13
+ run do |opts, _args, _cmd|
14
+ require 'pdk/module/build'
15
+ require 'pdk/module/metadata'
16
+ require 'pdk/cli/util'
17
+
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
+ )
23
+
24
+ PDK::CLI::Util.analytics_screen_view('build', opts)
25
+
26
+ module_metadata = PDK::Module::Metadata.from_file('metadata.json')
27
+
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 _(
34
+ 'This module is missing the following fields in the metadata.json: %{fields}. ' \
35
+ 'These missing fields may affect the visibility of the module on the Forge.',
36
+ ) % {
37
+ fields: module_metadata.missing_fields.join(', '),
38
+ }
39
+ else
40
+ module_metadata.interview_for_forge!
41
+ module_metadata.write!('metadata.json')
42
+ end
43
+ end
44
+
45
+ builder = PDK::Module::Build.new(opts)
46
+
47
+ unless opts[:force]
48
+ if builder.package_already_exists?
49
+ PDK.logger.info _("The file '%{package}' already exists.") % { package: builder.package_file }
50
+
51
+ unless PDK::CLI::Util.prompt_for_yes(_('Overwrite?'), default: false)
52
+ PDK.logger.info _('Build cancelled; exiting.')
53
+ exit 0
54
+ end
55
+ end
56
+
57
+ unless builder.module_pdk_compatible?
58
+ PDK.logger.info _('This module is not compatible with PDK, so PDK can not validate or test this build. ' \
59
+ 'Unvalidated modules may have errors when uploading to the Forge. ' \
60
+ 'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.')
61
+
62
+ unless PDK::CLI::Util.prompt_for_yes(_('Continue build without converting?'))
63
+ PDK.logger.info _('Build cancelled; exiting.')
64
+ exit 0
65
+ end
66
+ end
67
+ end
68
+
69
+ PDK.logger.info _('Building %{module_name} version %{module_version}') % {
70
+ module_name: module_metadata.data['name'],
71
+ module_version: module_metadata.data['version'],
72
+ }
73
+
74
+ builder.build
75
+
76
+ PDK.logger.info _('Build of %{package_name} has completed successfully. Built package can be found here: %{package_path}') % {
77
+ package_name: module_metadata.data['name'],
78
+ package_path: builder.package_file,
79
+ }
80
+ end
81
+ end
82
+ end
@@ -1,48 +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
- )
11
- skip_option_parsing
12
-
13
- run do |_opts, args, _cmd|
14
- require 'pdk/cli/exec/interactive_command'
15
- require 'pdk/util/bundler'
16
-
17
- PDK::CLI::Util.ensure_in_module!(
18
- message: _('`pdk bundle` can only be run from inside a valid module directory.'),
19
- )
20
-
21
- PDK::CLI::Util.validate_puppet_version_opts({})
22
-
23
- screen_view_name = ['bundle']
24
- screen_view_name << args[0] if args.size >= 1
25
- screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'
26
-
27
- PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))
28
-
29
- # Ensure that the correct Ruby is activated before running command.
30
- puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
31
- PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
32
-
33
- gemfile_env = PDK::Util::Bundler::BundleHelper.gemfile_env(puppet_env[:gemset])
34
-
35
- require 'pdk/cli/exec'
36
- require 'pdk/cli/exec/interactive_command'
37
-
38
- command = PDK::CLI::Exec::InteractiveCommand.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
39
- c.context = :pwd
40
- c.update_environment(gemfile_env)
41
- end
42
-
43
- result = command.execute!
44
-
45
- exit result[:exit_code]
46
- end
47
- end
48
- end
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
+ )
11
+ skip_option_parsing
12
+
13
+ run do |_opts, args, _cmd|
14
+ require 'pdk/cli/exec/interactive_command'
15
+ require 'pdk/util/bundler'
16
+
17
+ PDK::CLI::Util.ensure_in_module!(
18
+ message: _('`pdk bundle` can only be run from inside a valid module directory.'),
19
+ )
20
+
21
+ PDK::CLI::Util.validate_puppet_version_opts({})
22
+
23
+ screen_view_name = ['bundle']
24
+ screen_view_name << args[0] if args.size >= 1
25
+ screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'
26
+
27
+ PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))
28
+
29
+ # Ensure that the correct Ruby is activated before running command.
30
+ puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
31
+ PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
32
+
33
+ gemfile_env = PDK::Util::Bundler::BundleHelper.gemfile_env(puppet_env[:gemset])
34
+
35
+ require 'pdk/cli/exec'
36
+ require 'pdk/cli/exec/interactive_command'
37
+
38
+ command = PDK::CLI::Exec::InteractiveCommand.new(PDK::CLI::Exec.bundle_bin, *args).tap do |c|
39
+ c.context = :pwd
40
+ c.update_environment(gemfile_env)
41
+ end
42
+
43
+ result = command.execute!
44
+
45
+ exit result[:exit_code]
46
+ end
47
+ end
48
+ end
@@ -1,26 +1,26 @@
1
- module PDK::CLI
2
- @config_get_cmd = @config_cmd.define_command do
3
- name 'get'
4
- usage _('config get [name]')
5
- summary _('(Deprecated) Retrieve the configuration for <name>. If not specified, retrieve all configuration settings')
6
-
7
- run do |_opts, args, _cmd|
8
- PDK.logger.warn _('The \'pdk config get\' command is deprecated, please use \'pdk get config\' instead.')
9
-
10
- item_name = args[0]
11
- resolved_config = PDK.config.resolve(item_name)
12
- # If the user wanted to know a setting but it doesn't exist, raise an error
13
- if resolved_config.empty? && !item_name.nil?
14
- PDK.logger.error(_("Configuration item '%{name}' does not exist") % { name: item_name })
15
- exit 1
16
- end
17
- # If the user requested a setting and it's the only one resolved, then just output the value
18
- if resolved_config.count == 1 && resolved_config.keys[0] == item_name
19
- puts _('%{value}') % { value: resolved_config.values[0] }
20
- exit 0
21
- end
22
- # Otherwise just output everything
23
- resolved_config.keys.sort.each { |key| puts _('%{name}=%{value}') % { name: key, value: resolved_config[key] } }
24
- end
25
- end
26
- end
1
+ module PDK::CLI
2
+ @config_get_cmd = @config_cmd.define_command do
3
+ name 'get'
4
+ usage _('config get [name]')
5
+ summary _('(Deprecated) Retrieve the configuration for <name>. If not specified, retrieve all configuration settings')
6
+
7
+ run do |_opts, args, _cmd|
8
+ PDK.logger.warn _('The \'pdk config get\' command is deprecated, please use \'pdk get config\' instead.')
9
+
10
+ item_name = args[0]
11
+ resolved_config = PDK.config.resolve(item_name)
12
+ # If the user wanted to know a setting but it doesn't exist, raise an error
13
+ if resolved_config.empty? && !item_name.nil?
14
+ PDK.logger.error(_("Configuration item '%{name}' does not exist") % { name: item_name })
15
+ exit 1
16
+ end
17
+ # If the user requested a setting and it's the only one resolved, then just output the value
18
+ if resolved_config.count == 1 && resolved_config.keys[0] == item_name
19
+ puts _('%{value}') % { value: resolved_config.values[0] }
20
+ exit 0
21
+ end
22
+ # Otherwise just output everything
23
+ resolved_config.keys.sort.each { |key| puts _('%{name}=%{value}') % { name: key, value: resolved_config[key] } }
24
+ end
25
+ end
26
+ end
@@ -1,22 +1,22 @@
1
- module PDK::CLI
2
- @config_cmd = @base_cmd.define_command do
3
- name 'config'
4
- usage _('config [subcommand] [options]')
5
- summary _('(Deprecated) Configure the Puppet Development Kit.')
6
- default_subcommand 'help'
7
-
8
- run do |_opts, args, _cmd|
9
- PDK.logger.warn _('The \'pdk config\' command is deprecated, please use \'pdk get config\' and \'pdk set config\' instead.')
10
-
11
- if args == ['help']
12
- PDK::CLI.run(%w[config --help])
13
- exit 0
14
- end
15
-
16
- PDK::CLI.run(%w[config help]) if args.empty?
17
- end
18
- end
19
- @config_cmd.add_command Cri::Command.new_basic_help
20
- end
21
-
22
- require 'pdk/cli/config/get'
1
+ module PDK::CLI
2
+ @config_cmd = @base_cmd.define_command do
3
+ name 'config'
4
+ usage _('config [subcommand] [options]')
5
+ summary _('(Deprecated) Configure the Puppet Development Kit.')
6
+ default_subcommand 'help'
7
+
8
+ run do |_opts, args, _cmd|
9
+ PDK.logger.warn _('The \'pdk config\' command is deprecated, please use \'pdk get config\' and \'pdk set config\' instead.')
10
+
11
+ if args == ['help']
12
+ PDK::CLI.run(%w[config --help])
13
+ exit 0
14
+ end
15
+
16
+ PDK::CLI.run(%w[config help]) if args.empty?
17
+ end
18
+ end
19
+ @config_cmd.add_command Cri::Command.new_basic_help
20
+ end
21
+
22
+ require 'pdk/cli/config/get'