pdk 2.6.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -1
  3. data/lib/pdk/analytics/client/google_analytics.rb +4 -2
  4. data/lib/pdk/cli/build.rb +17 -21
  5. data/lib/pdk/cli/bundle.rb +4 -5
  6. data/lib/pdk/cli/config/get.rb +6 -6
  7. data/lib/pdk/cli/config.rb +3 -3
  8. data/lib/pdk/cli/console.rb +7 -7
  9. data/lib/pdk/cli/convert.rb +11 -11
  10. data/lib/pdk/cli/env.rb +3 -4
  11. data/lib/pdk/cli/errors.rb +1 -1
  12. data/lib/pdk/cli/exec/command.rb +12 -14
  13. data/lib/pdk/cli/exec/interactive_command.rb +11 -11
  14. data/lib/pdk/cli/exec.rb +4 -4
  15. data/lib/pdk/cli/exec_group.rb +1 -3
  16. data/lib/pdk/cli/get/config.rb +5 -5
  17. data/lib/pdk/cli/get.rb +2 -2
  18. data/lib/pdk/cli/module/build.rb +3 -3
  19. data/lib/pdk/cli/module/generate.rb +4 -4
  20. data/lib/pdk/cli/module.rb +3 -3
  21. data/lib/pdk/cli/new/class.rb +4 -4
  22. data/lib/pdk/cli/new/defined_type.rb +4 -4
  23. data/lib/pdk/cli/new/fact.rb +3 -3
  24. data/lib/pdk/cli/new/function.rb +4 -4
  25. data/lib/pdk/cli/new/module.rb +10 -11
  26. data/lib/pdk/cli/new/provider.rb +3 -3
  27. data/lib/pdk/cli/new/task.rb +5 -5
  28. data/lib/pdk/cli/new/test.rb +7 -7
  29. data/lib/pdk/cli/new/transport.rb +3 -3
  30. data/lib/pdk/cli/new.rb +3 -3
  31. data/lib/pdk/cli/release/prep.rb +9 -9
  32. data/lib/pdk/cli/release/publish.rb +7 -11
  33. data/lib/pdk/cli/release.rb +35 -39
  34. data/lib/pdk/cli/remove/config.rb +15 -15
  35. data/lib/pdk/cli/remove.rb +2 -2
  36. data/lib/pdk/cli/set/config.rb +16 -16
  37. data/lib/pdk/cli/set.rb +2 -2
  38. data/lib/pdk/cli/test/unit.rb +13 -13
  39. data/lib/pdk/cli/test.rb +2 -2
  40. data/lib/pdk/cli/update.rb +19 -29
  41. data/lib/pdk/cli/util/command_redirector.rb +1 -1
  42. data/lib/pdk/cli/util/interview.rb +4 -4
  43. data/lib/pdk/cli/util/option_normalizer.rb +2 -2
  44. data/lib/pdk/cli/util/option_validator.rb +1 -1
  45. data/lib/pdk/cli/util.rb +19 -20
  46. data/lib/pdk/cli/validate.rb +16 -18
  47. data/lib/pdk/cli.rb +16 -33
  48. data/lib/pdk/config/ini_file_setting.rb +2 -2
  49. data/lib/pdk/config/json_schema_namespace.rb +3 -3
  50. data/lib/pdk/config/json_schema_setting.rb +1 -1
  51. data/lib/pdk/config/json_with_schema.rb +1 -1
  52. data/lib/pdk/config/namespace.rb +4 -4
  53. data/lib/pdk/config/setting.rb +5 -5
  54. data/lib/pdk/config/validator.rb +2 -2
  55. data/lib/pdk/config/yaml.rb +2 -2
  56. data/lib/pdk/config/yaml_with_schema.rb +3 -3
  57. data/lib/pdk/config.rb +18 -20
  58. data/lib/pdk/context/control_repo.rb +1 -1
  59. data/lib/pdk/context/module.rb +1 -1
  60. data/lib/pdk/context/none.rb +1 -1
  61. data/lib/pdk/generate/module.rb +52 -64
  62. data/lib/pdk/generate/puppet_object.rb +6 -6
  63. data/lib/pdk/generate/task.rb +1 -1
  64. data/lib/pdk/module/build.rb +11 -16
  65. data/lib/pdk/module/convert.rb +14 -16
  66. data/lib/pdk/module/metadata.rb +12 -12
  67. data/lib/pdk/module/release.rb +20 -19
  68. data/lib/pdk/module/update.rb +5 -5
  69. data/lib/pdk/module/update_manager.rb +6 -6
  70. data/lib/pdk/report/event.rb +11 -11
  71. data/lib/pdk/template/fetcher/git.rb +4 -4
  72. data/lib/pdk/template/fetcher.rb +1 -1
  73. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +1 -1
  74. data/lib/pdk/template/renderer/v1/renderer.rb +5 -7
  75. data/lib/pdk/template/renderer/v1/template_file.rb +3 -1
  76. data/lib/pdk/template/template_dir.rb +1 -1
  77. data/lib/pdk/template.rb +2 -2
  78. data/lib/pdk/tests/unit.rb +12 -12
  79. data/lib/pdk/util/bundler.rb +14 -14
  80. data/lib/pdk/util/changelog_generator.rb +6 -8
  81. data/lib/pdk/util/filesystem.rb +2 -2
  82. data/lib/pdk/util/git.rb +5 -5
  83. data/lib/pdk/util/puppet_strings.rb +2 -2
  84. data/lib/pdk/util/puppet_version.rb +24 -17
  85. data/lib/pdk/util/ruby_version.rb +2 -5
  86. data/lib/pdk/util/template_uri.rb +8 -8
  87. data/lib/pdk/util/vendored_file.rb +3 -3
  88. data/lib/pdk/util/windows/api_types.rb +3 -4
  89. data/lib/pdk/util/windows/file.rb +1 -1
  90. data/lib/pdk/util/windows/process.rb +5 -8
  91. data/lib/pdk/util.rb +2 -2
  92. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +5 -5
  93. data/lib/pdk/validate/invokable_validator.rb +6 -6
  94. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +2 -2
  95. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +2 -2
  96. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +1 -1
  97. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +1 -1
  98. data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +38 -0
  99. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +1 -1
  100. data/lib/pdk/validate/puppet/puppet_validator_group.rb +1 -0
  101. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +1 -1
  102. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +4 -4
  103. data/lib/pdk/validate/tasks/tasks_name_validator.rb +2 -5
  104. data/lib/pdk/validate/validator.rb +1 -1
  105. data/lib/pdk/validate/validator_group.rb +1 -1
  106. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +4 -4
  107. data/lib/pdk/validate.rb +2 -1
  108. data/lib/pdk/version.rb +2 -2
  109. data/lib/pdk.rb +0 -2
  110. metadata +32 -54
  111. data/lib/pdk/i18n.rb +0 -4
  112. data/locales/config.yaml +0 -21
  113. data/locales/pdk.pot +0 -2111
