1
#include "source/common/http/dependency_manager.h"
2

            
3
#include "absl/container/flat_hash_set.h"
4
#include "absl/strings/substitute.h"
5

            
6
namespace Envoy {
7
namespace Http {
8

            
9
using envoy::extensions::filters::common::dependency::v3::Dependency;
10

            
11
10446
absl::Status DependencyManager::validDecodeDependencies() {
12
10446
  using DependencyTuple = std::tuple<const std::string&, int>;
13
10446
  absl::flat_hash_set<DependencyTuple> satisfied;
14

            
15
15720
  for (const auto& [name, dependencies] : filter_chain_) {
16
15665
    for (const auto& requirement : dependencies.decode_required()) {
17
12
      if (!satisfied.contains({requirement.name(), requirement.type()})) {
18
9
        return absl::NotFoundError(absl::Substitute(
19
9
            "Dependency violation: filter '$0' requires a $1 named '$2'", name,
20
9
            Dependency::DependencyType_Name(requirement.type()), requirement.name()));
21
9
      }
22
12
    }
23
15656
    for (const auto& provided : dependencies.decode_provided()) {
24
9
      satisfied.insert({provided.name(), provided.type()});
25
9
    }
26
15656
  }
27

            
28
10437
  return absl::OkStatus();
29
10446
}
30

            
31
} // namespace Http
32
} // namespace Envoy