Class: PDK::Validate::Puppet::PuppetPlanSyntaxValidator

Inherits:
PuppetSyntaxValidator show all
Defined in:
lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb

Constant Summary

Constants inherited from PuppetSyntaxValidator

PDK::Validate::Puppet::PuppetSyntaxValidator::ERROR_CONTEXT, PDK::Validate::Puppet::PuppetSyntaxValidator::ERROR_CONTEXT_LEGACY, PDK::Validate::Puppet::PuppetSyntaxValidator::PUPPET_LOGGER_PREFIX, PDK::Validate::Puppet::PuppetSyntaxValidator::PUPPET_SYNTAX_PATTERN

Instance Attribute Summary

Attributes inherited from ExternalCommandValidator

#commands

Attributes inherited from Validator

#context, #options, #prepared

Instance Method Summary collapse

Methods inherited from PuppetSyntaxValidator

#cmd, #invoke, #null_file, #parse_offense, #parse_output, #remove_validate_tmpdir, #sanitize_console_output

Methods inherited from ExternalCommandValidator

#alternate_bin_paths, #cmd, #cmd_path, #invoke, #parse_output, #prepare_invoke!, #spinner

Methods inherited from InvokableValidator

#allow_empty_targets?, #fnmatch?, #ignore_dotfiles?, #invoke_style, #parse_targets, #prepare_invoke!, #process_invalid, #process_skipped, #spinner, #spinner_text, #valid_in_context?

Methods inherited from Validator

#initialize, #invoke, #prepare_invoke!, #spinner, #spinner_text, #spinners_enabled?, #start_spinner, #stop_spinner, #valid_in_context?

Constructor Details

This class inherits a constructor from PDK::Validate::Validator

Instance Method Details

#nameObject



7
8
9
# File 'lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb', line 7

def name
  'puppet-plan-syntax'
end

#parse_options(targets) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb', line 21

def parse_options(targets)
  # Due to PDK-1266 we need to run `puppet parser validate` with an empty
  # modulepath. On *nix, Ruby treats `/dev/null` as an empty directory
  # however it doesn't do so with `NUL` on Windows. The workaround for
  # this to ensure consistent behaviour is to create an empty temporary
  # directory and use that as the modulepath.
  ['parser', 'validate', '--tasks', '--config', null_file, '--modulepath', validate_tmpdir].concat(targets)
end

#patternObject



11
12
13
# File 'lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb', line 11

def pattern
  contextual_pattern('plans/**/*.pp')
end

#pattern_ignoreObject



15
# File 'lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb', line 15

def pattern_ignore; end

#spinner_text_for_targets(_targets) ⇒ Object



17
18
19
# File 'lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb', line 17

def spinner_text_for_targets(_targets)
  format('Checking Puppet plan syntax (%{pattern}).', pattern: pattern.join(' '))
end

#validate_tmpdirObject



30
31
32
33
34
# File 'lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb', line 30

def validate_tmpdir
  require 'tmpdir'

  @validate_tmpdir ||= Dir.mktmpdir('puppet-plan-parser-validate')
end