Sha256: 504dd931ec350f3ca2e4a763f2352c825ad860460c64162dd3ae3738b56efa3c
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'pdk' require 'pdk/util' require 'pdk/cli/exec' require 'pdk/validators/base_validator' module PDK module Validate class PuppetLint < BaseValidator def self.name 'puppet-lint' end def self.cmd 'puppet-lint' end def self.pattern '**/*.pp' end def self.spinner_text _('Checking Puppet manifest style') end def self.parse_options(options, targets) cmd_options = ['--json'] cmd_options << '--fix' if options[:auto_correct] cmd_options.concat(targets) end def self.parse_output(report, result, targets) begin json_data = JSON.parse(result[:stdout]) rescue JSON::ParserError json_data = [] end # puppet-lint does not include files without problems in its JSON # output, so we need to go through the list of targets and add passing # events to the report for any target not listed in the JSON output. targets.reject { |target| json_data.any? { |j| j['path'] == target } }.each do |target| report.add_event( file: target, source: 'puppet-lint', severity: 'ok', state: :passed, ) end json_data.each do |offense| report.add_event( file: offense['path'], source: 'puppet-lint', line: offense['line'], column: offense['column'], message: offense['message'], test: offense['check'], severity: (offense['kind'] == 'fixed') ? 'corrected' : offense['kind'], state: :failure, ) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pdk-0.3.0 | lib/pdk/validators/puppet/puppet_lint.rb |