@@ -1,8 +1,8 @@
1
1
  module PDK::CLI
2
2
  @remove_cmd = @base_cmd.define_command do
3
3
  name 'remove'
4
- usage _('remove [subcommand] [options]')
5
- summary _('Remove or delete information about the PDK or current project.')
4
+ usage 'remove [subcommand] [options]'
5
+ summary 'Remove or delete information about the PDK or current project.'
6
6
  default_subcommand 'help'
7
7
 
8
8
  run do |_opts, args, _cmd|
@@ -12,12 +12,12 @@ module PDK::CLI
12
12
  def self.transform_value(type_name, value)
13
13
  normalized_name = type_name.downcase.strip
14
14
  unless ALLOWED_TYPE_NAMES.include?(normalized_name)
15
- raise PDK::CLI::ExitWithError, _('Unknown type %{type_name}. Expected one of %{allowed}') % { type_name: type_name, allowed: pretty_allowed_names }
15
+ raise PDK::CLI::ExitWithError, 'Unknown type %{type_name}. Expected one of %{allowed}' % { type_name: type_name, allowed: pretty_allowed_names }
16
16
  end
17
17
 
18
18
  # Short circuit string conversions as it's trivial
19
19
  if normalized_name == 'string'
20
- raise PDK::CLI::ExitWithError, _('An error occured converting \'%{value}\' into a %{type_name}') % { value: value.nil? ? 'nil' : value, type_name: type_name } unless value.is_a?(String)
20
+ raise PDK::CLI::ExitWithError, 'An error occured converting \'%{value}\' into a %{type_name}' % { value: value.nil? ? 'nil' : value, type_name: type_name } unless value.is_a?(String)
21
21
  return value
22
22
  end
23
23
 
@@ -33,7 +33,7 @@ module PDK::CLI
33
33
  value
34
34
  end
35
35
  rescue ArgumentError, TypeError
36
- raise PDK::CLI::ExitWithError, _('An error occured converting \'%{value}\' into a %{type_name}') % { value: value.nil? ? 'nil' : value, type_name: type_name }
36
+ raise PDK::CLI::ExitWithError, 'An error occured converting \'%{value}\' into a %{type_name}' % { value: value.nil? ? 'nil' : value, type_name: type_name }
37
37
  end
38
38
  end
39
39
 
@@ -70,33 +70,33 @@ module PDK::CLI
70
70
  # Transform the value if we need to
71
71
  item_value = PDK::CLI::Set::Config.transform_value(opts[:type], item_value) unless opts[:type].nil?
72
72
 
