pdk 1.9.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +744 -711
  3. data/README.md +23 -21
  4. data/lib/pdk/answer_file.rb +3 -112
  5. data/lib/pdk/bolt.rb +20 -0
  6. data/lib/pdk/cli/build.rb +51 -54
  7. data/lib/pdk/cli/bundle.rb +33 -29
  8. data/lib/pdk/cli/console.rb +148 -0
  9. data/lib/pdk/cli/convert.rb +46 -37
  10. data/lib/pdk/cli/env.rb +51 -0
  11. data/lib/pdk/cli/errors.rb +4 -3
  12. data/lib/pdk/cli/exec/command.rb +285 -0
  13. data/lib/pdk/cli/exec/interactive_command.rb +109 -0
  14. data/lib/pdk/cli/exec.rb +32 -201
  15. data/lib/pdk/cli/exec_group.rb +79 -43
  16. data/lib/pdk/cli/get/config.rb +26 -0
  17. data/lib/pdk/cli/get.rb +22 -0
  18. data/lib/pdk/cli/new/class.rb +20 -22
  19. data/lib/pdk/cli/new/defined_type.rb +21 -21
  20. data/lib/pdk/cli/new/fact.rb +27 -0
  21. data/lib/pdk/cli/new/function.rb +27 -0
  22. data/lib/pdk/cli/new/module.rb +40 -29
  23. data/lib/pdk/cli/new/provider.rb +18 -18
  24. data/lib/pdk/cli/new/task.rb +23 -22
  25. data/lib/pdk/cli/new/test.rb +52 -0
  26. data/lib/pdk/cli/new/transport.rb +27 -0
  27. data/lib/pdk/cli/new.rb +15 -9
  28. data/lib/pdk/cli/release/prep.rb +39 -0
  29. data/lib/pdk/cli/release/publish.rb +46 -0
  30. data/lib/pdk/cli/release.rb +185 -0
  31. data/lib/pdk/cli/remove/config.rb +83 -0
  32. data/lib/pdk/cli/remove.rb +22 -0
  33. data/lib/pdk/cli/set/config.rb +121 -0
  34. data/lib/pdk/cli/set.rb +22 -0
  35. data/lib/pdk/cli/test/unit.rb +71 -69
  36. data/lib/pdk/cli/test.rb +9 -8
  37. data/lib/pdk/cli/update.rb +38 -21
  38. data/lib/pdk/cli/util/command_redirector.rb +13 -3
  39. data/lib/pdk/cli/util/interview.rb +25 -9
  40. data/lib/pdk/cli/util/option_normalizer.rb +6 -6
  41. data/lib/pdk/cli/util/option_validator.rb +19 -9
  42. data/lib/pdk/cli/util/spinner.rb +13 -0
  43. data/lib/pdk/cli/util/update_manager_printer.rb +82 -0
  44. data/lib/pdk/cli/util.rb +105 -48
  45. data/lib/pdk/cli/validate.rb +96 -111
  46. data/lib/pdk/cli.rb +134 -87
  47. data/lib/pdk/config/errors.rb +5 -0
  48. data/lib/pdk/config/ini_file.rb +184 -0
  49. data/lib/pdk/config/ini_file_setting.rb +35 -0
  50. data/lib/pdk/config/json.rb +35 -0
  51. data/lib/pdk/config/json_schema_namespace.rb +137 -0
  52. data/lib/pdk/config/json_schema_setting.rb +51 -0
  53. data/lib/pdk/config/json_with_schema.rb +47 -0
  54. data/lib/pdk/config/namespace.rb +362 -0
  55. data/lib/pdk/config/setting.rb +134 -0
  56. data/lib/pdk/config/task_schema.json +116 -0
  57. data/lib/pdk/config/validator.rb +31 -0
  58. data/lib/pdk/config/yaml.rb +41 -0
  59. data/lib/pdk/config/yaml_with_schema.rb +51 -0
  60. data/lib/pdk/config.rb +304 -0
  61. data/lib/pdk/context/control_repo.rb +61 -0
  62. data/lib/pdk/context/module.rb +28 -0
  63. data/lib/pdk/context/none.rb +22 -0
  64. data/lib/pdk/context.rb +98 -0
  65. data/lib/pdk/control_repo.rb +89 -0
  66. data/lib/pdk/generate/defined_type.rb +27 -33
  67. data/lib/pdk/generate/fact.rb +26 -0
  68. data/lib/pdk/generate/function.rb +49 -0
  69. data/lib/pdk/generate/module.rb +160 -153
  70. data/lib/pdk/generate/provider.rb +16 -69
  71. data/lib/pdk/generate/puppet_class.rb +27 -32
  72. data/lib/pdk/generate/puppet_object.rb +100 -159
  73. data/lib/pdk/generate/task.rb +34 -51
  74. data/lib/pdk/generate/transport.rb +34 -0
  75. data/lib/pdk/generate.rb +21 -8
  76. data/lib/pdk/logger.rb +24 -6
  77. data/lib/pdk/module/build.rb +125 -37
  78. data/lib/pdk/module/convert.rb +146 -65
  79. data/lib/pdk/module/metadata.rb +72 -71
  80. data/lib/pdk/module/release.rb +255 -0
  81. data/lib/pdk/module/update.rb +48 -37
  82. data/lib/pdk/module/update_manager.rb +75 -39
  83. data/lib/pdk/module.rb +10 -2
  84. data/lib/pdk/monkey_patches.rb +268 -0
  85. data/lib/pdk/report/event.rb +36 -48
  86. data/lib/pdk/report.rb +35 -22
  87. data/lib/pdk/template/fetcher/git.rb +84 -0
  88. data/lib/pdk/template/fetcher/local.rb +29 -0
  89. data/lib/pdk/template/fetcher.rb +100 -0
  90. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +108 -0
  91. data/lib/pdk/template/renderer/v1/renderer.rb +131 -0
  92. data/lib/pdk/template/renderer/v1/template_file.rb +100 -0
  93. data/lib/pdk/template/renderer/v1.rb +25 -0
  94. data/lib/pdk/template/renderer.rb +97 -0
  95. data/lib/pdk/template/template_dir.rb +67 -0
  96. data/lib/pdk/template.rb +52 -0
  97. data/lib/pdk/tests/unit.rb +101 -51
  98. data/lib/pdk/util/bundler.rb +44 -42
  99. data/lib/pdk/util/changelog_generator.rb +138 -0
  100. data/lib/pdk/util/env.rb +48 -0
  101. data/lib/pdk/util/filesystem.rb +139 -2
  102. data/lib/pdk/util/git.rb +108 -8
  103. data/lib/pdk/util/json_finder.rb +86 -0
  104. data/lib/pdk/util/puppet_strings.rb +125 -0
  105. data/lib/pdk/util/puppet_version.rb +71 -87
  106. data/lib/pdk/util/ruby_version.rb +49 -25
  107. data/lib/pdk/util/template_uri.rb +283 -0
  108. data/lib/pdk/util/vendored_file.rb +34 -42
  109. data/lib/pdk/util/version.rb +11 -10
  110. data/lib/pdk/util/windows/api_types.rb +74 -44
  111. data/lib/pdk/util/windows/file.rb +31 -27
  112. data/lib/pdk/util/windows/process.rb +74 -0
  113. data/lib/pdk/util/windows/string.rb +19 -12
  114. data/lib/pdk/util/windows.rb +2 -0
  115. data/lib/pdk/util.rb +111 -124
  116. data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -0
  117. data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -0
  118. data/lib/pdk/validate/external_command_validator.rb +213 -0
  119. data/lib/pdk/validate/internal_ruby_validator.rb +101 -0
  120. data/lib/pdk/validate/invokable_validator.rb +238 -0
  121. data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +84 -0
  122. data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +76 -0
  123. data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -0
  124. data/lib/pdk/validate/puppet/puppet_epp_validator.rb +131 -0
  125. data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -0
  126. data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +38 -0
  127. data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +135 -0
  128. data/lib/pdk/validate/puppet/puppet_validator_group.rb +22 -0
  129. data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +79 -0
  130. data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -0
  131. data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +83 -0
  132. data/lib/pdk/validate/tasks/tasks_name_validator.rb +45 -0
  133. data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -0
  134. data/lib/pdk/validate/validator.rb +120 -0
  135. data/lib/pdk/validate/validator_group.rb +107 -0
  136. data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +86 -0
  137. data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -0
  138. data/lib/pdk/validate.rb +86 -12
  139. data/lib/pdk/version.rb +2 -2
  140. data/lib/pdk.rb +60 -10
  141. metadata +138 -100
  142. data/lib/pdk/cli/module/build.rb +0 -14
  143. data/lib/pdk/cli/module/generate.rb +0 -45
  144. data/lib/pdk/cli/module.rb +0 -14
  145. data/lib/pdk/i18n.rb +0 -4
  146. data/lib/pdk/module/templatedir.rb +0 -321
  147. data/lib/pdk/template_file.rb +0 -95
  148. data/lib/pdk/validate/base_validator.rb +0 -215
  149. data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -86
  150. data/lib/pdk/validate/metadata/metadata_syntax.rb +0 -109
  151. data/lib/pdk/validate/metadata_validator.rb +0 -30
  152. data/lib/pdk/validate/puppet/puppet_lint.rb +0 -67
  153. data/lib/pdk/validate/puppet/puppet_syntax.rb +0 -112
  154. data/lib/pdk/validate/puppet_validator.rb +0 -30
  155. data/lib/pdk/validate/ruby/rubocop.rb +0 -77
  156. data/lib/pdk/validate/ruby_validator.rb +0 -29
  157. data/lib/pdk/validate/tasks/metadata_lint.rb +0 -126
  158. data/lib/pdk/validate/tasks/name.rb +0 -88
  159. data/lib/pdk/validate/tasks_validator.rb +0 -33
  160. data/lib/pdk/validate/yaml/syntax.rb +0 -109
  161. data/lib/pdk/validate/yaml_validator.rb +0 -31
  162. data/locales/config.yaml +0 -21
  163. data/locales/pdk.pot +0 -1291
