Class: PDK::Validate::PuppetLint
Constant Summary
BaseValidator::ALLOW_EMPTY_TARGETS, BaseValidator::INVOKE_STYLE
Class Method Summary
collapse
allow_empty_targets?, cmd_path, ignore_pathspec, invoke, parse_targets, process_invalid, process_skipped
Class Method Details
.cmd ⇒ Object
13
14
15
|
# File 'lib/pdk/validate/puppet/puppet_lint.rb', line 13
def self.cmd
'puppet-lint'
end
|
.name ⇒ Object
9
10
11
|
# File 'lib/pdk/validate/puppet/puppet_lint.rb', line 9
def self.name
'puppet-lint'
end
|
.parse_options(options, targets) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/pdk/validate/puppet/puppet_lint.rb', line 25
def self.parse_options(options, targets)
cmd_options = ['--json', '--relative']
cmd_options << '--fix' if options[:auto_correct]
cmd_options.concat(targets)
end
|
.parse_output(report, result, targets) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/pdk/validate/puppet/puppet_lint.rb', line 33
def self.parse_output(report, result, targets)
begin
json_data = JSON.parse(result[:stdout]).flatten
rescue JSON::ParserError
raise PDK::Validate::ParseOutputError, result[:stdout]
end
targets.reject { |target| json_data.any? { |j| j['path'] == target } }.each do |target|
report.add_event(
file: target,
source: name,
severity: 'ok',
state: :passed,
)
end
json_data.each do |offense|
report.add_event(
file: offense['path'],
source: name,
line: offense['line'],
column: offense['column'],
message: offense['message'],
test: offense['check'],
severity: (offense['kind'] == 'fixed') ? 'corrected' : offense['kind'],
state: :failure,
)
end
end
|
.pattern ⇒ Object
17
18
19
|
# File 'lib/pdk/validate/puppet/puppet_lint.rb', line 17
def self.pattern
'**/*.pp'
end
|
.spinner_text(_targets = nil) ⇒ Object
21
22
23
|
# File 'lib/pdk/validate/puppet/puppet_lint.rb', line 21
def self.spinner_text(_targets = nil)
_('Checking Puppet manifest style (%{pattern}).') % { pattern: pattern }
end
|