73
- raise PDK::CLI::ExitWithError, _('Configuration name is required') if item_name.nil?
74
- raise PDK::CLI::ExitWithError, _('Configuration value is required. If you wish to remove a value use \'pdk remove config\'') if item_value.nil?
73
+ raise PDK::CLI::ExitWithError, 'Configuration name is required' if item_name.nil?
74
+ raise PDK::CLI::ExitWithError, 'Configuration value is required. If you wish to remove a value use \'pdk remove config\'' if item_value.nil?
75
75
 
76
76
  current_value = PDK.config.get(item_name)
77
- raise PDK::CLI::ExitWithError, _("The configuration item '%{name}' can not have a value set.") % { name: item_name } if current_value.is_a?(PDK::Config::Namespace)
77
+ raise PDK::CLI::ExitWithError, "The configuration item '%{name}' can not have a value set." % { name: item_name } if current_value.is_a?(PDK::Config::Namespace)
78
78
 
79
79
  # If we're forcing the value, don't do any munging
80
80
  unless force
81
81
  # Check if the setting already exists
82
82
  if current_value.is_a?(Array) && current_value.include?(item_value)
83
- PDK.logger.info(_("No changes made to '%{name}' as it already contains value '%{to}'") % { name: item_name, to: item_value })
83
+ PDK.logger.info("No changes made to '%{name}' as it already contains value '%{to}'" % { name: item_name, to: item_value })
84
84
  return 0
85
85
  end
86
86
  end
87
87
 
88
88
  new_value = PDK.config.set(item_name, item_value, force: opts[:force])
89
89
  if current_value.nil? || force
90
- PDK.logger.info(_("Set initial value of '%{name}' to '%{to}'") % { name: item_name, to: new_value })
90
+ PDK.logger.info("Set initial value of '%{name}' to '%{to}'" % { name: item_name, to: new_value })
91
91
  elsif current_value.is_a?(Array)
92
92
  # Arrays have a special output format
93
- PDK.logger.info(_("Added new value '%{to}' to '%{name}'") % { name: item_name, to: item_value })
93
+ PDK.logger.info("Added new value '%{to}' to '%{name}'" % { name: item_name, to: item_value })
94
94
  else
95
- PDK.logger.info(_("Changed existing value of '%{name}' from '%{from}' to '%{to}'") % { name: item_name, from: current_value, to: new_value })
95
+ PDK.logger.info("Changed existing value of '%{name}' from '%{from}' to '%{to}'" % { name: item_name, from: current_value, to: new_value })
96
96
  end
97
97
 
98
98
  # Same output as `get config`
99
- $stdout.puts _('%{name}=%{value}') % { name: item_name, value: PDK.config.get(item_name) }
99
+ $stdout.puts '%{name}=%{value}' % { name: item_name, value: PDK.config.get(item_name) }
100
100
  0
101
101
  end
102
102
  end
@@ -104,13 +104,13 @@ module PDK::CLI
104
104
 
105
105
  @set_config_cmd = @set_cmd.define_command do
106
106
  name 'config'
107
- usage _('config [name] [value]')
108
- summary _('Set or update the configuration for <name>')
107
+ usage 'config [name] [value]'
108
+ summary 'Set or update the configuration for <name>'
109
109
 
110
- option :f, :force, _('Force the configuration setting to be overwitten.'), argument: :forbidden
110
+ option :f, :force, 'Force the configuration setting to be overwitten.', argument: :forbidden
111
111
 
112
- option :t, :type, _('The type of value to set. Acceptable values: %{values}') % { values: PDK::CLI::Set::Config.pretty_allowed_names }, argument: :required
113
- option nil, :as, _('Alias of --type'), argument: :required
112
+ option :t, :type, 'The type of value to set. Acceptable values: %{values}' % { values: PDK::CLI::Set::Config.pretty_allowed_names }, argument: :required
113
+ option nil, :as, 'Alias of --type', argument: :required
114
114
 
115
115
  run do |opts, args, _cmd|
116
116
  exit PDK::CLI::Set::Config.run(opts, args)
data/lib/pdk/cli/set.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module PDK::CLI
2
2
  @set_cmd = @base_cmd.define_command do
3
3
  name 'set'
4
- usage _('set [subcommand] [options]')
5
- summary _('Set or update information about the PDK or current project.')
4
+ usage 'set [subcommand] [options]'
5
+ summary 'Set or update information about the PDK or current project.'
6
6
  default_subcommand 'help'
7
7
 
8
8
  run do |_opts, args, _cmd|
@@ -1,23 +1,23 @@
1
1
  module PDK::CLI
2
2
  @test_unit_cmd = @test_cmd.define_command do
3
3
  name 'unit'
4
- usage _('unit [options]')
5
- summary _('Run unit tests.')
4
+ usage 'unit [options]'
5
+ summary 'Run unit tests.'
6
6
 
