Class: PuppetCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_check.rb

Overview

interfaces from CLI/tasks and to individual parsers

Defined Under Namespace

Classes: CLI, Tasks

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.filesObject

Returns the value of attribute files.



18
19
20
# File 'lib/puppet_check.rb', line 18

def files
  @files
end

Instance Method Details

#run(settings = {}, paths = []) ⇒ Object

main runner for PuppetCheck



22
23
24
25
26
27
28
29
30
31
32
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
65
66
67
68
69
# File 'lib/puppet_check.rb', line 22

def run(settings = {}, paths = [])
  # settings defaults
  settings = self.class.defaults(settings)

  # grab all of the files to be processed
  files = self.class.parse_paths(paths)

  # parse the files
  parsed_files = execute_parsers(files, settings[:style], settings[:puppetlint_args], settings[:rubocop_args], settings[:public], settings[:private])

  # output the diagnostic results
  OutputResults.run(parsed_files.clone, settings[:output_format])

  # progress to regression checks if no errors in file checks
  if parsed_files[:errors].empty? && (!settings[:fail_on_warnings] || parsed_files[:warnings].empty?)
    begin
      require_relative 'puppet-check/regression_check'

      # perform smoke checks if there were no errors and the user desires
      catalog = RegressionCheck.smoke(settings[:octonodes], settings[:octoconfig]) if settings[:smoke]
    # if octocatalog-diff is not installed then continue immediately
    rescue NameError
      puts 'puppet-check: immediately continuing to results'
    # smoke check failure? output message and return 2
    rescue OctocatalogDiff::Errors::CatalogError => err
      puts 'There was a smoke check error:'
      puts err
      puts catalog.error_message unless catalog.valid?
      2
    end
    # perform regression checks if there were no errors and the user desires
    # begin
    #   catalog = RegressionCheck.regression(settings[:octonodes], settings[:octoconfig]) if settings[:regression]
    # rescue OctocatalogDiff::Errors::CatalogError => err
    #   puts 'There was a catalog compilation error during the regression check:'
    #   puts err
    #   puts catalog.error_message unless catalog.valid?
    #   2
    # end

    # code to output differences in catalog?
    # everything passed? return 0
    0
  else
    # error files? return 2
    2
  end
end