Class: Puppet::Parser::Compiler::CatalogValidator::EnvironmentRelationshipValidator

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

Overview

Validator that asserts that all capability resources that are referenced by 'consume' or 'require' has been exported by some other resource in the environment

Constant Summary

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

FINAL, PRE_FINISH

Instance Attribute Summary

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

#catalog

Instance Method Summary collapse

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

#initialize, validation_stage?

Constructor Details

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

Instance Method Details

#validateObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb', line 6

def validate
  assumed_exports = {}
  exported = {}
  catalog.resources.each do |resource|
    next unless resource.is_a?(Puppet::Parser::Resource)
    resource.eachparam do |param|
      pclass = Puppet::Type.metaparamclass(param.name)
      validate_relationship(resource, param, assumed_exports, exported) if !pclass.nil? && pclass < Puppet::Type::RelationshipMetaparam
    end
  end
  assumed_exports.each_pair do |key, (param, cap)|
    raise CatalogValidationError.new(_("Capability '%{cap}' referenced by '%{param}' is never exported") % { cap: cap, param: param.name }, param.file, param.line) unless exported.include?(key)
  end
  nil
end