7
7
  PDK::CLI.puppet_version_options(self)
8
8
  PDK::CLI.puppet_dev_option(self)
9
- flag nil, :list, _('List all available unit test files.')
10
- flag nil, :parallel, _('Run unit tests in parallel.')
11
- flag :v, :verbose, _('More verbose --list output. Displays a list of examples in each unit test file.')
12
- flag :c, 'clean-fixtures', _('Clean up downloaded fixtures after the test run.')
9
+ flag nil, :list, 'List all available unit test files.'
10
+ flag nil, :parallel, 'Run unit tests in parallel.'
11
+ flag :v, :verbose, 'More verbose --list output. Displays a list of examples in each unit test file.'
12
+ flag :c, 'clean-fixtures', 'Clean up downloaded fixtures after the test run.'
13
13
 
14
- option nil, :tests, _('Specify a comma-separated list of unit test files to run.'), argument: :required, default: '' do |values|
14
+ option nil, :tests, 'Specify a comma-separated list of unit test files to run.', argument: :required, default: '' do |values|
15
15
  require 'pdk/cli/util/option_validator'
16
16
  PDK::CLI::Util::OptionValidator.comma_separated_list?(values)
17
17
  end
18
18
 
19
19
  # TODO
20
- # option nil, :runner_options, _("options to pass through to the actual test-runner"), argument: :required
20
+ # option nil, :runner_options, "options to pass through to the actual test-runner", argument: :required
21
21
 
22
22
  run do |opts, _args, _cmd|
23
23
  require 'pdk/tests/unit'
@@ -27,7 +27,7 @@ module PDK::CLI
27
27
  PDK::CLI::Util.validate_puppet_version_opts(opts)
28
28
 
29
29
  PDK::CLI::Util.ensure_in_module!(
30
- message: _('Unit tests can only be run from inside a valid module directory.'),
30
+ message: 'Unit tests can only be run from inside a valid module directory.',
31
31
  log_level: :info,
32
32
  )
33
33
 
@@ -49,18 +49,18 @@ module PDK::CLI
49
49
  examples = PDK::Test::Unit.list(opts)
50
50
 
51
51
  if examples.empty?
52
- puts _('No unit test files with examples were found.')
52
+ puts 'No unit test files with examples were found.'
53
53
  else
54
- puts _('Unit Test Files:')
54
+ puts 'Unit Test Files:'
55
55
  files = examples.map { |example| example[:file_path] }
56
56
  files.uniq.each do |file|
57
- puts _(file)
57
+ puts file
58
58
 
59
59
  next unless opts[:verbose]
60
60
 
61
61
  file_examples = examples.select { |example| example[:file_path] == file }
62
62
  file_examples.each do |file_example|
63
- puts _("\t%{id}\t%{description}" % { id: file_example[:id], description: file_example[:full_description] })
63
+ puts "\t%{id}\t%{description}" % { id: file_example[:id], description: file_example[:full_description] }
64
64
  end
65
65
  end
66
66
  end
data/lib/pdk/cli/test.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module PDK::CLI
2
2
  @test_cmd = @base_cmd.define_command do
3
3
  name 'test'
4
- usage _('test [subcommand] [options]')
5
- summary _('Run tests.')
4
+ usage 'test [subcommand] [options]'
5
+ summary 'Run tests.'
6
6
  default_subcommand 'help'
7
7
  end
8
8
  @test_cmd.add_command Cri::Command.new_basic_help
@@ -1,11 +1,11 @@
1
1
  module PDK::CLI
2
2
  @update_cmd = @base_cmd.define_command do
3
3
  name 'update'
4
- usage _('update [options]')
5
- summary _('Update a module that has been created by or converted for use by PDK.')
4
+ usage 'update [options]'
5
+ summary 'Update a module that has been created by or converted for use by PDK.'
6
6
 
7
- flag nil, :noop, _('Do not update the module, just output what would be done.')
8
- flag nil, :force, _('Update the module automatically, with no prompts.')
7
+ flag nil, :noop, 'Do not update the module, just output what would be done.'
8
+ flag nil, :force, 'Update the module automatically, with no prompts.'
9
9
 
10
10
  PDK::CLI.template_ref_option(self)
11
11
 
@@ -14,31 +14,23 @@ module PDK::CLI
14
14
  PDK.context.to_debug_log
15
15
 
16
16
  unless PDK.context.is_a?(PDK::Context::Module)
17
- raise PDK::CLI::ExitWithError, _('`pdk update` can only be run from inside a valid module directory.')
17
+ raise PDK::CLI::ExitWithError, '`pdk update` can only be run from inside a valid module directory.'
18
18
  end
19
19
 
