1
#include "source/extensions/formatter/cel/config.h"
2

            
3
#include "envoy/extensions/formatter/cel/v3/cel.pb.h"
4

            
5
#include "source/extensions/formatter/cel/cel.h"
6

            
7
namespace Envoy {
8
namespace Extensions {
9
namespace Formatter {
10

            
11
::Envoy::Formatter::CommandParserPtr
12
CELFormatterFactory::createCommandParserFromProto(const Protobuf::Message&,
13
2
                                                  Server::Configuration::GenericFactoryContext&) {
14
2
#if defined(USE_CEL_PARSER)
15
2
  ENVOY_LOG_TO_LOGGER(Logger::Registry::getLog(Logger::Id::config), warn,
16
2
                      "'CEL' formatter is treated as a built-in formatter and does not "
17
2
                      "require configuration.");
18
2
  return std::make_unique<CELFormatterCommandParser>();
19
#else
20
  UNREFERENCED_PARAMETER(context);
21
  throw EnvoyException("CEL is not available for use in this environment.");
22
#endif
23
2
}
24

            
25
7
ProtobufTypes::MessagePtr CELFormatterFactory::createEmptyConfigProto() {
26
7
  return std::make_unique<envoy::extensions::formatter::cel::v3::Cel>();
27
7
}
28

            
29
27
std::string CELFormatterFactory::name() const { return "envoy.formatter.cel"; }
30

            
31
REGISTER_FACTORY(CELFormatterFactory, ::Envoy::Formatter::CommandParserFactory);
32

            
33
class BuiltInCELFormatterFactory : public Envoy::Formatter::BuiltInCommandParserFactory {
34
public:
35
9
  std::string name() const override { return "envoy.built_in_formatters.cel"; }
36

            
37
7
  ::Envoy::Formatter::CommandParserPtr createCommandParser() const override {
38
7
    return std::make_unique<CELFormatterCommandParser>();
39
7
  }
40
};
41

            
42
REGISTER_FACTORY(BuiltInCELFormatterFactory, Envoy::Formatter::BuiltInCommandParserFactory);
43

            
44
} // namespace Formatter
45
} // namespace Extensions
46
} // namespace Envoy