@@ -1,88 +0,0 @@
1
- require 'pdk'
2
- require 'pdk/validate/base_validator'
3
- require 'pdk/util'
4
-
5
- module PDK
6
- module Validate
7
- class Tasks
8
- class Name < BaseValidator
9
- INVALID_TASK_MSG = _(
10
- 'Invalid task name. Task names must start with a lowercase letter' \
11
- 'and can only contain lowercase letters, numbers, and underscores.',
12
- )
13
-
14
- def self.name
15
- 'task-name'
16
- end
17
-
18
- def self.pattern
19
- 'tasks/**/*'
20
- end
21
-
22
- def self.spinner_text(_targets = [])
23
- _('Checking task names (%{targets}).') % {
24
- targets: pattern,
25
- }
26
- end
27
-
28
- def self.create_spinner(targets = [], options = {})
29
- return unless PDK::CLI::Util.interactive?
30
- options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
31
-
32
- exec_group = options[:exec_group]
33
- @spinner = if exec_group
34
- exec_group.add_spinner(spinner_text(targets), options)
35
- else
36
- TTY::Spinner.new("[:spinner] #{spinner_text(targets)}", options)
37
- end
38
- @spinner.auto_spin
39
- end
40
-
41
- def self.stop_spinner(exit_code)
42
- if exit_code.zero? && @spinner
43
- @spinner.success
44
- elsif @spinner
45
- @spinner.error
46
- end
47
- end
48
-
49
- def self.invoke(report, options = {})
50
- targets, skipped, invalid = parse_targets(options)
51
-
52
- process_skipped(report, skipped)
53
- process_invalid(report, invalid)
54
-
55
- return 0 if targets.empty?
56
-
57
- return_val = 0
58
- create_spinner(targets, options)
59
-
60
- targets.each do |target|
61
- task_name = File.basename(target, File.extname(target))
62
- if PDK::CLI::Util::OptionValidator.valid_task_name?(task_name)
63
- report.add_event(
64
- file: target,
65
- source: name,
66
- state: :passed,
67
- severity: 'ok',
68
- )
69
- else
70
- report.add_event(
71
- file: target,
72
- source: name,
73
- state: :failure,
74
- severity: 'error',
75
- message: INVALID_TASK_MSG,
76
- )
77
-
78
- return_val = 1
79
- end
80
- end
81
-
82
- stop_spinner(return_val)
83
- return_val
84
- end
85
- end
86
- end
87
- end
88
- end
@@ -1,33 +0,0 @@
1
- require 'pdk'
2
- require 'pdk/cli/exec'
3
- require 'pdk/validate/base_validator'
4
- require 'pdk/validate/tasks/metadata_lint'
5
- require 'pdk/validate/tasks/name'
6
-
7
- module PDK
8
- module Validate
9
- class TasksValidator < BaseValidator
10
- def self.name
11
- 'tasks'
12
- end
13
-
14
- def self.metadata_validators
15
- [
16
- Tasks::Name,
17
- Tasks::MetadataLint,
18
- ]
19
- end
20
-
21
- def self.invoke(report, options = {})
22
- exit_code = 0
23
-
24
- metadata_validators.each do |validator|
25
- exit_code = validator.invoke(report, options)
26
- break if exit_code != 0
27
- end
28
-
29
- exit_code
30
- end
31
- end
32
- end
33
- end
@@ -1,109 +0,0 @@
1
- require 'pdk'
2
- require 'pdk/cli/exec'
3
- require 'pdk/validate/base_validator'
4
- require 'pdk/util'
5
- require 'pathname'
6
-
7
- module PDK
8
- module Validate
9
- class YAML
10
- class Syntax < BaseValidator
11
- IGNORE_DOTFILES = false
12
-
13
- def self.name
14
- 'yaml-syntax'
15
- end
16
-
17
- def self.pattern
18
- [
19
- '**/*.yaml',
20
- '*.yaml',
21
- '**/*.yml',
22
- '*.yml',
23
- ]
24
- end
25
-
26
- def self.spinner_text(_targets = [])
27
- _('Checking YAML syntax (%{targets}).') % {
28
- targets: pattern,
29
- }
30
- end
31
-
32
- def self.create_spinner(targets = [], options = {})
33
- return unless PDK::CLI::Util.interactive?
34
- options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
35
-
36
- exec_group = options[:exec_group]
37
- @spinner = if exec_group
38
- exec_group.add_spinner(spinner_text(targets), options)
39
- else
40
- TTY::Spinner.new("[:spinner] #{spinner_text(targets)}", options)
41
- end
42
- @spinner.auto_spin
43
- end
44
-
45
- def self.stop_spinner(exit_code)
46
- if exit_code.zero? && @spinner
47
- @spinner.success
48
- elsif @spinner
49
- @spinner.error
50
- end
51
- end
52
-
53
- def self.invoke(report, options = {})
54
- targets, skipped, invalid = parse_targets(options)
55
-
56
- process_skipped(report, skipped)
57
- process_invalid(report, invalid)
58
-
59
- return 0 if targets.empty?
60
-
61
- return_val = 0
62
- create_spinner(targets, options)
63
-
64
- targets.each do |target|
65
- unless File.readable?(target)
66
- report.add_event(
67
- file: target,
68
- source: name,
69
- state: :failure,
70
- severity: 'error',
71
- message: _('Could not be read.'),
72
- )
73
- return_val = 1
74
- next
75
- end
76
-
77
- begin
78
- ::YAML.safe_load(File.read(target), [], [], true)
79
-
80
- report.add_event(
81
- file: target,
82
- source: name,
83
- state: :passed,
84
- severity: 'ok',
85
- )
86
- rescue Psych::SyntaxError => e
87
- report.add_event(
88
- file: target,
89
- source: name,
90
- state: :failure,
91
- severity: 'error',
92
- line: e.line,
93
- column: e.column,
94
- message: _('%{problem} %{context}') % {
95
- problem: e.problem,
96
- context: e.context,
97
- },
98
- )
99
- return_val = 1
100
- end
101
- end
102
-
103
- stop_spinner(return_val)
104
- return_val
105
- end
106
- end
107
- end
108
- end
109
- end
@@ -1,31 +0,0 @@
1
- require 'pdk'
2
- require 'pdk/cli/exec'
3
- require 'pdk/validate/base_validator'
4
- require 'pdk/validate/yaml/syntax'
5
-
6
- module PDK
7
- module Validate
8
- class YAMLValidator < BaseValidator
9
- def self.name
10
- 'yaml'
11
- end
12
-
13
- def self.validators
14
- [
15
- PDK::Validate::YAML::Syntax,
16
- ]
17
- end
18
-
19
- def self.invoke(report, options = {})
20
- exit_code = 0
21
-
22
- validators.each do |validator|
23
- exit_code = validator.invoke(report, options)
24
- break if exit_code != 0
25
- end
26
-
27
- exit_code
28
- end
29
- end
30
- end
31
- end
data/locales/config.yaml DELETED
@@ -1,21 +0,0 @@
1
- ---
2
- # This is the project-specific configuration file for setting up
3
- # fast_gettext for your project.
4
- gettext:
5
- # This is used for the name of the .pot and .po files; they will be
6
- # called <project_name>.pot?
7
- project_name: 'pdk'
8
- # This is used in comments in the .pot and .po files to indicate what
9
- # project the files belong to and should bea little more desctiptive than
10
- # <project_name>
11
- package_name: puppet development kit
12
- # The locale that the default messages in the .pot file are in
13
- default_locale: en
14
- # The email used for sending bug reports.
15
- bugs_address: docs@puppet.com
16
- # The holder of the copyright.
17
- copyright_holder: Puppet, Inc.
18
- # Patterns for +Dir.glob+ used to find all files that might contain
19
- # translatable content, relative to the project root directory
20
- source_files:
21
- - 'lib/**/*.rb'