20
- raise PDK::CLI::ExitWithError, _('This module does not appear to be PDK compatible. To make the module compatible with PDK, run `pdk convert`.') unless PDK::Util.module_pdk_compatible?
20
+ raise PDK::CLI::ExitWithError, 'This module does not appear to be PDK compatible. To make the module compatible with PDK, run `pdk convert`.' unless PDK::Util.module_pdk_compatible?
21
21
 
22
22
  if opts[:noop] && opts[:force]
23
- raise PDK::CLI::ExitWithError, _('You can not specify --noop and --force when updating a module')
23
+ raise PDK::CLI::ExitWithError, 'You can not specify --noop and --force when updating a module'
24
24
  end
25
25
 
26
26
  if Gem::Version.new(PDK::VERSION) < Gem::Version.new(PDK::Util.module_pdk_version)
27
- PDK.logger.warn _(
28
- 'This module has been updated to PDK %{module_pdk_version} which ' \
29
- 'is newer than your PDK version (%{user_pdk_version}), proceed ' \
30
- 'with caution!',
31
- ) % {
32
- module_pdk_version: PDK::Util.module_pdk_version,
33
- user_pdk_version: PDK::VERSION,
34
- }
27
+ PDK.logger.warn "This module has been updated to PDK #{PDK::Util.module_pdk_version} which is newer than your PDK version (#{PDK::VERSION}), proceed with caution!"
35
28
 
36
29
  unless opts[:force]
37
- raise PDK::CLI::ExitWithError, _(
38
- 'Please update your PDK installation and try again. ' \
39
- 'You may also use the --force flag to override this and ' \
40
- 'continue at your own risk.',
41
- )
30
+ raise PDK::CLI::ExitWithError,
31
+ 'Please update your PDK installation and try again. ' \
32
+ 'You may also use the --force flag to override this and ' \
33
+ 'continue at your own risk.'
42
34
  end
43
35
  end
44
36
 
@@ -47,15 +39,13 @@ module PDK::CLI
47
39
  updater = PDK::Module::Update.new(PDK.context.root_path, opts)
48
40
 
49
41
  if updater.pinned_to_puppetlabs_template_tag?
50
- PDK.logger.info _(
51
- 'This module is currently pinned to version %{current_version} ' \
52
- 'of the default template. If you would like to update your ' \
53
- 'module to the latest version of the template, please run `pdk ' \
54
- 'update --template-ref %{new_version}`.',
55
- ) % {
56
- current_version: updater.template_uri.uri_fragment,
57
- new_version: PDK::TEMPLATE_REF,
58
- }
42
+ PDK.logger.info 'This module is currently pinned to version %{current_version} ' \
43
+ 'of the default template. If you would like to update your ' \
44
+ 'module to the latest version of the template, please run `pdk ' \
45
+ 'update --template-ref %{new_version}`.' % {
46
+ current_version: updater.template_uri.uri_fragment,
47
+ new_version: PDK::TEMPLATE_REF,
48
+ }
59
49
  end
60
50
 
61
51
  updater.run
@@ -16,7 +16,7 @@ module PDK
16
16
  end
17
17
 
18
18
  def run
19
- @prompt.puts _('Did you mean \'%{command}\'?') % { command: pastel.bold(@command) }
19
+ @prompt.puts 'Did you mean \'%{command}\'?' % { command: pastel.bold(@command) }
20
20
  @prompt.yes?('-->')
21
21
  rescue PDK::CLI::Util::Interview::READER::InputInterrupt
22
22
  nil
@@ -30,17 +30,17 @@ module PDK
30
30
  num_questions = @questions.count
31
31
  @questions.each do |question_name, question|
32
32
  @name = question_name
33
- @prompt.print pastel.bold(_('[Q %{current_number}/%{questions_total}]') % { current_number: i, questions_total: num_questions }) + ' '
33
+ @prompt.print pastel.bold('[Q %{current_number}/%{questions_total}]' % { current_number: i, questions_total: num_questions }) + ' '
34
34
  @prompt.puts pastel.bold(question[:question])
35
35
  @prompt.puts question[:help] if question.key?(:help)
36
36
 
37
37
  case question[:type]
38
38
  when :yes
39
- yes?(_('-->')) do |q|
39
+ yes?('-->') do |q|
40
40
  q.default(question[:default]) if question.key?(:default)
41
41
  end
42
42
  when :multi_select
43
- multi_select(_('-->'), per_page: question[:choices].count) do |q|
43
+ multi_select('-->', per_page: question[:choices].count) do |q|
44
44
  q.enum ')'
45
45
  q.default(*question[:default]) if question.key?(:default)
46
46
 
@@ -49,7 +49,7 @@ module PDK
49
49
  end
50
50
  end
51
51
  else
52
- ask(_('-->')) do |q|
52
+ ask('-->') do |q|
53
53
  q.required(question.fetch(:required, false))
54
54
 
55
55
  if question.key?(:validate_pattern)
