1
#pragma once
2

            
3
#include "envoy/config/subscription.h"
4

            
5
namespace Envoy {
6
namespace Config {
7

            
8
// Represents a collection of config validators defined using Envoy extensions,
9
// for all xDS service types. This is different than running Envoy in
10
// "validation-mode", as these config validators will be executed whenever
11
// Envoy receives a new update.
12
class CustomConfigValidators {
13
public:
14
1973
  virtual ~CustomConfigValidators() = default;
15

            
16
  /**
17
   * Executes the validators that receive the State-of-the-World resources.
18
   *
19
   * @param type_url the xDS type url of the incoming resources.
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
  virtual void executeValidators(absl::string_view type_url,
25
                                 const std::vector<DecodedResourcePtr>& resources) PURE;
26

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

            
43
using CustomConfigValidatorsPtr = std::unique_ptr<CustomConfigValidators>;
44

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