pdk 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1336 -1329
- data/LICENSE +201 -201
- data/README.md +163 -163
- data/exe/pdk +10 -10
- data/lib/pdk/analytics/client/google_analytics.rb +143 -143
- data/lib/pdk/analytics/client/noop.rb +25 -25
- data/lib/pdk/analytics/util.rb +19 -19
- data/lib/pdk/analytics.rb +30 -30
- data/lib/pdk/answer_file.rb +12 -12
- data/lib/pdk/bolt.rb +19 -19
- data/lib/pdk/cli/build.rb +82 -82
- data/lib/pdk/cli/bundle.rb +48 -48
- data/lib/pdk/cli/config/get.rb +26 -26
- data/lib/pdk/cli/config.rb +22 -22
- data/lib/pdk/cli/console.rb +148 -148
- data/lib/pdk/cli/convert.rb +52 -52
- data/lib/pdk/cli/env.rb +52 -52
- data/lib/pdk/cli/errors.rb +25 -25
- data/lib/pdk/cli/exec/command.rb +293 -293
- data/lib/pdk/cli/exec/interactive_command.rb +114 -114
- data/lib/pdk/cli/exec.rb +84 -84
- data/lib/pdk/cli/exec_group.rb +104 -104
- data/lib/pdk/cli/get/config.rb +24 -24
- data/lib/pdk/cli/get.rb +20 -20
- data/lib/pdk/cli/module/build.rb +12 -12
- data/lib/pdk/cli/module/generate.rb +47 -47
- data/lib/pdk/cli/module.rb +14 -14
- data/lib/pdk/cli/new/class.rb +32 -32
- data/lib/pdk/cli/new/defined_type.rb +32 -32
- data/lib/pdk/cli/new/fact.rb +29 -29
- data/lib/pdk/cli/new/function.rb +29 -29
- data/lib/pdk/cli/new/module.rb +53 -53
- data/lib/pdk/cli/new/provider.rb +29 -29
- data/lib/pdk/cli/new/task.rb +34 -34
- data/lib/pdk/cli/new/test.rb +52 -52
- data/lib/pdk/cli/new/transport.rb +27 -27
- data/lib/pdk/cli/new.rb +21 -21
- data/lib/pdk/cli/release/prep.rb +39 -39
- data/lib/pdk/cli/release/publish.rb +50 -50
- data/lib/pdk/cli/release.rb +194 -194
- data/lib/pdk/cli/remove/config.rb +80 -80
- data/lib/pdk/cli/remove.rb +20 -20
- data/lib/pdk/cli/set/config.rb +119 -119
- data/lib/pdk/cli/set.rb +20 -20
- data/lib/pdk/cli/test/unit.rb +90 -90
- data/lib/pdk/cli/test.rb +11 -11
- data/lib/pdk/cli/update.rb +64 -64
- data/lib/pdk/cli/util/command_redirector.rb +27 -27
- data/lib/pdk/cli/util/interview.rb +72 -72
- data/lib/pdk/cli/util/option_normalizer.rb +55 -55
- data/lib/pdk/cli/util/option_validator.rb +68 -68
- data/lib/pdk/cli/util/spinner.rb +13 -13
- data/lib/pdk/cli/util/update_manager_printer.rb +82 -82
- data/lib/pdk/cli/util.rb +305 -305
- data/lib/pdk/cli/validate.rb +116 -116
- data/lib/pdk/cli.rb +175 -175
- data/lib/pdk/config/analytics_schema.json +26 -26
- data/lib/pdk/config/errors.rb +5 -5
- data/lib/pdk/config/ini_file.rb +183 -183
- data/lib/pdk/config/ini_file_setting.rb +39 -39
- data/lib/pdk/config/json.rb +34 -34
- data/lib/pdk/config/json_schema_namespace.rb +142 -142
- data/lib/pdk/config/json_schema_setting.rb +53 -53
- data/lib/pdk/config/json_with_schema.rb +49 -49
- data/lib/pdk/config/namespace.rb +354 -354
- data/lib/pdk/config/setting.rb +135 -135
- data/lib/pdk/config/validator.rb +31 -31
- data/lib/pdk/config/yaml.rb +46 -46
- data/lib/pdk/config/yaml_with_schema.rb +59 -59
- data/lib/pdk/config.rb +390 -390
- data/lib/pdk/context/control_repo.rb +60 -60
- data/lib/pdk/context/module.rb +28 -28
- data/lib/pdk/context/none.rb +22 -22
- data/lib/pdk/context.rb +99 -99
- data/lib/pdk/control_repo.rb +90 -90
- data/lib/pdk/generate/defined_type.rb +43 -43
- data/lib/pdk/generate/fact.rb +25 -25
- data/lib/pdk/generate/function.rb +48 -48
- data/lib/pdk/generate/module.rb +352 -352
- data/lib/pdk/generate/provider.rb +28 -28
- data/lib/pdk/generate/puppet_class.rb +43 -43
- data/lib/pdk/generate/puppet_object.rb +232 -232
- data/lib/pdk/generate/task.rb +68 -68
- data/lib/pdk/generate/transport.rb +33 -33
- data/lib/pdk/generate.rb +24 -24
- data/lib/pdk/i18n.rb +4 -4
- data/lib/pdk/logger.rb +45 -45
- data/lib/pdk/module/build.rb +322 -322
- data/lib/pdk/module/convert.rb +296 -296
- data/lib/pdk/module/metadata.rb +202 -202
- data/lib/pdk/module/release.rb +260 -260
- data/lib/pdk/module/update.rb +131 -131
- data/lib/pdk/module/update_manager.rb +227 -227
- data/lib/pdk/module.rb +30 -30
- data/lib/pdk/report/event.rb +370 -370
- data/lib/pdk/report.rb +121 -121
- data/lib/pdk/template/fetcher/git.rb +85 -85
- data/lib/pdk/template/fetcher/local.rb +28 -28
- data/lib/pdk/template/fetcher.rb +98 -98
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -116
- data/lib/pdk/template/renderer/v1/renderer.rb +132 -132
- data/lib/pdk/template/renderer/v1/template_file.rb +102 -102
- data/lib/pdk/template/renderer/v1.rb +25 -25
- data/lib/pdk/template/renderer.rb +96 -96
- data/lib/pdk/template/template_dir.rb +67 -67
- data/lib/pdk/template.rb +59 -59
- data/lib/pdk/tests/unit.rb +252 -252
- data/lib/pdk/util/bundler.rb +259 -259
- data/lib/pdk/util/changelog_generator.rb +137 -137
- data/lib/pdk/util/env.rb +47 -47
- data/lib/pdk/util/filesystem.rb +138 -138
- data/lib/pdk/util/git.rb +179 -179
- data/lib/pdk/util/json_finder.rb +85 -85
- data/lib/pdk/util/puppet_strings.rb +125 -125
- data/lib/pdk/util/puppet_version.rb +266 -266
- data/lib/pdk/util/ruby_version.rb +179 -179
- data/lib/pdk/util/template_uri.rb +295 -295
- data/lib/pdk/util/vendored_file.rb +93 -93
- data/lib/pdk/util/version.rb +43 -43
- data/lib/pdk/util/windows/api_types.rb +82 -82
- data/lib/pdk/util/windows/file.rb +36 -36
- data/lib/pdk/util/windows/process.rb +79 -79
- data/lib/pdk/util/windows/string.rb +16 -16
- data/lib/pdk/util/windows.rb +15 -15
- data/lib/pdk/util.rb +278 -278
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -23
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -98
- data/lib/pdk/validate/external_command_validator.rb +208 -208
- data/lib/pdk/validate/internal_ruby_validator.rb +100 -100
- data/lib/pdk/validate/invokable_validator.rb +228 -228
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -86
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -78
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -20
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -133
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -66
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -137
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -21
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -80
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -19
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -88
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -50
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -20
- data/lib/pdk/validate/validator.rb +118 -118
- data/lib/pdk/validate/validator_group.rb +104 -104
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -95
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -19
- data/lib/pdk/validate.rb +94 -94
- data/lib/pdk/version.rb +4 -4
- data/lib/pdk.rb +76 -76
- data/locales/config.yaml +21 -21
- data/locales/pdk.pot +2111 -2094
- metadata +3 -3
@@ -1,104 +1,104 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Validate
|
5
|
-
# The base class which should be used by meta-validators, that is, this group executes other validators
|
6
|
-
#
|
7
|
-
# At a minimum, the `name` and `validators` methods should be overridden in the child class
|
8
|
-
#
|
9
|
-
# An example concrete implementation could look like:
|
10
|
-
#
|
11
|
-
# module PDK
|
12
|
-
# module Validate
|
13
|
-
# module Tasks
|
14
|
-
# class TasksValidatorGroup < ValidatorGroup
|
15
|
-
# def name
|
16
|
-
# 'tasks'
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# def validators
|
20
|
-
# [
|
21
|
-
# TasksNameValidator,
|
22
|
-
# TasksMetadataLintValidator,
|
23
|
-
# ].freeze
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
#
|
30
|
-
# @see PDK::Validate::Validator
|
31
|
-
# @abstract
|
32
|
-
class ValidatorGroup < Validator
|
33
|
-
# @see PDK::Validate::Validator.spinner_text
|
34
|
-
def spinner_text
|
35
|
-
_('Running %{name} validators ...') % { name: name }
|
36
|
-
end
|
37
|
-
|
38
|
-
# @see PDK::Validate::Validator.spinner
|
39
|
-
def spinner
|
40
|
-
return nil unless spinners_enabled?
|
41
|
-
return @spinner unless @spinner.nil?
|
42
|
-
require 'pdk/cli/util/spinner'
|
43
|
-
|
44
|
-
@spinner = TTY::Spinner::Multi.new("[:spinner] #{spinner_text}", PDK::CLI::Util.spinner_opts_for_platform)
|
45
|
-
|
46
|
-
# Register the child spinners
|
47
|
-
validator_instances.each do |instance|
|
48
|
-
next if instance.spinner.nil?
|
49
|
-
@spinner.register(instance.spinner)
|
50
|
-
end
|
51
|
-
|
52
|
-
@spinner
|
53
|
-
end
|
54
|
-
|
55
|
-
# Can be overridden by child classes to do their own preparation tasks.
|
56
|
-
# Typically this is not required by a meta-validator though.
|
57
|
-
#
|
58
|
-
# @see PDK::Validate::Validator.prepare_invoke!
|
59
|
-
def prepare_invoke!
|
60
|
-
return if @prepared
|
61
|
-
super
|
62
|
-
|
63
|
-
# Force the spinner to be registered etc.
|
64
|
-
spinner
|
65
|
-
|
66
|
-
# Prepare child validators
|
67
|
-
validator_instances.each { |instance| instance.prepare_invoke! }
|
68
|
-
nil
|
69
|
-
end
|
70
|
-
|
71
|
-
# A list of Validator classes that this group will run
|
72
|
-
# @return Array[Class] An array of Validator classes (or objects that subclass to it) that this group will execute
|
73
|
-
# @abstract
|
74
|
-
def validators
|
75
|
-
[]
|
76
|
-
end
|
77
|
-
|
78
|
-
# @see PDK::Validate::Validator.invoke
|
79
|
-
def invoke(report)
|
80
|
-
exit_code = 0
|
81
|
-
|
82
|
-
prepare_invoke!
|
83
|
-
start_spinner
|
84
|
-
|
85
|
-
validator_instances.each do |instance|
|
86
|
-
exit_code = instance.invoke(report)
|
87
|
-
break if exit_code != 0
|
88
|
-
end
|
89
|
-
|
90
|
-
stop_spinner(exit_code.zero?)
|
91
|
-
|
92
|
-
exit_code
|
93
|
-
end
|
94
|
-
|
95
|
-
# The instanitated PDK::Validator::Validator classes from the `validators` array
|
96
|
-
# @return Array[PDK::Validator::Validator]
|
97
|
-
# @api private
|
98
|
-
def validator_instances
|
99
|
-
@validator_instances ||= validators.map { |klass| klass.new(context, options.merge(parent_validator: self)) }
|
100
|
-
.select { |instance| instance.valid_in_context? }
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Validate
|
5
|
+
# The base class which should be used by meta-validators, that is, this group executes other validators
|
6
|
+
#
|
7
|
+
# At a minimum, the `name` and `validators` methods should be overridden in the child class
|
8
|
+
#
|
9
|
+
# An example concrete implementation could look like:
|
10
|
+
#
|
11
|
+
# module PDK
|
12
|
+
# module Validate
|
13
|
+
# module Tasks
|
14
|
+
# class TasksValidatorGroup < ValidatorGroup
|
15
|
+
# def name
|
16
|
+
# 'tasks'
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def validators
|
20
|
+
# [
|
21
|
+
# TasksNameValidator,
|
22
|
+
# TasksMetadataLintValidator,
|
23
|
+
# ].freeze
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# @see PDK::Validate::Validator
|
31
|
+
# @abstract
|
32
|
+
class ValidatorGroup < Validator
|
33
|
+
# @see PDK::Validate::Validator.spinner_text
|
34
|
+
def spinner_text
|
35
|
+
_('Running %{name} validators ...') % { name: name }
|
36
|
+
end
|
37
|
+
|
38
|
+
# @see PDK::Validate::Validator.spinner
|
39
|
+
def spinner
|
40
|
+
return nil unless spinners_enabled?
|
41
|
+
return @spinner unless @spinner.nil?
|
42
|
+
require 'pdk/cli/util/spinner'
|
43
|
+
|
44
|
+
@spinner = TTY::Spinner::Multi.new("[:spinner] #{spinner_text}", PDK::CLI::Util.spinner_opts_for_platform)
|
45
|
+
|
46
|
+
# Register the child spinners
|
47
|
+
validator_instances.each do |instance|
|
48
|
+
next if instance.spinner.nil?
|
49
|
+
@spinner.register(instance.spinner)
|
50
|
+
end
|
51
|
+
|
52
|
+
@spinner
|
53
|
+
end
|
54
|
+
|
55
|
+
# Can be overridden by child classes to do their own preparation tasks.
|
56
|
+
# Typically this is not required by a meta-validator though.
|
57
|
+
#
|
58
|
+
# @see PDK::Validate::Validator.prepare_invoke!
|
59
|
+
def prepare_invoke!
|
60
|
+
return if @prepared
|
61
|
+
super
|
62
|
+
|
63
|
+
# Force the spinner to be registered etc.
|
64
|
+
spinner
|
65
|
+
|
66
|
+
# Prepare child validators
|
67
|
+
validator_instances.each { |instance| instance.prepare_invoke! }
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
# A list of Validator classes that this group will run
|
72
|
+
# @return Array[Class] An array of Validator classes (or objects that subclass to it) that this group will execute
|
73
|
+
# @abstract
|
74
|
+
def validators
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
78
|
+
# @see PDK::Validate::Validator.invoke
|
79
|
+
def invoke(report)
|
80
|
+
exit_code = 0
|
81
|
+
|
82
|
+
prepare_invoke!
|
83
|
+
start_spinner
|
84
|
+
|
85
|
+
validator_instances.each do |instance|
|
86
|
+
exit_code = instance.invoke(report)
|
87
|
+
break if exit_code != 0
|
88
|
+
end
|
89
|
+
|
90
|
+
stop_spinner(exit_code.zero?)
|
91
|
+
|
92
|
+
exit_code
|
93
|
+
end
|
94
|
+
|
95
|
+
# The instanitated PDK::Validator::Validator classes from the `validators` array
|
96
|
+
# @return Array[PDK::Validator::Validator]
|
97
|
+
# @api private
|
98
|
+
def validator_instances
|
99
|
+
@validator_instances ||= validators.map { |klass| klass.new(context, options.merge(parent_validator: self)) }
|
100
|
+
.select { |instance| instance.valid_in_context? }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -1,95 +1,95 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Validate
|
5
|
-
module YAML
|
6
|
-
class YAMLSyntaxValidator < InternalRubyValidator
|
7
|
-
YAML_ALLOWLISTED_CLASSES = [Symbol].freeze
|
8
|
-
|
9
|
-
def ignore_dotfiles
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
'yaml-syntax'
|
15
|
-
end
|
16
|
-
|
17
|
-
def pattern
|
18
|
-
[
|
19
|
-
'**/*.yaml',
|
20
|
-
'**/*.yml',
|
21
|
-
].tap do |pat|
|
22
|
-
if context.is_a?(PDK::Context::ControlRepo)
|
23
|
-
pat.concat(
|
24
|
-
[
|
25
|
-
'**/*.eyaml',
|
26
|
-
'**/*.eyml',
|
27
|
-
],
|
28
|
-
)
|
29
|
-
else
|
30
|
-
pat
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def spinner_text
|
36
|
-
_('Checking YAML syntax (%{patterns}).') % {
|
37
|
-
patterns: pattern.join(' '),
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
def validate_target(report, target)
|
42
|
-
return 0 unless PDK::Util::Filesystem.file?(target)
|
43
|
-
|
44
|
-
unless PDK::Util::Filesystem.readable?(target)
|
45
|
-
report.add_event(
|
46
|
-
file: target,
|
47
|
-
source: name,
|
48
|
-
state: :failure,
|
49
|
-
severity: 'error',
|
50
|
-
message: _('Could not be read.'),
|
51
|
-
)
|
52
|
-
return 1
|
53
|
-
end
|
54
|
-
|
55
|
-
begin
|
56
|
-
::YAML.safe_load(PDK::Util::Filesystem.read_file(target), YAML_ALLOWLISTED_CLASSES, [], true)
|
57
|
-
|
58
|
-
report.add_event(
|
59
|
-
file: target,
|
60
|
-
source: name,
|
61
|
-
state: :passed,
|
62
|
-
severity: 'ok',
|
63
|
-
)
|
64
|
-
return 0
|
65
|
-
rescue Psych::SyntaxError => e
|
66
|
-
report.add_event(
|
67
|
-
file: target,
|
68
|
-
source: name,
|
69
|
-
state: :failure,
|
70
|
-
severity: 'error',
|
71
|
-
line: e.line,
|
72
|
-
column: e.column,
|
73
|
-
message: _('%{problem} %{context}') % {
|
74
|
-
problem: e.problem,
|
75
|
-
context: e.context,
|
76
|
-
},
|
77
|
-
)
|
78
|
-
return 1
|
79
|
-
rescue Psych::DisallowedClass => e
|
80
|
-
report.add_event(
|
81
|
-
file: target,
|
82
|
-
source: name,
|
83
|
-
state: :failure,
|
84
|
-
severity: 'error',
|
85
|
-
message: _('Unsupported class: %{message}') % {
|
86
|
-
message: e.message,
|
87
|
-
},
|
88
|
-
)
|
89
|
-
return 1
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Validate
|
5
|
+
module YAML
|
6
|
+
class YAMLSyntaxValidator < InternalRubyValidator
|
7
|
+
YAML_ALLOWLISTED_CLASSES = [Symbol].freeze
|
8
|
+
|
9
|
+
def ignore_dotfiles
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
'yaml-syntax'
|
15
|
+
end
|
16
|
+
|
17
|
+
def pattern
|
18
|
+
[
|
19
|
+
'**/*.yaml',
|
20
|
+
'**/*.yml',
|
21
|
+
].tap do |pat|
|
22
|
+
if context.is_a?(PDK::Context::ControlRepo)
|
23
|
+
pat.concat(
|
24
|
+
[
|
25
|
+
'**/*.eyaml',
|
26
|
+
'**/*.eyml',
|
27
|
+
],
|
28
|
+
)
|
29
|
+
else
|
30
|
+
pat
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def spinner_text
|
36
|
+
_('Checking YAML syntax (%{patterns}).') % {
|
37
|
+
patterns: pattern.join(' '),
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def validate_target(report, target)
|
42
|
+
return 0 unless PDK::Util::Filesystem.file?(target)
|
43
|
+
|
44
|
+
unless PDK::Util::Filesystem.readable?(target)
|
45
|
+
report.add_event(
|
46
|
+
file: target,
|
47
|
+
source: name,
|
48
|
+
state: :failure,
|
49
|
+
severity: 'error',
|
50
|
+
message: _('Could not be read.'),
|
51
|
+
)
|
52
|
+
return 1
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
::YAML.safe_load(PDK::Util::Filesystem.read_file(target), YAML_ALLOWLISTED_CLASSES, [], true)
|
57
|
+
|
58
|
+
report.add_event(
|
59
|
+
file: target,
|
60
|
+
source: name,
|
61
|
+
state: :passed,
|
62
|
+
severity: 'ok',
|
63
|
+
)
|
64
|
+
return 0
|
65
|
+
rescue Psych::SyntaxError => e
|
66
|
+
report.add_event(
|
67
|
+
file: target,
|
68
|
+
source: name,
|
69
|
+
state: :failure,
|
70
|
+
severity: 'error',
|
71
|
+
line: e.line,
|
72
|
+
column: e.column,
|
73
|
+
message: _('%{problem} %{context}') % {
|
74
|
+
problem: e.problem,
|
75
|
+
context: e.context,
|
76
|
+
},
|
77
|
+
)
|
78
|
+
return 1
|
79
|
+
rescue Psych::DisallowedClass => e
|
80
|
+
report.add_event(
|
81
|
+
file: target,
|
82
|
+
source: name,
|
83
|
+
state: :failure,
|
84
|
+
severity: 'error',
|
85
|
+
message: _('Unsupported class: %{message}') % {
|
86
|
+
message: e.message,
|
87
|
+
},
|
88
|
+
)
|
89
|
+
return 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Validate
|
5
|
-
module YAML
|
6
|
-
class YAMLValidatorGroup < ValidatorGroup
|
7
|
-
def name
|
8
|
-
'yaml'
|
9
|
-
end
|
10
|
-
|
11
|
-
def validators
|
12
|
-
[
|
13
|
-
YAMLSyntaxValidator,
|
14
|
-
].freeze
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Validate
|
5
|
+
module YAML
|
6
|
+
class YAMLValidatorGroup < ValidatorGroup
|
7
|
+
def name
|
8
|
+
'yaml'
|
9
|
+
end
|
10
|
+
|
11
|
+
def validators
|
12
|
+
[
|
13
|
+
YAMLSyntaxValidator,
|
14
|
+
].freeze
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/pdk/validate.rb
CHANGED
@@ -1,94 +1,94 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
|
3
|
-
module PDK
|
4
|
-
module Validate
|
5
|
-
autoload :ExternalCommandValidator, 'pdk/validate/external_command_validator'
|
6
|
-
autoload :InternalRubyValidator, 'pdk/validate/internal_ruby_validator'
|
7
|
-
autoload :InvokableValidator, 'pdk/validate/invokable_validator'
|
8
|
-
autoload :Validator, 'pdk/validate/validator'
|
9
|
-
autoload :ValidatorGroup, 'pdk/validate/validator_group'
|
10
|
-
|
11
|
-
module ControlRepo
|
12
|
-
autoload :ControlRepoValidatorGroup, 'pdk/validate/control_repo/control_repo_validator_group'
|
13
|
-
autoload :EnvironmentConfValidator, 'pdk/validate/control_repo/environment_conf_validator'
|
14
|
-
end
|
15
|
-
|
16
|
-
module Metadata
|
17
|
-
autoload :MetadataJSONLintValidator, 'pdk/validate/metadata/metadata_json_lint_validator'
|
18
|
-
autoload :MetadataSyntaxValidator, 'pdk/validate/metadata/metadata_syntax_validator'
|
19
|
-
autoload :MetadataValidatorGroup, 'pdk/validate/metadata/metadata_validator_group'
|
20
|
-
end
|
21
|
-
|
22
|
-
module Puppet
|
23
|
-
autoload :PuppetEPPValidator, 'pdk/validate/puppet/puppet_epp_validator'
|
24
|
-
autoload :PuppetLintValidator, 'pdk/validate/puppet/puppet_lint_validator'
|
25
|
-
autoload :PuppetSyntaxValidator, 'pdk/validate/puppet/puppet_syntax_validator'
|
26
|
-
autoload :PuppetValidatorGroup, 'pdk/validate/puppet/puppet_validator_group'
|
27
|
-
end
|
28
|
-
|
29
|
-
module Ruby
|
30
|
-
autoload :RubyRubocopValidator, 'pdk/validate/ruby/ruby_rubocop_validator'
|
31
|
-
autoload :RubyValidatorGroup, 'pdk/validate/ruby/ruby_validator_group'
|
32
|
-
end
|
33
|
-
|
34
|
-
module Tasks
|
35
|
-
autoload :TasksMetadataLintValidator, 'pdk/validate/tasks/tasks_metadata_lint_validator'
|
36
|
-
autoload :TasksNameValidator, 'pdk/validate/tasks/tasks_name_validator'
|
37
|
-
autoload :TasksValidatorGroup, 'pdk/validate/tasks/tasks_validator_group'
|
38
|
-
end
|
39
|
-
|
40
|
-
module YAML
|
41
|
-
autoload :YAMLSyntaxValidator, 'pdk/validate/yaml/yaml_syntax_validator'
|
42
|
-
autoload :YAMLValidatorGroup, 'pdk/validate/yaml/yaml_validator_group'
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.validators
|
46
|
-
validator_hash.values
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.validator_names
|
50
|
-
validator_hash.keys
|
51
|
-
end
|
52
|
-
|
53
|
-
# @api private
|
54
|
-
def self.validator_hash
|
55
|
-
# TODO: This isn't the most performant... But with only 6 items, it's fine
|
56
|
-
@validator_hash ||= [
|
57
|
-
ControlRepo::ControlRepoValidatorGroup,
|
58
|
-
Metadata::MetadataValidatorGroup,
|
59
|
-
Puppet::PuppetValidatorGroup,
|
60
|
-
Ruby::RubyValidatorGroup,
|
61
|
-
Tasks::TasksValidatorGroup,
|
62
|
-
YAML::YAMLValidatorGroup,
|
63
|
-
].map { |klass| [klass.new.name, klass] }.to_h.freeze
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.invoke_validators_by_name(context, names, parallel = false, options = {})
|
67
|
-
instances = names.select { |name| validator_names.include?(name) }
|
68
|
-
.map { |name| validator_hash[name].new(context, options) }
|
69
|
-
.select { |instance| instance.valid_in_context? }
|
70
|
-
.each { |instance| instance.prepare_invoke! }
|
71
|
-
report = PDK::Report.new
|
72
|
-
|
73
|
-
# Nothing to validate then nothing to do.
|
74
|
-
return [0, report] if instances.empty?
|
75
|
-
|
76
|
-
require 'pdk/cli/exec_group'
|
77
|
-
exec_group = PDK::CLI::ExecGroup.create(
|
78
|
-
_('Validating module using %{num_of_threads} threads' % { num_of_threads: instances.count }),
|
79
|
-
{ parallel: parallel },
|
80
|
-
options,
|
81
|
-
)
|
82
|
-
|
83
|
-
instances.each do |validator|
|
84
|
-
exec_group.register do
|
85
|
-
validator.invoke(report)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
[exec_group.exit_code, report]
|
90
|
-
end
|
91
|
-
|
92
|
-
class ParseOutputError < StandardError; end
|
93
|
-
end
|
94
|
-
end
|
1
|
+
require 'pdk'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Validate
|
5
|
+
autoload :ExternalCommandValidator, 'pdk/validate/external_command_validator'
|
6
|
+
autoload :InternalRubyValidator, 'pdk/validate/internal_ruby_validator'
|
7
|
+
autoload :InvokableValidator, 'pdk/validate/invokable_validator'
|
8
|
+
autoload :Validator, 'pdk/validate/validator'
|
9
|
+
autoload :ValidatorGroup, 'pdk/validate/validator_group'
|
10
|
+
|
11
|
+
module ControlRepo
|
12
|
+
autoload :ControlRepoValidatorGroup, 'pdk/validate/control_repo/control_repo_validator_group'
|
13
|
+
autoload :EnvironmentConfValidator, 'pdk/validate/control_repo/environment_conf_validator'
|
14
|
+
end
|
15
|
+
|
16
|
+
module Metadata
|
17
|
+
autoload :MetadataJSONLintValidator, 'pdk/validate/metadata/metadata_json_lint_validator'
|
18
|
+
autoload :MetadataSyntaxValidator, 'pdk/validate/metadata/metadata_syntax_validator'
|
19
|
+
autoload :MetadataValidatorGroup, 'pdk/validate/metadata/metadata_validator_group'
|
20
|
+
end
|
21
|
+
|
22
|
+
module Puppet
|
23
|
+
autoload :PuppetEPPValidator, 'pdk/validate/puppet/puppet_epp_validator'
|
24
|
+
autoload :PuppetLintValidator, 'pdk/validate/puppet/puppet_lint_validator'
|
25
|
+
autoload :PuppetSyntaxValidator, 'pdk/validate/puppet/puppet_syntax_validator'
|
26
|
+
autoload :PuppetValidatorGroup, 'pdk/validate/puppet/puppet_validator_group'
|
27
|
+
end
|
28
|
+
|
29
|
+
module Ruby
|
30
|
+
autoload :RubyRubocopValidator, 'pdk/validate/ruby/ruby_rubocop_validator'
|
31
|
+
autoload :RubyValidatorGroup, 'pdk/validate/ruby/ruby_validator_group'
|
32
|
+
end
|
33
|
+
|
34
|
+
module Tasks
|
35
|
+
autoload :TasksMetadataLintValidator, 'pdk/validate/tasks/tasks_metadata_lint_validator'
|
36
|
+
autoload :TasksNameValidator, 'pdk/validate/tasks/tasks_name_validator'
|
37
|
+
autoload :TasksValidatorGroup, 'pdk/validate/tasks/tasks_validator_group'
|
38
|
+
end
|
39
|
+
|
40
|
+
module YAML
|
41
|
+
autoload :YAMLSyntaxValidator, 'pdk/validate/yaml/yaml_syntax_validator'
|
42
|
+
autoload :YAMLValidatorGroup, 'pdk/validate/yaml/yaml_validator_group'
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.validators
|
46
|
+
validator_hash.values
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.validator_names
|
50
|
+
validator_hash.keys
|
51
|
+
end
|
52
|
+
|
53
|
+
# @api private
|
54
|
+
def self.validator_hash
|
55
|
+
# TODO: This isn't the most performant... But with only 6 items, it's fine
|
56
|
+
@validator_hash ||= [
|
57
|
+
ControlRepo::ControlRepoValidatorGroup,
|
58
|
+
Metadata::MetadataValidatorGroup,
|
59
|
+
Puppet::PuppetValidatorGroup,
|
60
|
+
Ruby::RubyValidatorGroup,
|
61
|
+
Tasks::TasksValidatorGroup,
|
62
|
+
YAML::YAMLValidatorGroup,
|
63
|
+
].map { |klass| [klass.new.name, klass] }.to_h.freeze
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.invoke_validators_by_name(context, names, parallel = false, options = {})
|
67
|
+
instances = names.select { |name| validator_names.include?(name) }
|
68
|
+
.map { |name| validator_hash[name].new(context, options) }
|
69
|
+
.select { |instance| instance.valid_in_context? }
|
70
|
+
.each { |instance| instance.prepare_invoke! }
|
71
|
+
report = PDK::Report.new
|
72
|
+
|
73
|
+
# Nothing to validate then nothing to do.
|
74
|
+
return [0, report] if instances.empty?
|
75
|
+
|
76
|
+
require 'pdk/cli/exec_group'
|
77
|
+
exec_group = PDK::CLI::ExecGroup.create(
|
78
|
+
_('Validating module using %{num_of_threads} threads' % { num_of_threads: instances.count }),
|
79
|
+
{ parallel: parallel },
|
80
|
+
options,
|
81
|
+
)
|
82
|
+
|
83
|
+
instances.each do |validator|
|
84
|
+
exec_group.register do
|
85
|
+
validator.invoke(report)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
[exec_group.exit_code, report]
|
90
|
+
end
|
91
|
+
|
92
|
+
class ParseOutputError < StandardError; end
|
93
|
+
end
|
94
|
+
end
|
data/lib/pdk/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module PDK
|
2
|
-
VERSION = '2.
|
3
|
-
TEMPLATE_REF = '2.
|
4
|
-
end
|
1
|
+
module PDK
|
2
|
+
VERSION = '2.5.0'.freeze
|
3
|
+
TEMPLATE_REF = '2.5.0'.freeze
|
4
|
+
end
|