Class: Puppet::Parser::Compiler::CatalogValidator::SiteValidator

Inherits:
Puppet::Parser::Compiler::CatalogValidator show all
Defined in:
lib/puppet/parser/compiler/catalog_validator/site_validator.rb

Overview

Validator that asserts that only application components can appear inside a site.

Constant Summary

Constants inherited from Puppet::Parser::Compiler::CatalogValidator

FINAL, PRE_FINISH

Instance Attribute Summary

Attributes inherited from Puppet::Parser::Compiler::CatalogValidator

#catalog

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Puppet::Parser::Compiler::CatalogValidator

#initialize

Constructor Details

This class inherits a constructor from Puppet::Parser::Compiler::CatalogValidator

Class Method Details

.validation_stage?(stage) ⇒ Boolean


4
5
6
# File 'lib/puppet/parser/compiler/catalog_validator/site_validator.rb', line 4

def self.validation_stage?(stage)
  PRE_FINISH.equal?(stage)
end

Instance Method Details

#validateObject


8
9
10
11
12
13
14
15
16
17
# File 'lib/puppet/parser/compiler/catalog_validator/site_validator.rb', line 8

def validate
  the_site_resource = catalog.resource('Site', 'site')
  return unless the_site_resource

  catalog.downstream_from_vertex(the_site_resource).keys.each do |r|
    unless r.is_application_component? || r.resource_type.application?
      raise CatalogValidationError.new(_("Only application components can appear inside a site - %{res} is not allowed") % { res: r }, r.file, r.line)
    end
  end
end