1
#pragma once
2

            
3
#include "envoy/config/config_validator.h"
4
#include "envoy/config/custom_config_validators.h"
5
#include "envoy/server/instance.h"
6

            
7
namespace Envoy {
8
namespace Config {
9

            
10
class CustomConfigValidatorsImpl : public CustomConfigValidators {
11
public:
12
  CustomConfigValidatorsImpl(
13
      ProtobufMessage::ValidationVisitor& validation_visitor, const Server::Instance& server,
14
      const Protobuf::RepeatedPtrField<envoy::config::core::v3::TypedExtensionConfig>&
15
          validators_configs);
16

            
17
  /**
18
   * Executes the validators that receive the State-of-the-World resources.
19
   *
20
   * @param resources the State-of-the-World resources from the new config
21
   *        update.
22
   * @throw EnvoyException if the config is rejected by one of the validators.
23
   */
24
  void executeValidators(absl::string_view type_url,
25
                         const std::vector<DecodedResourcePtr>& resources) override;
26

            
27
  /**
28
   * Executes the validators that receive the Incremental (delta-xDS) resources.
29
   *
30
   * @param added_resources the added/modified resources from the new config
31
   *        update.
32
   * @param removed_resources the resources to remove according to the new
33
   *        config update.
34
   * @throw EnvoyException if the config is rejected by one of the validators.
35
   */
36
  void executeValidators(absl::string_view type_url,
37
                         const std::vector<DecodedResourcePtr>& added_resources,
38
                         const Protobuf::RepeatedPtrField<std::string>& removed_resources) override;
39

            
40
private:
41
  absl::flat_hash_map<std::string, std::vector<Envoy::Config::ConfigValidatorPtr>> validators_map_;
42
  const Server::Instance& server_;
43
};
44

            
45
} // namespace Config
46
} // namespace Envoy