@@ -5,7 +5,7 @@ module PDK
5
5
  module Util
6
6
  class OptionNormalizer
7
7
  def self.comma_separated_list_to_array(list, _options = {})
8
- raise _('Error: expected comma separated list') unless OptionValidator.comma_separated_list?(list)
8
+ raise 'Error: expected comma separated list' unless OptionValidator.comma_separated_list?(list)
9
9
  list.split(',').compact
10
10
  end
11
11
 
@@ -31,7 +31,7 @@ module PDK
31
31
  begin
32
32
  OptionValidator.enum(format, PDK::Report.formats)
33
33
  rescue ArgumentError
34
- raise PDK::CLI::ExitWithError, _("'%{name}' is not a valid report format (%{valid})") % {
34
+ raise PDK::CLI::ExitWithError, "'%{name}' is not a valid report format (%{valid})" % {
35
35
  name: format,
36
36
  valid: PDK::Report.formats.join(', '),
37
37
  }
@@ -18,7 +18,7 @@ module PDK
18
18
  invalid_entries = vals.reject { |e| valid_entries.include?(e) }
19
19
 
20
20
  unless invalid_entries.empty?
21
- raise ArgumentError, _('Error: the following values are invalid: %{invalid_entries}') % { invalid_entries: invalid_entries }
21
+ raise ArgumentError, 'Error: the following values are invalid: %{invalid_entries}' % { invalid_entries: invalid_entries }
22
22
  end
23
23
 
24
24
  val
data/lib/pdk/cli/util.rb CHANGED
@@ -23,7 +23,7 @@ module PDK
23
23
  return unless PDK::Util.module_root.nil?
24
24
  return if opts[:check_module_layout] && PDK::Util.in_module_root?
25
25
 
26
- message = opts.fetch(:message, _('This command must be run from inside a valid module (no metadata.json found).'))
26
+ message = opts.fetch(:message, 'This command must be run from inside a valid module (no metadata.json found).')
27
27
  raise PDK::CLI::ExitWithError.new(message, opts)
28
28
  end
29
29
  module_function :ensure_in_module!
@@ -49,7 +49,7 @@ module PDK
49
49
  begin
50
50
  response = prompt.yes?(question_text) do |q|
51
51
  q.default opts[:default] unless opts[:default].nil?
52
- q.validate(validator, _('Answer "Y" to continue or "n" to cancel.'))
52
+ q.validate(validator, 'Answer "Y" to continue or "n" to cancel.')
53
53
  end
54
54
  rescue PDK::CLI::Util::Interview::READER::InputInterrupt
55
55
  PDK.logger.info opts[:cancel_message] if opts[:cancel_message]
@@ -96,22 +96,22 @@ module PDK
96
96
 
97
97
  # This means the module does not have a pdk-version tag in the metadata.json
98
98
  # and will require a pdk convert.
99
- raise PDK::CLI::ExitWithError, _('This module is not PDK compatible. Run `pdk convert` to make it compatible with your version of PDK.') if module_pdk_ver.nil?
99
+ raise PDK::CLI::ExitWithError, 'This module is not PDK compatible. Run `pdk convert` to make it compatible with your version of PDK.' if module_pdk_ver.nil?
100
100
 
101
101
  # This checks that the version of pdk in the module's metadata is older
102
102
  # than 1.3.1, which means the module will need to run pdk convert to the
103
103
  # new templates.
104
104
  if Gem::Version.new(module_pdk_ver) < Gem::Version.new('1.3.1')
105
- PDK.logger.warn _('This module template is out of date. Run `pdk convert` to make it compatible with your version of PDK.')
105
+ PDK.logger.warn 'This module template is out of date. Run `pdk convert` to make it compatible with your version of PDK.'
106
106
  # This checks if the version of the installed PDK is older than the
107
107
  # version in the module's metadata, and advises the user to upgrade to
108
108
  # their install of PDK.
109
109
  elsif Gem::Version.new(PDK::VERSION) < Gem::Version.new(module_pdk_ver)
110
- PDK.logger.warn _('This module is compatible with a newer version of PDK. Upgrade your version of PDK to ensure compatibility.')
110
+ PDK.logger.warn 'This module is compatible with a newer version of PDK. Upgrade your version of PDK to ensure compatibility.'
111
111
  # This checks if the version listed in the module's metadata is older
112
112
  # than the installed PDK, and advises the user to run pdk update.
113
113
  elsif Gem::Version.new(PDK::VERSION) > Gem::Version.new(module_pdk_ver)
114
- PDK.logger.warn _('This module is compatible with an older version of PDK. Run `pdk update` to update it to your version of PDK.')
114
+ PDK.logger.warn 'This module is compatible with an older version of PDK. Run `pdk update` to update it to your version of PDK.'
115
115
  end
116
116
  end
117
117
  module_function :module_version_check
@@ -122,10 +122,9 @@ module PDK
122
122
  deprecated_below = Gem::Version.new('5.0.0')
123
123
  return unless version < deprecated_below
124
124
 
125
- deprecated_msg = _(
125
+ deprecated_msg =
126
126
  'Support for Puppet versions older than %{version} is ' \
127
- 'deprecated and will be removed in a future version of PDK.',
128
- ) % { version: deprecated_below.to_s }
127
+ 'deprecated and will be removed in a future version of PDK.' % { version: deprecated_below.to_s }
129
128
  PDK.logger.warn(deprecated_msg)
130
129
  end
131
130
  module_function :check_for_deprecated_puppet
@@ -163,7 +162,7 @@ module PDK
163
162
 
164
163
  # Notify user of what Ruby version will be used.
165
164
  unless logging_disabled
166
- PDK.logger.info(_('Using Ruby %{version}') % {
165
+ PDK.logger.info('Using Ruby %{version}' % {
167
166
  version: puppet_env[:ruby_version],
168
167
  })
169
168
  end
@@ -177,7 +176,7 @@ module PDK
177
176
  gemset.each do |gem, version|
178
177
  next if version.nil?
179
178
 
180
- PDK.logger.info(_('Using %{gem} %{version}') % {
179
+ PDK.logger.info('Using %{gem} %{version}' % {
181
180
  gem: gem.to_s.capitalize,
182
181
  version: version,
183
182
  })
@@ -208,7 +207,7 @@ module PDK
208
207
  [puppet_ver_specs, pe_ver_specs].each do |offending|
209
208
  next if offending.empty?
210
209
 
211
- raise PDK::CLI::ExitWithError, _('You cannot specify a %{first} and %{second} at the same time.') % {
210
+ raise PDK::CLI::ExitWithError, 'You cannot specify a %{first} and %{second} at the same time.' % {
212
211
  first: pup_dev_spec,
213
212
  second: offending.first,
214
213
  }
@@ -220,7 +219,7 @@ module PDK
220
219
 
221
220
  offending = [pup_ver_spec, pe_ver_specs[0]].sort
222
221
 
223
- raise PDK::CLI::ExitWithError, _('You cannot specify a %{first} and %{second} at the same time.') % {
222
+ raise PDK::CLI::ExitWithError, 'You cannot specify a %{first} and %{second} at the same time.' % {
224
223
  first: offending[0],
225
224
  second: offending[1],
226
225
  }
@@ -230,7 +229,7 @@ module PDK
230
229
  warning_str = 'Puppet dev flag from command line: "--puppet-dev" '
231
230
  warning_str += 'overrides value from environment: "PDK_PUPPET_DEV=true". You should not specify both.'
232
231
 
233
- PDK.logger.warn(_(warning_str) % {
232
+ PDK.logger.warn(warning_str % {
234
233
  pup_ver_opt: opts[:'puppet-dev'],
235
234
  pup_ver_env: PDK::Util::Env['PDK_PUPPET_DEV'],
236
235
  })
@@ -238,7 +237,7 @@ module PDK
238
237
  warning_str = 'Puppet version option from command line: "--puppet-version=%{pup_ver_opt}" '
239
238
  warning_str += 'overrides value from environment: "PDK_PUPPET_VERSION=%{pup_ver_env}". You should not specify both.'
240
239
 
241
- PDK.logger.warn(_(warning_str) % {
240
+ PDK.logger.warn(warning_str % {
242
241
  pup_ver_opt: opts[:'puppet-version'],
243
242
  pup_ver_env: PDK::Util::Env['PDK_PUPPET_VERSION'],
244
243
  })
@@ -246,9 +245,9 @@ module PDK
246
245
  warning_str = 'Puppet Enterprise version option from command line: "--pe-version=%{pe_ver_opt}" '
247
246
  warning_str += 'overrides value from environment: "PDK_PE_VERSION=%{pe_ver_env}". You should not specify both.'
248
247
 
249
- PDK.logger.warn(_(warning_str) % {
250
- pup_ver_opt: opts[:'pe-version'],
251
- pup_ver_env: PDK::Util::Env['PDK_PE_VERSION'],
248
+ PDK.logger.warn(warning_str % {
249
+ pe_ver_opt: opts[:'pe-version'],
250
+ pe_ver_env: PDK::Util::Env['PDK_PE_VERSION'],
252
251
  })
253
252
  end
254
253
  end
@@ -256,11 +255,11 @@ module PDK
256
255
 
257
256
  def validate_template_opts(opts)
258
257
  if opts[:'template-ref'] && opts[:'template-url'].nil?
259
- raise PDK::CLI::ExitWithError, _('--template-ref requires --template-url to also be specified.')
258
+ raise PDK::CLI::ExitWithError, '--template-ref requires --template-url to also be specified.'
260
259
  end
261
260
 
262
261
  return unless opts[:'template-url'] && opts[:'template-url'].include?('#')
263
- raise PDK::CLI::ExitWithError, _('--template-url may not be used to specify paths containing #\'s.')
262
+ raise PDK::CLI::ExitWithError, '--template-url may not be used to specify paths containing #\'s.'
264
263
  end
265
264
  module_function :validate_template_opts
266
265
 
@@ -1,22 +1,20 @@
1
1
  module PDK::CLI
2
2
  @validate_cmd = @base_cmd.define_command do
3
3
  name 'validate'
4
- usage _('validate [validators] [options] [targets]')
5
- summary _('Run static analysis tests.')
6
- description _(
7
- "Run metadata, YAML, Puppet, Ruby, or Tasks validation.\n\n" \
8
- '[validators] is an optional comma-separated list of validators to use. ' \
9
- 'If not specified, all validators are used. ' \
10
- "Note that when using PowerShell, the list of validators must be enclosed in single quotes.\n\n" \
11
- '[targets] is an optional space-separated list of files or directories to be validated. ' \
12
- 'If not specified, validators are run against all applicable files in the module.',
13
- )
4
+ usage 'validate [validators] [options] [targets]'
5
+ summary 'Run static analysis tests.'
6
+ description "Run metadata, YAML, Puppet, Ruby, or Tasks validation.\n\n" \
7
+ '[validators] is an optional comma-separated list of validators to use. ' \
8
+ 'If not specified, all validators are used. ' \
9
+ "Note that when using PowerShell, the list of validators must be enclosed in single quotes.\n\n" \
10
+ '[targets] is an optional space-separated list of files or directories to be validated. ' \
11
+ 'If not specified, validators are run against all applicable files in the module.'
14
12
 
15
13
  PDK::CLI.puppet_version_options(self)
16
14
  PDK::CLI.puppet_dev_option(self)
17
- flag nil, :list, _('List all available validators.')
18
- flag :a, 'auto-correct', _('Automatically correct problems where possible.')
19
- flag nil, :parallel, _('Run validations in parallel.')
15
+ flag nil, :list, 'List all available validators.'
16
+ flag :a, 'auto-correct', 'Automatically correct problems where possible.'
17
+ flag nil, :parallel, 'Run validations in parallel.'
20
18
 
21
19
  run do |opts, args, _cmd|
22
20
  # Write the context information to the debug log
@@ -31,13 +29,13 @@ module PDK::CLI
31
29
 
32
30
  if opts[:list]
33
31
  PDK::CLI::Util.analytics_screen_view('validate', opts)
34
- PDK.logger.info(_('Available validators: %{validator_names}') % { validator_names: PDK::Validate.validator_names.join(', ') })
32
+ PDK.logger.info('Available validators: %{validator_names}' % { validator_names: PDK::Validate.validator_names.join(', ') })
35
33
  exit 0
36
34
  end
37
35
 
38
36
  PDK::CLI::Util.validate_puppet_version_opts(opts)
39
37
  unless PDK.feature_flag?('controlrepo') || PDK.context.is_a?(PDK::Context::Module)
40
- raise PDK::CLI::ExitWithError.new(_('Code validation can only be run from inside a valid module directory'), log_level: :error)
38
+ raise PDK::CLI::ExitWithError.new('Code validation can only be run from inside a valid module directory', log_level: :error)
41
39
  end
42
40
 
43
41
  PDK::CLI::Util.module_version_check if PDK.context.is_a?(PDK::Context::Module)
@@ -58,7 +56,7 @@ module PDK::CLI
58
56
 
59
57
  vals.reject { |v| PDK::Validate.validator_names.include?(v) }
60
58
  .each do |v|
61
- PDK.logger.warn(_("Unknown validator '%{v}'. Available validators: %{validators}.") % { v: v, validators: PDK::Validate.validator_names.join(', ') })
59
+ PDK.logger.warn("Unknown validator '%{v}'. Available validators: %{validators}." % { v: v, validators: PDK::Validate.validator_names.join(', ') })
62
60
  end
63
61
  else
64
62
  # This is a single item. Check if it's a known validator, or otherwise treat it as a target.
@@ -68,11 +66,11 @@ module PDK::CLI
68
66
  else
69
67
  targets = [args[0]]
70
68
  # We now know that no validators were passed, so let the user know we're using all of them by default.
71
- PDK.logger.info(_('Running all available validators...'))
69
+ PDK.logger.info('Running all available validators...')
72
70
  end
73
71
  end
74
72
  else
75
- PDK.logger.info(_('Running all available validators...'))
73
+ PDK.logger.info('Running all available validators...')
76
74
  end
77
75
  validators_to_run = PDK::Validate.validator_names if validators_to_run.nil?
78
76