File: catalog_validator.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (35 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

# Abstract class for a catalog validator that can be registered with the compiler to run at
# a certain stage.
class Puppet::Parser::Compiler
  class CatalogValidator
    PRE_FINISH = :pre_finish
    FINAL = :final

    # Returns true if the validator should run at the given stage. The default
    # implementation will only run at stage `FINAL`
    #
    # @param stage [Symbol] One of the stage constants defined in this class
    # @return [Boolean] true if the validator should run at the given stage
    #
    def self.validation_stage?(stage)
      FINAL.equal?(stage)
    end

    attr_reader :catalog

    # @param catalog [Puppet::Resource::Catalog] The catalog to validate
    def initialize(catalog)
      @catalog = catalog
    end

    # Validate some aspect of the catalog and raise a `CatalogValidationError` on failure
    def validate
    end
  end

  class CatalogValidationError < Puppet::Error
    include Puppet::ExternalFileError
  end
end