From 20a864f49013e397019338f303925814df5072e6 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Tue, 17 Dec 2019 18:19:03 -0800 Subject: [PATCH 01/12] xds: dis-associate filter name from filter factory Signed-off-by: Kuat Yessenov --- include/envoy/access_log/BUILD | 1 + include/envoy/config/BUILD | 8 ++++ include/envoy/config/typed_config.h | 37 ++++++++++++++++ include/envoy/config/typed_metadata.h | 1 + include/envoy/grpc/google_grpc_creds.h | 1 + include/envoy/network/resolver.h | 1 + include/envoy/registry/registry.h | 26 +++++++++++ include/envoy/server/BUILD | 4 ++ include/envoy/server/access_log_config.h | 10 +---- .../envoy/server/active_udp_listener_config.h | 2 + include/envoy/server/filter_config.h | 35 +++------------ include/envoy/server/health_checker_config.h | 1 + .../envoy/server/resource_monitor_config.h | 10 +---- include/envoy/server/tracer_config.h | 9 +--- .../envoy/server/transport_socket_config.h | 10 +---- include/envoy/singleton/manager.h | 2 + include/envoy/ssl/context_manager.h | 2 + .../ssl/private_key/private_key_config.h | 2 + include/envoy/upstream/BUILD | 1 + include/envoy/upstream/cluster_factory.h | 2 + include/envoy/upstream/retry.h | 9 ++-- source/common/access_log/BUILD | 1 + source/common/access_log/access_log_impl.cc | 7 ++- source/common/access_log/access_log_impl.h | 10 +---- source/common/config/utility.cc | 2 - source/common/config/utility.h | 44 ++++++++++++++++++- source/common/http/codec_client.cc | 2 +- source/common/http/http3/quic_codec_factory.h | 2 + source/common/router/config_impl.cc | 27 +++++------- source/common/router/config_impl.h | 5 ++- source/common/upstream/health_checker_impl.cc | 2 +- .../upstream/transport_socket_match_impl.cc | 2 +- source/common/upstream/upstream_impl.cc | 7 ++- .../common/wasm/null/null_vm_plugin.h | 2 + .../filters/network/dubbo_proxy/config.cc | 5 +-- .../filters/network/dubbo_proxy/filters/BUILD | 1 + .../dubbo_proxy/filters/filter_config.h | 10 +---- .../filters/network/dubbo_proxy/protocol.h | 3 +- .../network/dubbo_proxy/router/route.h | 3 +- .../filters/network/dubbo_proxy/serializer.h | 3 +- .../network/http_connection_manager/config.cc | 8 ++-- .../filters/network/thrift_proxy/config.cc | 6 +-- .../network/thrift_proxy/filters/BUILD | 1 + .../thrift_proxy/filters/filter_config.h | 10 +---- .../filters/network/thrift_proxy/protocol.h | 3 +- .../filters/network/thrift_proxy/transport.h | 3 +- .../transport_sockets/tap/config.cc | 5 +-- source/server/BUILD | 1 + source/server/configuration_impl.cc | 7 ++- source/server/configuration_impl.h | 10 +---- source/server/listener_impl.cc | 11 ++--- source/server/listener_manager_impl.cc | 17 +++---- source/server/overload_manager_impl.cc | 2 +- test/common/config/registry_test.cc | 3 ++ .../active_quic_listener_config_test.cc | 3 +- test/server/connection_handler_test.cc | 2 +- test/server/options_impl_test.cc | 2 + 57 files changed, 236 insertions(+), 170 deletions(-) create mode 100644 include/envoy/config/typed_config.h diff --git a/include/envoy/access_log/BUILD b/include/envoy/access_log/BUILD index 9dc6453cf8f6..991715a6a830 100644 --- a/include/envoy/access_log/BUILD +++ b/include/envoy/access_log/BUILD @@ -12,6 +12,7 @@ envoy_cc_library( name = "access_log_interface", hdrs = ["access_log.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//include/envoy/http:header_map_interface", "//include/envoy/stream_info:stream_info_interface", "//source/common/protobuf", diff --git a/include/envoy/config/BUILD b/include/envoy/config/BUILD index adc456e7a6ee..3a2db9c1c0c6 100644 --- a/include/envoy/config/BUILD +++ b/include/envoy/config/BUILD @@ -58,6 +58,14 @@ envoy_cc_library( ], ) +envoy_cc_library( + name = "typed_config_interface", + hdrs = ["typed_config.h"], + deps = [ + "//source/common/protobuf", + ], +) + envoy_cc_library( name = "typed_metadata_interface", hdrs = ["typed_metadata.h"], diff --git a/include/envoy/config/typed_config.h b/include/envoy/config/typed_config.h new file mode 100644 index 000000000000..c7676767e232 --- /dev/null +++ b/include/envoy/config/typed_config.h @@ -0,0 +1,37 @@ +#pragma once + +#include "envoy/common/pure.h" + +#include "common/protobuf/protobuf.h" + +namespace Envoy { +namespace Config { + +/** + * Base class for config defined by a typed proto message. + */ +class TypedConfig { +public: + /** + * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The config, which + * arrives in an opaque google.protobuf.Struct message, will be converted to JSON and then parsed + * into this empty proto. + */ + virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; + + /** + * @return config proto full name + */ + virtual std::string type() { + auto ptr = createEmptyConfigProto(); + if (ptr == nullptr) { + return ""; + } + return ptr->GetDescriptor()->full_name(); + } + + virtual ~TypedConfig() = default; +}; + +} // namespace Config +} // namespace Envoy diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index 369ec0927bd3..6536ec9961a5 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -74,6 +74,7 @@ class TypedMetadataFactory { parse(const ProtobufWkt::Struct& data) const PURE; static std::string category() { return "typed_metadata"; } + static std::string type() { return ""; } }; } // namespace Config diff --git a/include/envoy/grpc/google_grpc_creds.h b/include/envoy/grpc/google_grpc_creds.h index f201c6d6a9ba..391d8df20f3b 100644 --- a/include/envoy/grpc/google_grpc_creds.h +++ b/include/envoy/grpc/google_grpc_creds.h @@ -46,6 +46,7 @@ class GoogleGrpcCredentialsFactory { * FactoryCategoryRegistry. */ static std::string category() { return "grpc_credentials"; } + static std::string type() { return ""; } }; } // namespace Grpc diff --git a/include/envoy/network/resolver.h b/include/envoy/network/resolver.h index 24a25045f18a..380454e9aecd 100644 --- a/include/envoy/network/resolver.h +++ b/include/envoy/network/resolver.h @@ -40,6 +40,7 @@ class Resolver { * FactoryCategoryRegistry. */ static std::string category() { return "resolvers"; } + static std::string type() { return ""; } }; } // namespace Address diff --git a/include/envoy/registry/registry.h b/include/envoy/registry/registry.h index 713c97574598..876834fb8dfc 100644 --- a/include/envoy/registry/registry.h +++ b/include/envoy/registry/registry.h @@ -158,6 +158,11 @@ template class FactoryRegistry : public Logger::Loggable& typeNames() { + static auto* type_names = new absl::flat_hash_map; + return *type_names; + } + /** * instead_value are used when passed name was deprecated. */ @@ -167,8 +172,18 @@ template class FactoryRegistry : public Logger::Loggable class FactoryRegistry : public Logger::Loggablesecond; } + /** + * Gets a factory by type URL. If not found, returns nullptr. + */ + static Base* getFactoryByType(absl::string_view type) { + auto it = typeNames().find(type); + if (it == factories().end()) { + return nullptr; + } + return it->second; + } + /** * @return the canonical name of the factory. If the given name is a * deprecated factory name, the canonical name is returned instead. diff --git a/include/envoy/server/BUILD b/include/envoy/server/BUILD index 657643e74a86..93a214f6c241 100644 --- a/include/envoy/server/BUILD +++ b/include/envoy/server/BUILD @@ -155,6 +155,7 @@ envoy_cc_library( ":process_context_interface", "//include/envoy/access_log:access_log_interface", "//include/envoy/api:api_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/grpc:context_interface", "//include/envoy/http:codes_interface", "//include/envoy/http:context_interface", @@ -210,6 +211,7 @@ envoy_cc_library( name = "transport_socket_config_interface", hdrs = ["transport_socket_config.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//include/envoy/event:dispatcher_interface", "//include/envoy/init:manager_interface", "//include/envoy/local_info:local_info_interface", @@ -229,6 +231,7 @@ envoy_cc_library( name = "resource_monitor_interface", hdrs = ["resource_monitor.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//source/common/protobuf", ], ) @@ -258,6 +261,7 @@ envoy_cc_library( hdrs = ["tracer_config.h"], deps = [ ":instance_interface", + "//include/envoy/config:typed_config_interface", "//source/common/protobuf", ], ) diff --git a/include/envoy/server/access_log_config.h b/include/envoy/server/access_log_config.h index 5b289fabfece..c06b5e76cef4 100644 --- a/include/envoy/server/access_log_config.h +++ b/include/envoy/server/access_log_config.h @@ -3,6 +3,7 @@ #include #include "envoy/access_log/access_log.h" +#include "envoy/config/typed_config.h" #include "envoy/server/filter_config.h" #include "common/protobuf/protobuf.h" @@ -15,7 +16,7 @@ namespace Configuration { * Implemented for each AccessLog::Instance and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class AccessLogInstanceFactory { +class AccessLogInstanceFactory : public Config::TypedConfig { public: virtual ~AccessLogInstanceFactory() = default; @@ -32,13 +33,6 @@ class AccessLogInstanceFactory { AccessLog::FilterPtr&& filter, FactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The config, which - * arrives in an opaque google.protobuf.Struct message, will be converted to JSON and then parsed - * into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular AccessLog::Instance implementation * produced by the factory. diff --git a/include/envoy/server/active_udp_listener_config.h b/include/envoy/server/active_udp_listener_config.h index de2a41ce4194..812e044cf37d 100644 --- a/include/envoy/server/active_udp_listener_config.h +++ b/include/envoy/server/active_udp_listener_config.h @@ -34,6 +34,8 @@ class ActiveUdpListenerConfigFactory { * FactoryCategoryRegistry. */ static std::string category() { return "udp_listeners"; } + + static std::string type() { return ""; } }; } // namespace Server diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index 89cce4b54827..54acd7f82fc7 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -4,6 +4,7 @@ #include "envoy/access_log/access_log.h" #include "envoy/api/v2/core/base.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/grpc/context.h" #include "envoy/http/codes.h" #include "envoy/http/context.h" @@ -211,16 +212,10 @@ class ListenerFactoryContext : public virtual FactoryContext { /** * Common interface for listener filters and UDP listener filters */ -class ListenerFilterConfigFactoryBase { +class ListenerFilterConfigFactoryBase : public Config::TypedConfig { public: virtual ~ListenerFilterConfigFactoryBase() = default; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message. The filter - * config, which arrives in an opaque message, will be parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular implementation of a listener filter * produced by the factory. @@ -320,7 +315,7 @@ class ProtocolOptionsFactory { * Implemented by each network filter and registered via Registry::registerFactory() * or the convenience class RegisterFactory. */ -class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory { +class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory, public Config::TypedConfig { public: ~NamedNetworkFilterConfigFactory() override = default; @@ -335,13 +330,6 @@ class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory { virtual Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message& config, FactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The filter - * config, which arrives in an opaque google.protobuf.Struct message, will be converted to - * JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular implementation of a network filter * produced by the factory. @@ -365,7 +353,8 @@ class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory { * Implemented by each upstream cluster network filter and registered via * Registry::registerFactory() or the convenience class RegisterFactory. */ -class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory { +class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory, + public Config::TypedConfig { public: ~NamedUpstreamNetworkFilterConfigFactory() override = default; @@ -377,11 +366,6 @@ class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory { virtual Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message& config, CommonFactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular implementation of a network filter * produced by the factory. @@ -400,7 +384,7 @@ class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory { * Implemented by each HTTP filter and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory { +class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory, public Config::TypedConfig { public: ~NamedHttpFilterConfigFactory() override = default; @@ -418,13 +402,6 @@ class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory { const std::string& stat_prefix, FactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The filter - * config, which arrives in an opaque google.protobuf.Struct message, will be converted to - * JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return ProtobufTypes::MessagePtr create an empty virtual host, route, or weighted * cluster-local config proto message for v2. The filter config, which arrives in an diff --git a/include/envoy/server/health_checker_config.h b/include/envoy/server/health_checker_config.h index 4fe695e929d6..eeff37aace40 100644 --- a/include/envoy/server/health_checker_config.h +++ b/include/envoy/server/health_checker_config.h @@ -84,6 +84,7 @@ class CustomHealthCheckerFactory { * FactoryCategoryRegistry. */ static std::string category() { return "health_checkers"; } + static std::string type() { return ""; } }; } // namespace Configuration diff --git a/include/envoy/server/resource_monitor_config.h b/include/envoy/server/resource_monitor_config.h index 53edcb2f854a..1a93fcfe8260 100644 --- a/include/envoy/server/resource_monitor_config.h +++ b/include/envoy/server/resource_monitor_config.h @@ -2,6 +2,7 @@ #include "envoy/api/api.h" #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "envoy/event/dispatcher.h" #include "envoy/protobuf/message_validator.h" #include "envoy/server/resource_monitor.h" @@ -38,7 +39,7 @@ class ResourceMonitorFactoryContext { * Implemented by each resource monitor and registered via Registry::registerFactory() * or the convenience class RegistryFactory. */ -class ResourceMonitorFactory { +class ResourceMonitorFactory : public Config::TypedConfig { public: virtual ~ResourceMonitorFactory() = default; @@ -54,13 +55,6 @@ class ResourceMonitorFactory { virtual ResourceMonitorPtr createResourceMonitor(const Protobuf::Message& config, ResourceMonitorFactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message. The resource monitor - * config, which arrives in an opaque google.protobuf.Struct message, will be converted - * to JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular implementation of a resource * monitor produced by the factory. diff --git a/include/envoy/server/tracer_config.h b/include/envoy/server/tracer_config.h index 7da24de47900..9715098cedc9 100644 --- a/include/envoy/server/tracer_config.h +++ b/include/envoy/server/tracer_config.h @@ -1,6 +1,7 @@ #pragma once #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "envoy/server/instance.h" #include "envoy/tracing/http_tracer.h" @@ -14,7 +15,7 @@ namespace Configuration { * Implemented by each Tracer and registered via Registry::registerFactory() or the convenience * class RegisterFactory. */ -class TracerFactory { +class TracerFactory : public Config::TypedConfig { public: virtual ~TracerFactory() = default; @@ -29,12 +30,6 @@ class TracerFactory { virtual Tracing::HttpTracerPtr createHttpTracer(const Protobuf::Message& config, Instance& server) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The tracing - * config, which arrives in an opaque message, will be parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * Returns the identifying name for a particular implementation of tracer produced by the * factory. diff --git a/include/envoy/server/transport_socket_config.h b/include/envoy/server/transport_socket_config.h index b0c22e786314..78ceed411b5c 100644 --- a/include/envoy/server/transport_socket_config.h +++ b/include/envoy/server/transport_socket_config.h @@ -2,6 +2,7 @@ #include +#include "envoy/config/typed_config.h" #include "envoy/event/dispatcher.h" #include "envoy/init/manager.h" #include "envoy/local_info/local_info.h" @@ -106,17 +107,10 @@ class TransportSocketFactoryContext { virtual Api::Api& api() PURE; }; -class TransportSocketConfigFactory { +class TransportSocketConfigFactory : public Config::TypedConfig { public: virtual ~TransportSocketConfigFactory() = default; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message. The transport socket - * config, which arrives in an opaque google.protobuf.Struct message, will be converted - * to JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular TransportSocketFactoryPtr * implementation produced by the factory. diff --git a/include/envoy/singleton/manager.h b/include/envoy/singleton/manager.h index 2278ef8942d7..c4bfa6f2f81c 100644 --- a/include/envoy/singleton/manager.h +++ b/include/envoy/singleton/manager.h @@ -18,6 +18,8 @@ class Registration { public: virtual ~Registration() = default; virtual std::string name() PURE; + static std::string category() { return "singleton"; } + static std::string type() { return ""; } }; /** diff --git a/include/envoy/ssl/context_manager.h b/include/envoy/ssl/context_manager.h index bb0c104e5202..68e444c9baf1 100644 --- a/include/envoy/ssl/context_manager.h +++ b/include/envoy/ssl/context_manager.h @@ -57,6 +57,8 @@ class ContextManagerFactory { // There could be only one factory thus the name is static. static std::string name() { return "ssl_context_manager"; } + static std::string category() { return "ssl_context_manager"; } + static std::string type() { return ""; } }; } // namespace Ssl diff --git a/include/envoy/ssl/private_key/private_key_config.h b/include/envoy/ssl/private_key/private_key_config.h index 6f6eef9ac0e2..95e675dd7f49 100644 --- a/include/envoy/ssl/private_key/private_key_config.h +++ b/include/envoy/ssl/private_key/private_key_config.h @@ -35,6 +35,8 @@ class PrivateKeyMethodProviderInstanceFactory { * Used for automatic registration with FactoryCategoryRegistry. */ static std::string category() { return "tls.key_providers"; }; + + static std::string type() { return ""; }; }; } // namespace Ssl diff --git a/include/envoy/upstream/BUILD b/include/envoy/upstream/BUILD index cb30f9994bc4..ef4eb94ce043 100644 --- a/include/envoy/upstream/BUILD +++ b/include/envoy/upstream/BUILD @@ -105,6 +105,7 @@ envoy_cc_library( name = "retry_interface", hdrs = ["retry.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//include/envoy/upstream:types_interface", "//include/envoy/upstream:upstream_interface", ], diff --git a/include/envoy/upstream/cluster_factory.h b/include/envoy/upstream/cluster_factory.h index 5c6ee9787ed8..6529c0a060f2 100644 --- a/include/envoy/upstream/cluster_factory.h +++ b/include/envoy/upstream/cluster_factory.h @@ -149,6 +149,8 @@ class ClusterFactory { * FactoryCategoryRegistry. */ static std::string category() { return "clusters"; } + + virtual std::string type() const { return ""; } }; } // namespace Upstream diff --git a/include/envoy/upstream/retry.h b/include/envoy/upstream/retry.h index f83983133562..5b378067fa9f 100644 --- a/include/envoy/upstream/retry.h +++ b/include/envoy/upstream/retry.h @@ -1,5 +1,6 @@ #pragma once +#include "envoy/config/typed_config.h" #include "envoy/upstream/types.h" #include "envoy/upstream/upstream.h" @@ -75,7 +76,7 @@ using RetryHostPredicateSharedPtr = std::shared_ptr; /** * Factory for RetryPriority. */ -class RetryPriorityFactory { +class RetryPriorityFactory : public Config::TypedConfig { public: virtual ~RetryPriorityFactory() = default; @@ -93,13 +94,13 @@ class RetryPriorityFactory { */ static std::string category() { return "retry_priorities"; } - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; + ProtobufTypes::MessagePtr createEmptyConfigProto() override { return nullptr; } }; /** * Factory for RetryHostPredicate. */ -class RetryHostPredicateFactory { +class RetryHostPredicateFactory : public Config::TypedConfig { public: virtual ~RetryHostPredicateFactory() = default; @@ -113,7 +114,7 @@ class RetryHostPredicateFactory { static std::string category() { return "retry_host_predicates"; } - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; + ProtobufTypes::MessagePtr createEmptyConfigProto() override { return nullptr; } }; } // namespace Upstream diff --git a/source/common/access_log/BUILD b/source/common/access_log/BUILD index 76c225d52c4d..fdfcbf740b15 100644 --- a/source/common/access_log/BUILD +++ b/source/common/access_log/BUILD @@ -15,6 +15,7 @@ envoy_cc_library( external_deps = ["abseil_hash"], deps = [ "//include/envoy/access_log:access_log_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/filesystem:filesystem_interface", "//include/envoy/http:header_map_interface", "//include/envoy/runtime:runtime_interface", diff --git a/source/common/access_log/access_log_impl.cc b/source/common/access_log/access_log_impl.cc index 8b4a0f3b7512..ba802ffba55e 100644 --- a/source/common/access_log/access_log_impl.cc +++ b/source/common/access_log/access_log_impl.cc @@ -82,8 +82,8 @@ FilterFactory::fromProto(const envoy::config::filter::accesslog::v2::AccessLogFi case envoy::config::filter::accesslog::v2::AccessLogFilter::kExtensionFilter: MessageUtil::validate(config, validation_visitor); { - auto& factory = Config::Utility::getAndCheckFactory( - config.extension_filter().name()); + auto& factory = + Config::Utility::getAndCheckFactory(config.extension_filter()); return factory.createFilter(config.extension_filter(), runtime, random); } default: @@ -277,8 +277,7 @@ AccessLogFactory::fromProto(const envoy::config::filter::accesslog::v2::AccessLo } auto& factory = - Config::Utility::getAndCheckFactory( - config.name()); + Config::Utility::getAndCheckFactory(config); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( config, context.messageValidationVisitor(), factory); diff --git a/source/common/access_log/access_log_impl.h b/source/common/access_log/access_log_impl.h index fae56dcf0944..1bce9764b393 100644 --- a/source/common/access_log/access_log_impl.h +++ b/source/common/access_log/access_log_impl.h @@ -7,6 +7,7 @@ #include "envoy/access_log/access_log.h" #include "envoy/config/filter/accesslog/v2/accesslog.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/runtime/runtime.h" #include "envoy/server/access_log_config.h" #include "envoy/type/percent.pb.h" @@ -230,7 +231,7 @@ class GrpcStatusFilter : public Filter { /** * Extension filter factory that reads from ExtensionFilter proto. */ -class ExtensionFilterFactory { +class ExtensionFilterFactory : public Config::TypedConfig { public: virtual ~ExtensionFilterFactory() = default; @@ -247,13 +248,6 @@ class ExtensionFilterFactory { createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader& runtime, Runtime::RandomGenerator& random) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The config, which - * arrives in an opaque google.protobuf.Struct message, will be converted to JSON and then parsed - * into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular Filter implementation * produced by the factory. diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index f0abdce9e249..75b269fea88b 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -24,8 +24,6 @@ #include "common/stats/stats_matcher_impl.h" #include "common/stats/tag_producer_impl.h" -#include "udpa/type/v1/typed_struct.pb.h" - namespace Envoy { namespace Config { diff --git a/source/common/config/utility.h b/source/common/config/utility.h index bbd25757d3e1..07d6f7759dbb 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -26,6 +26,8 @@ #include "common/protobuf/utility.h" #include "common/singleton/const_singleton.h" +#include "udpa/type/v1/typed_struct.pb.h" + namespace Envoy { namespace Config { @@ -193,7 +195,7 @@ class Utility { * @param name string identifier for the particular implementation. Note: this is a proto string * because it is assumed that this value will be pulled directly from the configuration proto. */ - template static Factory& getAndCheckFactory(const std::string& name) { + template static Factory& getAndCheckFactoryByName(const std::string& name) { if (name.empty()) { throw EnvoyException("Provided name for static registration lookup was empty."); } @@ -208,6 +210,46 @@ class Utility { return *factory; } + /** + * Get a Factory from the registry with error checking to ensure the name and the factory are + * valid. If the typed config references a proto that is neither Struct nor Empty, then the proto + * type is used to select a factory. + * @param message proto that contains fields 'name' and 'typed_config'. + */ + template + static Factory& getAndCheckFactory(const ProtoMessage& message) { + const auto& name = message.name(); + + static const std::string struct_type = + ProtobufWkt::Struct::default_instance().GetDescriptor()->full_name(); + static const std::string empty_type = + ProtobufWkt::Empty::default_instance().GetDescriptor()->full_name(); + static const std::string typed_struct_type = + udpa::type::v1::TypedStruct::default_instance().GetDescriptor()->full_name(); + + if (message.has_typed_config()) { + absl::string_view type = + TypeUtil::typeUrlToDescriptorFullName(message.typed_config().type_url()); + + if (type == typed_struct_type) { + udpa::type::v1::TypedStruct typed_struct; + MessageUtil::unpackTo(message.typed_config(), typed_struct); + type = TypeUtil::typeUrlToDescriptorFullName(typed_struct.type_url()); + } + + if (!type.empty() && type != struct_type && type != empty_type) { + Factory* factory = Registry::FactoryRegistry::getFactoryByType(type); + + if (factory == nullptr) { + throw EnvoyException( + fmt::format("Didn't find a registered implementation for type: '{}'", type)); + } + return *factory; + } + } + return Utility::getAndCheckFactoryByName(name); + } + /** * Translate a nested config into a proto message provided by the implementation factory. * @param extension_name name of extension corresponding to config. diff --git a/source/common/http/codec_client.cc b/source/common/http/codec_client.cc index 673212d3e69b..04a2ca0d7b04 100644 --- a/source/common/http/codec_client.cc +++ b/source/common/http/codec_client.cc @@ -162,7 +162,7 @@ CodecClientProd::CodecClientProd(Type type, Network::ClientConnectionPtr&& conne } case Type::HTTP3: { codec_ = std::unique_ptr( - Config::Utility::getAndCheckFactory( + Config::Utility::getAndCheckFactoryByName( Http::QuicCodecNames::get().Quiche) .createQuicClientConnection(*connection_, *this)); } diff --git a/source/common/http/http3/quic_codec_factory.h b/source/common/http/http3/quic_codec_factory.h index 21ca7cab8704..ded22c13ad36 100644 --- a/source/common/http/http3/quic_codec_factory.h +++ b/source/common/http/http3/quic_codec_factory.h @@ -19,6 +19,7 @@ class QuicHttpServerConnectionFactory { createQuicServerConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; static std::string category() { return "quic_client_codec"; } + static std::string type() { return ""; } }; // A factory to create Http::ClientConnection instance for QUIC. @@ -32,6 +33,7 @@ class QuicHttpClientConnectionFactory { createQuicClientConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; static std::string category() { return "quic_server_codec"; } + static std::string type() { return ""; } }; } // namespace Http diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 0eabbf1a310d..8209be99cd6b 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -83,19 +83,19 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry for (const auto& host_predicate : retry_policy.retry_host_predicate()) { auto& factory = Envoy::Config::Utility::getAndCheckFactory( - host_predicate.name()); + host_predicate); auto config = Envoy::Config::Utility::translateToFactoryConfig(host_predicate, validation_visitor, factory); - retry_host_predicate_configs_.emplace_back(host_predicate.name(), std::move(config)); + retry_host_predicate_configs_.emplace_back(factory, std::move(config)); } const auto& retry_priority = retry_policy.retry_priority(); if (!retry_priority.name().empty()) { - auto& factory = Envoy::Config::Utility::getAndCheckFactory( - retry_priority.name()); + auto& factory = + Envoy::Config::Utility::getAndCheckFactory(retry_priority); retry_priority_config_ = - std::make_pair(retry_priority.name(), Envoy::Config::Utility::translateToFactoryConfig( - retry_priority, validation_visitor, factory)); + std::make_pair(&factory, Envoy::Config::Utility::translateToFactoryConfig( + retry_priority, validation_visitor, factory)); } auto host_selection_attempts = retry_policy.host_selection_retry_max_attempts(); @@ -133,24 +133,19 @@ std::vector RetryPolicyImpl::retryHostPre std::vector predicates; for (const auto& config : retry_host_predicate_configs_) { - auto& factory = Envoy::Config::Utility::getAndCheckFactory( - config.first); - predicates.emplace_back(factory.createHostPredicate(*config.second, num_retries_)); + predicates.emplace_back(config.first.createHostPredicate(*config.second, num_retries_)); } return predicates; } Upstream::RetryPrioritySharedPtr RetryPolicyImpl::retryPriority() const { - if (retry_priority_config_.first.empty()) { + if (retry_priority_config_.first == nullptr) { return nullptr; } - auto& factory = Envoy::Config::Utility::getAndCheckFactory( - retry_priority_config_.first); - - return factory.createRetryPriority(*retry_priority_config_.second, *validation_visitor_, - num_retries_); + return retry_priority_config_.first->createRetryPriority(*retry_priority_config_.second, + *validation_visitor_, num_retries_); } CorsPolicyImpl::CorsPolicyImpl(const envoy::api::v2::route::CorsPolicy& config, @@ -1170,7 +1165,7 @@ createRouteSpecificFilterConfig(const std::string& name, const ProtobufWkt::Any& const ProtobufWkt::Struct& config, Server::Configuration::ServerFactoryContext& factory_context, ProtobufMessage::ValidationVisitor& validator) { - auto& factory = Envoy::Config::Utility::getAndCheckFactory< + auto& factory = Envoy::Config::Utility::getAndCheckFactoryByName< Server::Configuration::NamedHttpFilterConfigFactory>(name); ProtobufTypes::MessagePtr proto_config = factory.createEmptyRouteConfigProto(); Envoy::Config::Utility::translateOpaqueConfig(name, typed_config, config, validator, diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index 0f14937c7ba5..563c4d643b46 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -264,11 +264,12 @@ class RetryPolicyImpl : public RetryPolicy { uint32_t retry_on_{}; // Each pair contains the name and config proto to be used to create the RetryHostPredicates // that should be used when with this policy. - std::vector> retry_host_predicate_configs_; + std::vector> + retry_host_predicate_configs_; Upstream::RetryPrioritySharedPtr retry_priority_; // Name and config proto to use to create the RetryPriority to use with this policy. Default // initialized when no RetryPriority should be used. - std::pair retry_priority_config_; + std::pair retry_priority_config_; uint32_t host_selection_attempts_{1}; std::vector retriable_status_codes_; std::vector retriable_headers_; diff --git a/source/common/upstream/health_checker_impl.cc b/source/common/upstream/health_checker_impl.cc index 624707d28cda..6325f5b7cd13 100644 --- a/source/common/upstream/health_checker_impl.cc +++ b/source/common/upstream/health_checker_impl.cc @@ -85,7 +85,7 @@ HealthCheckerSharedPtr HealthCheckerFactory::create( case envoy::api::v2::core::HealthCheck::HealthCheckerCase::kCustomHealthCheck: { auto& factory = Config::Utility::getAndCheckFactory( - health_check_config.custom_health_check().name()); + health_check_config.custom_health_check()); std::unique_ptr context( new HealthCheckerFactoryContextImpl(cluster, runtime, random, dispatcher, std::move(event_logger), validation_visitor, api)); diff --git a/source/common/upstream/transport_socket_match_impl.cc b/source/common/upstream/transport_socket_match_impl.cc index 3077d01834e4..7fe6f6ad4c04 100644 --- a/source/common/upstream/transport_socket_match_impl.cc +++ b/source/common/upstream/transport_socket_match_impl.cc @@ -18,7 +18,7 @@ TransportSocketMatcherImpl::TransportSocketMatcherImpl( for (const auto& socket_match : socket_matches) { const auto& socket_config = socket_match.transport_socket(); auto& config_factory = Config::Utility::getAndCheckFactory< - Server::Configuration::UpstreamTransportSocketConfigFactory>(socket_config.name()); + Server::Configuration::UpstreamTransportSocketConfigFactory>(socket_config); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( socket_config, factory_context.messageValidationVisitor(), config_factory); FactoryMatch factory_match( diff --git a/source/common/upstream/upstream_impl.cc b/source/common/upstream/upstream_impl.cc index 7d285162637d..2a25c74a0cf1 100644 --- a/source/common/upstream/upstream_impl.cc +++ b/source/common/upstream/upstream_impl.cc @@ -752,11 +752,10 @@ ClusterInfoImpl::ClusterInfoImpl( auto filters = config.filters(); for (ssize_t i = 0; i < filters.size(); i++) { const auto& proto_config = filters[i]; - const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " upstream filter #{}:", i); - ENVOY_LOG(debug, " name: {}", string_name); + ENVOY_LOG(debug, " name: {}", proto_config.name()); auto& factory = Config::Utility::getAndCheckFactory< - Server::Configuration::NamedUpstreamNetworkFilterConfigFactory>(string_name); + Server::Configuration::NamedUpstreamNetworkFilterConfigFactory>(proto_config); auto message = factory.createEmptyConfigProto(); if (!proto_config.typed_config().value().empty()) { MessageUtil::unpackTo(proto_config.typed_config(), *message); @@ -795,7 +794,7 @@ Network::TransportSocketFactoryPtr createTransportSocketFactory( } auto& config_factory = Config::Utility::getAndCheckFactory< - Server::Configuration::UpstreamTransportSocketConfigFactory>(transport_socket.name()); + Server::Configuration::UpstreamTransportSocketConfigFactory>(transport_socket); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( transport_socket, factory_context.messageValidationVisitor(), config_factory); return config_factory.createTransportSocketFactory(*message, factory_context); diff --git a/source/extensions/common/wasm/null/null_vm_plugin.h b/source/extensions/common/wasm/null/null_vm_plugin.h index 231651eeafad..c534c8f6fe3e 100644 --- a/source/extensions/common/wasm/null/null_vm_plugin.h +++ b/source/extensions/common/wasm/null/null_vm_plugin.h @@ -42,6 +42,8 @@ class NullVmPluginFactory { */ static std::string category() { return "wasm.null_vms"; } + static std::string type() { return ""; } + /** * Create an instance of the plugin. */ diff --git a/source/extensions/filters/network/dubbo_proxy/config.cc b/source/extensions/filters/network/dubbo_proxy/config.cc index 154915b0cbd9..0b24431a3eca 100644 --- a/source/extensions/filters/network/dubbo_proxy/config.cc +++ b/source/extensions/filters/network/dubbo_proxy/config.cc @@ -135,15 +135,14 @@ ProtocolPtr ConfigImpl::createProtocol() { } void ConfigImpl::registerFilter(const DubboFilterConfig& proto_config) { - const std::string& string_name = proto_config.name(); - + const auto& string_name = proto_config.name(); ENVOY_LOG(debug, " dubbo filter #{}", filter_factories_.size()); ENVOY_LOG(debug, " name: {}", string_name); ENVOY_LOG(debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.config(), true)); auto& factory = - Envoy::Config::Utility::getAndCheckFactory( + Envoy::Config::Utility::getAndCheckFactoryByName( string_name); ProtobufTypes::MessagePtr message = factory.createEmptyConfigProto(); Envoy::Config::Utility::translateOpaqueConfig(string_name, proto_config.config(), diff --git a/source/extensions/filters/network/dubbo_proxy/filters/BUILD b/source/extensions/filters/network/dubbo_proxy/filters/BUILD index 253738c08779..19f4fd317675 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/BUILD +++ b/source/extensions/filters/network/dubbo_proxy/filters/BUILD @@ -28,6 +28,7 @@ envoy_cc_library( hdrs = ["filter_config.h"], deps = [ ":filter_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/server:filter_config_interface", "//source/common/common:macros", "//source/common/protobuf:cc_wkt_protos", diff --git a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h index e3cc0c4b45f5..5151dbe66132 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h @@ -3,6 +3,7 @@ #include #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "envoy/server/filter_config.h" #include "common/common/macros.h" @@ -20,7 +21,7 @@ namespace DubboFilters { * Implemented by each Dubbo filter and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedDubboFilterConfigFactory { +class NamedDubboFilterConfigFactory : public Envoy::Config::TypedConfig { public: virtual ~NamedDubboFilterConfigFactory() = default; @@ -37,13 +38,6 @@ class NamedDubboFilterConfigFactory { createFilterFactoryFromProto(const Protobuf::Message& config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The filter - * config, which arrives in an opaque google.protobuf.Struct message, will be converted to - * JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular implementation of a dubbo filter * produced by the factory. diff --git a/source/extensions/filters/network/dubbo_proxy/protocol.h b/source/extensions/filters/network/dubbo_proxy/protocol.h index e97ab25cb748..a1f5896ba1f9 100644 --- a/source/extensions/filters/network/dubbo_proxy/protocol.h +++ b/source/extensions/filters/network/dubbo_proxy/protocol.h @@ -120,6 +120,7 @@ class NamedProtocolConfigFactory { * FactoryCategoryRegistry. */ static std::string category() { return "dubbo_proxy.protocols"; } + static std::string type() { return ""; } /** * Convenience method to lookup a factory by type. @@ -128,7 +129,7 @@ class NamedProtocolConfigFactory { */ static NamedProtocolConfigFactory& getFactory(ProtocolType type) { const std::string& name = ProtocolNames::get().fromType(type); - return Envoy::Config::Utility::getAndCheckFactory(name); + return Envoy::Config::Utility::getAndCheckFactoryByName(name); } }; diff --git a/source/extensions/filters/network/dubbo_proxy/router/route.h b/source/extensions/filters/network/dubbo_proxy/router/route.h index 1cb478bd092f..7c9e0f26c40d 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route.h @@ -90,6 +90,7 @@ class NamedRouteMatcherConfigFactory { * FactoryCategoryRegistry. */ static std::string category() { return "dubbo_proxy.route_matchers"; } + static std::string type() { return ""; } /** * Convenience method to lookup a factory by type. @@ -98,7 +99,7 @@ class NamedRouteMatcherConfigFactory { */ static NamedRouteMatcherConfigFactory& getFactory(RouteMatcherType type) { const std::string& name = RouteMatcherNames::get().fromType(type); - return Envoy::Config::Utility::getAndCheckFactory(name); + return Envoy::Config::Utility::getAndCheckFactoryByName(name); } }; diff --git a/source/extensions/filters/network/dubbo_proxy/serializer.h b/source/extensions/filters/network/dubbo_proxy/serializer.h index c32d41ed2499..7eaae6ec75ae 100644 --- a/source/extensions/filters/network/dubbo_proxy/serializer.h +++ b/source/extensions/filters/network/dubbo_proxy/serializer.h @@ -100,6 +100,7 @@ class NamedSerializerConfigFactory { * FactoryCategoryRegistry. */ static std::string category() { return "dubbo_proxy.serializers"; } + static std::string type() { return ""; } /** * Convenience method to lookup a factory by type. @@ -109,7 +110,7 @@ class NamedSerializerConfigFactory { static NamedSerializerConfigFactory& getFactory(ProtocolType protocol_type, SerializationType type) { const std::string& name = ProtocolSerializerNames::get().fromType(protocol_type, type); - return Envoy::Config::Utility::getAndCheckFactory(name); + return Envoy::Config::Utility::getAndCheckFactoryByName(name); } }; diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index f5662dda813e..9f47c925d3e7 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -395,17 +395,15 @@ void HttpConnectionManagerConfig::processFilter( const envoy::config::filter::network::http_connection_manager::v2::HttpFilter& proto_config, int i, absl::string_view prefix, std::list& filter_factories, bool& is_terminal) { - const std::string& string_name = proto_config.name(); - ENVOY_LOG(debug, " {} filter #{}", prefix, i); - ENVOY_LOG(debug, " name: {}", string_name); + ENVOY_LOG(debug, " name: {}", proto_config.name()); ENVOY_LOG(debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.config(), true)); // Now see if there is a factory that will accept the config. auto& factory = Config::Utility::getAndCheckFactory( - string_name); + proto_config); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( proto_config, context_.messageValidationVisitor(), factory); Http::FilterFactoryCb callback = @@ -433,7 +431,7 @@ HttpConnectionManagerConfig::createCodec(Network::Connection& connection, // from HttpConnectionManager protobuf. This is not essential till there are multiple // implementations of QUIC. return std::unique_ptr( - Config::Utility::getAndCheckFactory( + Config::Utility::getAndCheckFactoryByName( Http::QuicCodecNames::get().Quiche) .createQuicServerConnection(connection, callbacks)); case CodecType::AUTO: diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index 25ecd6e78e40..504d9cbd8f45 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -157,15 +157,13 @@ ProtocolPtr ConfigImpl::createProtocol() { void ConfigImpl::processFilter( const envoy::config::filter::network::thrift_proxy::v2alpha1::ThriftFilter& proto_config) { - const std::string& string_name = proto_config.name(); - ENVOY_LOG(debug, " thrift filter #{}", filter_factories_.size()); - ENVOY_LOG(debug, " name: {}", string_name); + ENVOY_LOG(debug, " name: {}", proto_config.name()); ENVOY_LOG(debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.config(), true)); auto& factory = Envoy::Config::Utility::getAndCheckFactory( - string_name); + proto_config); ProtobufTypes::MessagePtr message = Envoy::Config::Utility::translateToFactoryConfig( proto_config, context_.messageValidationVisitor(), factory); diff --git a/source/extensions/filters/network/thrift_proxy/filters/BUILD b/source/extensions/filters/network/thrift_proxy/filters/BUILD index 233aaf8edc90..1f4ebe2b5fc6 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/BUILD +++ b/source/extensions/filters/network/thrift_proxy/filters/BUILD @@ -13,6 +13,7 @@ envoy_cc_library( hdrs = ["filter_config.h"], deps = [ ":filter_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/server:filter_config_interface", "//source/common/common:macros", "//source/common/protobuf:cc_wkt_protos", diff --git a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h index a012e2db7e9f..0fedb23dc062 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h @@ -1,5 +1,6 @@ #pragma once +#include "envoy/config/typed_config.h" #include "envoy/server/filter_config.h" #include "common/common/macros.h" @@ -17,7 +18,7 @@ namespace ThriftFilters { * Implemented by each Thrift filter and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedThriftFilterConfigFactory { +class NamedThriftFilterConfigFactory : public Envoy::Config::TypedConfig { public: virtual ~NamedThriftFilterConfigFactory() = default; @@ -34,13 +35,6 @@ class NamedThriftFilterConfigFactory { createFilterFactoryFromProto(const Protobuf::Message& config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The filter - * config, which arrives in an opaque google.protobuf.Struct message, will be converted to - * JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * @return std::string the identifying name for a particular implementation of a thrift filter * produced by the factory. diff --git a/source/extensions/filters/network/thrift_proxy/protocol.h b/source/extensions/filters/network/thrift_proxy/protocol.h index 3b3b947e7107..c0b6616d4c34 100644 --- a/source/extensions/filters/network/thrift_proxy/protocol.h +++ b/source/extensions/filters/network/thrift_proxy/protocol.h @@ -520,6 +520,7 @@ class NamedProtocolConfigFactory { * FactoryCategoryRegistry. */ static std::string category() { return "thrift_proxy.protocols"; } + static std::string type() { return ""; } /** * Convenience method to lookup a factory by type. @@ -528,7 +529,7 @@ class NamedProtocolConfigFactory { */ static NamedProtocolConfigFactory& getFactory(ProtocolType type) { const std::string& name = ProtocolNames::get().fromType(type); - return Envoy::Config::Utility::getAndCheckFactory(name); + return Envoy::Config::Utility::getAndCheckFactoryByName(name); } }; diff --git a/source/extensions/filters/network/thrift_proxy/transport.h b/source/extensions/filters/network/thrift_proxy/transport.h index 4f676da5bd52..b262674644e3 100644 --- a/source/extensions/filters/network/thrift_proxy/transport.h +++ b/source/extensions/filters/network/thrift_proxy/transport.h @@ -104,6 +104,7 @@ class NamedTransportConfigFactory { * FactoryCategoryRegistry. */ static std::string category() { return "thrift_proxy.transports"; } + static std::string type() { return ""; } /** * Convenience method to lookup a factory by type. @@ -112,7 +113,7 @@ class NamedTransportConfigFactory { */ static NamedTransportConfigFactory& getFactory(TransportType type) { const std::string& name = TransportNames::get().fromType(type); - return Envoy::Config::Utility::getAndCheckFactory(name); + return Envoy::Config::Utility::getAndCheckFactoryByName(name); } }; diff --git a/source/extensions/transport_sockets/tap/config.cc b/source/extensions/transport_sockets/tap/config.cc index c45f2def51a3..0471d14a65c1 100644 --- a/source/extensions/transport_sockets/tap/config.cc +++ b/source/extensions/transport_sockets/tap/config.cc @@ -39,8 +39,7 @@ Network::TransportSocketFactoryPtr UpstreamTapSocketConfigFactory::createTranspo MessageUtil::downcastAndValidate( message, context.messageValidationVisitor()); auto& inner_config_factory = Config::Utility::getAndCheckFactory< - Server::Configuration::UpstreamTransportSocketConfigFactory>( - outer_config.transport_socket().name()); + Server::Configuration::UpstreamTransportSocketConfigFactory>(outer_config.transport_socket()); ProtobufTypes::MessagePtr inner_factory_config = Config::Utility::translateToFactoryConfig( outer_config.transport_socket(), context.messageValidationVisitor(), inner_config_factory); auto inner_transport_factory = @@ -59,7 +58,7 @@ Network::TransportSocketFactoryPtr DownstreamTapSocketConfigFactory::createTrans message, context.messageValidationVisitor()); auto& inner_config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::DownstreamTransportSocketConfigFactory>( - outer_config.transport_socket().name()); + outer_config.transport_socket()); ProtobufTypes::MessagePtr inner_factory_config = Config::Utility::translateToFactoryConfig( outer_config.transport_socket(), context.messageValidationVisitor(), inner_config_factory); auto inner_transport_factory = inner_config_factory.createTransportSocketFactory( diff --git a/source/server/BUILD b/source/server/BUILD index 5e4cc5a66719..29520a7497ef 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -29,6 +29,7 @@ envoy_cc_library( srcs = ["configuration_impl.cc"], hdrs = ["configuration_impl.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//include/envoy/http:filter_interface", "//include/envoy/network:connection_interface", "//include/envoy/network:filter_interface", diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index eeb325e2d11b..a65e3ce3e9d3 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -102,11 +102,10 @@ void MainImpl::initializeTracers(const envoy::config::trace::v2::Tracing& config } // Initialize tracing driver. - std::string type = configuration.http().name(); - ENVOY_LOG(info, " loading tracing driver: {}", type); + ENVOY_LOG(info, " loading tracing driver: {}", configuration.http().name()); // Now see if there is a factory that will accept the config. - auto& factory = Config::Utility::getAndCheckFactory(type); + auto& factory = Config::Utility::getAndCheckFactory(configuration.http()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( configuration.http(), server.messageValidationContext().staticValidationVisitor(), factory); http_tracer_ = factory.createHttpTracer(*message, server); @@ -118,7 +117,7 @@ void MainImpl::initializeStatsSinks(const envoy::config::bootstrap::v2::Bootstra for (const envoy::config::metrics::v2::StatsSink& sink_object : bootstrap.stats_sinks()) { // Generate factory and translate stats sink custom config - auto& factory = Config::Utility::getAndCheckFactory(sink_object.name()); + auto& factory = Config::Utility::getAndCheckFactory(sink_object); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( sink_object, server.messageValidationContext().staticValidationVisitor(), factory); diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 9b167dce863c..821ea2178e37 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -11,6 +11,7 @@ #include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/config/trace/v2/trace.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/http/filter.h" #include "envoy/network/filter.h" #include "envoy/server/configuration.h" @@ -30,7 +31,7 @@ namespace Configuration { * Implemented for each Stats::Sink and registered via Registry::registerFactory() or * the convenience class RegisterFactory. */ -class StatsSinkFactory { +class StatsSinkFactory : public Config::TypedConfig { public: virtual ~StatsSinkFactory() = default; @@ -43,13 +44,6 @@ class StatsSinkFactory { */ virtual Stats::SinkPtr createStatsSink(const Protobuf::Message& config, Instance& server) PURE; - /** - * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The filter - * config, which arrives in an opaque google.protobuf.Struct message, will be converted to - * JSON and then parsed into this empty proto. - */ - virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** * Returns the identifying name for a particular implementation of Stats::Sink produced by the * factory. diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index c9b7da94f87d..c66ae47e042e 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -170,8 +170,9 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st if (udp_config.udp_listener_name().empty()) { udp_config.set_udp_listener_name(UdpListenerNames::get().RawUdp); } - auto& config_factory = Config::Utility::getAndCheckFactory( - udp_config.udp_listener_name()); + auto& config_factory = + Config::Utility::getAndCheckFactoryByName( + udp_config.udp_listener_name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig(udp_config, validation_visitor_, config_factory); udp_listener_factory_ = config_factory.createActiveUdpListenerFactory(*message); @@ -246,7 +247,7 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st // Add original dst listener filter if 'use_original_dst' flag is set. if (PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, use_original_dst, false)) { auto& factory = - Config::Utility::getAndCheckFactory( + Config::Utility::getAndCheckFactoryByName( Extensions::ListenerFilters::ListenerFilterNames::get().OriginalDst); listener_filter_factories_.push_back( factory.createFilterFactoryFromProto(Envoy::ProtobufWkt::Empty(), *this)); @@ -257,7 +258,7 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st // selected. if (PROTOBUF_GET_WRAPPED_OR_DEFAULT(config.filter_chains()[0], use_proxy_proto, false)) { auto& factory = - Config::Utility::getAndCheckFactory( + Config::Utility::getAndCheckFactoryByName( Extensions::ListenerFilters::ListenerFilterNames::get().ProxyProtocol); listener_filter_factories_.push_back( factory.createFilterFactoryFromProto(Envoy::ProtobufWkt::Empty(), *this)); @@ -287,7 +288,7 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st ENVOY_LOG(warn, "{}", message); auto& factory = - Config::Utility::getAndCheckFactory( + Config::Utility::getAndCheckFactoryByName( Extensions::ListenerFilters::ListenerFilterNames::get().TlsInspector); listener_filter_factories_.push_back( factory.createFilterFactoryFromProto(Envoy::ProtobufWkt::Empty(), *this)); diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index ef03a703e843..f071bd6fa27c 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -87,16 +87,15 @@ std::vector ProdListenerComponentFactory::createNetwor std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { const auto& proto_config = filters[i]; - const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " filter #{}:", i); - ENVOY_LOG(debug, " name: {}", string_name); + ENVOY_LOG(debug, " name: {}", proto_config.name()); ENVOY_LOG(debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.config(), true)); // Now see if there is a factory that will accept the config. auto& factory = Config::Utility::getAndCheckFactory( - string_name); + proto_config); Config::Utility::validateTerminalFilters(filters[i].name(), "network", factory.isTerminalFilter(), i == filters.size() - 1); @@ -116,16 +115,15 @@ ProdListenerComponentFactory::createListenerFilterFactoryList_( std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { const auto& proto_config = filters[i]; - const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " filter #{}:", i); - ENVOY_LOG(debug, " name: {}", string_name); + ENVOY_LOG(debug, " name: {}", proto_config.name()); ENVOY_LOG(debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.config(), true)); // Now see if there is a factory that will accept the config. auto& factory = Config::Utility::getAndCheckFactory( - string_name); + proto_config); auto message = Config::Utility::translateToFactoryConfig( proto_config, context.messageValidationVisitor(), factory); ret.push_back(factory.createFilterFactoryFromProto(*message, context)); @@ -140,16 +138,15 @@ ProdListenerComponentFactory::createUdpListenerFilterFactoryList_( std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { const auto& proto_config = filters[i]; - const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " filter #{}:", i); - ENVOY_LOG(debug, " name: {}", string_name); + ENVOY_LOG(debug, " name: {}", proto_config.name()); ENVOY_LOG(debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.config(), true)); // Now see if there is a factory that will accept the config. auto& factory = Config::Utility::getAndCheckFactory( - string_name); + proto_config); auto message = Config::Utility::translateToFactoryConfig( proto_config, context.messageValidationVisitor(), factory); @@ -759,7 +756,7 @@ std::unique_ptr ListenerFilterChainFactoryBuilder::buildFi } auto& config_factory = Config::Utility::getAndCheckFactory< - Server::Configuration::DownstreamTransportSocketConfigFactory>(transport_socket.name()); + Server::Configuration::DownstreamTransportSocketConfigFactory>(transport_socket); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( transport_socket, parent_.messageValidationVisitor(), config_factory); diff --git a/source/server/overload_manager_impl.cc b/source/server/overload_manager_impl.cc index 8195502cbccd..56ec284a06b9 100644 --- a/source/server/overload_manager_impl.cc +++ b/source/server/overload_manager_impl.cc @@ -109,7 +109,7 @@ OverloadManagerImpl::OverloadManagerImpl( const auto& name = resource.name(); ENVOY_LOG(debug, "Adding resource monitor for {}", name); auto& factory = - Config::Utility::getAndCheckFactory(name); + Config::Utility::getAndCheckFactory(resource); auto config = Config::Utility::translateToFactoryConfig(resource, validation_visitor, factory); auto monitor = factory.createResourceMonitor(*config, context); diff --git a/test/common/config/registry_test.cc b/test/common/config/registry_test.cc index 3b951e561222..1708ef3206e5 100644 --- a/test/common/config/registry_test.cc +++ b/test/common/config/registry_test.cc @@ -17,6 +17,8 @@ class InternalFactory { public: virtual ~InternalFactory() = default; virtual std::string name() PURE; + static std::string category() { return ""; } + static std::string type() { return ""; } }; class TestInternalFactory : public InternalFactory { @@ -51,6 +53,7 @@ class PublishedFactory { virtual ~PublishedFactory() = default; virtual std::string name() PURE; static std::string category() { return "testing.published"; } + static std::string type() { return ""; } }; class TestPublishedFactory : public PublishedFactory { diff --git a/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc b/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc index 641eb5409ee4..ca2699a1e721 100644 --- a/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc +++ b/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc @@ -20,7 +20,8 @@ class ActiveQuicListenerFactoryPeer { TEST(ActiveQuicListenerConfigTest, CreateActiveQuicListenerFactory) { std::string listener_name = QuicListenerName; auto& config_factory = - Config::Utility::getAndCheckFactory(listener_name); + Config::Utility::getAndCheckFactoryByName( + listener_name); ProtobufTypes::MessagePtr config = config_factory.createEmptyConfigProto(); std::string yaml = R"EOF( diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index f8cc85fafeb7..1d0813a3605a 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -61,7 +61,7 @@ class ConnectionHandlerTest : public testing::Test, protected Logger::Loggable(listener_name) + Config::Utility::getAndCheckFactoryByName(listener_name) .createActiveUdpListenerFactory(dummy); ON_CALL(*socket_, socketType()).WillByDefault(Return(socket_type)); } diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index 859ee88005f5..096850399a05 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -455,6 +455,7 @@ class TestFactory { virtual ~TestFactory() = default; virtual std::string name() PURE; static std::string category() { return "test"; } + static std::string type() { return ""; } }; class TestTestFactory : public TestFactory { @@ -467,6 +468,7 @@ class TestingFactory { virtual ~TestingFactory() = default; virtual std::string name() PURE; static std::string category() { return "testing"; } + static std::string type() { return ""; } }; class TestTestingFactory : public TestingFactory { From b2aee3e4086fcb6a5a5fd3ba1bf43f4a89977a28 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Tue, 17 Dec 2019 23:10:49 -0800 Subject: [PATCH 02/12] fix some tests Signed-off-by: Kuat Yessenov --- include/envoy/registry/registry.h | 7 ++++++- include/envoy/upstream/retry.h | 4 ---- .../quic_listeners/quiche/quic_transport_socket_factory.h | 4 ++++ test/common/upstream/upstream_impl_test.cc | 2 ++ test/integration/xds_integration_test.cc | 1 + test/server/configuration_impl_test.cc | 6 +++--- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/envoy/registry/registry.h b/include/envoy/registry/registry.h index 876834fb8dfc..ed134d0e1cb6 100644 --- a/include/envoy/registry/registry.h +++ b/include/envoy/registry/registry.h @@ -234,7 +234,7 @@ template class FactoryRegistry : public Logger::Loggablesecond; @@ -276,6 +276,11 @@ template class FactoryRegistry : public Logger::Loggablemutable_listeners(0); auto* filter_chain = listener->mutable_filter_chains(0); filter_chain->mutable_filters(0)->set_name("grewgragra"); + filter_chain->mutable_filters(0)->clear_typed_config(); }); EXPECT_DEATH_LOG_TO_STDERR(initialize(), "Didn't find a registered implementation for name: 'grewgragra'"); diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index e591c4197f5e..e441f0d02787 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -271,9 +271,9 @@ TEST_F(ConfigurationImplTest, ConfigurationFailsWhenInvalidTracerSpecified) { auto bootstrap = Upstream::parseBootstrapFromV2Json(json); MainImpl config; - EXPECT_THROW_WITH_MESSAGE(config.initialize(bootstrap, server_, cluster_manager_factory_), - EnvoyException, - "Didn't find a registered implementation for name: 'invalid'"); + EXPECT_THROW_WITH_MESSAGE( + config.initialize(bootstrap, server_, cluster_manager_factory_), EnvoyException, + "Didn't find a registered implementation for type: 'envoy.config.trace.v2.LightstepConfig'"); } TEST_F(ConfigurationImplTest, ProtoSpecifiedStatsSink) { From e249c8728df3313e10ef8316b05aee6ee79b97d7 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Wed, 18 Dec 2019 22:50:47 -0800 Subject: [PATCH 03/12] testing Signed-off-by: Kuat Yessenov --- source/common/config/api_type_oracle.cc | 9 +++++++++ source/common/config/api_type_oracle.h | 6 ++++++ source/common/config/utility.cc | 1 - source/common/config/utility.h | 17 +++++++++++++---- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/source/common/config/api_type_oracle.cc b/source/common/config/api_type_oracle.cc index 3381b4bdd3c7..64d510bb14c9 100644 --- a/source/common/config/api_type_oracle.cc +++ b/source/common/config/api_type_oracle.cc @@ -69,5 +69,14 @@ ApiTypeOracle::inferEarlierVersionDescriptor(absl::string_view extension_name, return nullptr; } +absl::optional ApiTypeOracle::inferEarlierExtension(absl::string_view config_type) { + for (const auto& it : v2ApiTypeMap()) { + if (config_type == it.second) { + return it.first; + } + } + return {}; +} + } // namespace Config } // namespace Envoy diff --git a/source/common/config/api_type_oracle.h b/source/common/config/api_type_oracle.h index b1694330fa07..da3ee9fecf16 100644 --- a/source/common/config/api_type_oracle.h +++ b/source/common/config/api_type_oracle.h @@ -3,6 +3,7 @@ #include "common/protobuf/protobuf.h" #include "absl/strings/string_view.h" +#include "absl/types/optional.h" namespace Envoy { namespace Config { @@ -25,6 +26,11 @@ class ApiTypeOracle { inferEarlierVersionDescriptor(absl::string_view extension_name, const ProtobufWkt::Any& typed_config, absl::string_view target_type); + + /** + * Infers an extension name for an earlier version of the configuration proto. + */ + static absl::optional inferEarlierExtension(absl::string_view config_type); }; } // namespace Config diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index 75b269fea88b..1f8c65cd8dd1 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -15,7 +15,6 @@ #include "common/common/fmt.h" #include "common/common/hex.h" #include "common/common/utility.h" -#include "common/config/api_type_oracle.h" #include "common/config/resources.h" #include "common/config/version_converter.h" #include "common/config/well_known_names.h" diff --git a/source/common/config/utility.h b/source/common/config/utility.h index 07d6f7759dbb..beb518442d84 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -21,6 +21,7 @@ #include "common/common/backoff_strategy.h" #include "common/common/hash.h" #include "common/common/hex.h" +#include "common/config/api_type_oracle.h" #include "common/grpc/common.h" #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" @@ -240,11 +241,19 @@ class Utility { if (!type.empty() && type != struct_type && type != empty_type) { Factory* factory = Registry::FactoryRegistry::getFactoryByType(type); - if (factory == nullptr) { - throw EnvoyException( - fmt::format("Didn't find a registered implementation for type: '{}'", type)); + if (factory != nullptr) { + return *factory; } - return *factory; + + // try to look up a deprecated type + auto earlier_version = ApiTypeOracle::inferEarlierExtension(type); + if (earlier_version) { + // return Utility::getAndCheckFactoryByName(earlier_version.value()); + return Utility::getAndCheckFactoryByName(name); + } + + throw EnvoyException( + fmt::format("Didn't find a registered implementation for type: '{}'", type)); } } return Utility::getAndCheckFactoryByName(name); From 217512ee6bd4e5a27606efa0b917d659d70255ed Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Mon, 23 Dec 2019 17:02:37 -0800 Subject: [PATCH 04/12] make smaller change Signed-off-by: Kuat Yessenov --- include/envoy/config/BUILD | 1 + include/envoy/config/typed_config.h | 39 ++++++++--- include/envoy/config/typed_metadata.h | 15 +--- include/envoy/grpc/BUILD | 1 + include/envoy/grpc/google_grpc_creds.h | 17 +---- include/envoy/network/BUILD | 1 + include/envoy/network/resolver.h | 17 +---- include/envoy/registry/registry.h | 14 ++-- include/envoy/server/BUILD | 6 +- include/envoy/server/access_log_config.h | 15 +--- .../envoy/server/active_udp_listener_config.h | 17 +---- include/envoy/server/filter_config.h | 70 +++---------------- include/envoy/server/health_checker_config.h | 17 +---- .../envoy/server/resource_monitor_config.h | 15 +--- include/envoy/server/tracer_config.h | 15 +--- .../envoy/server/transport_socket_config.h | 22 +----- include/envoy/singleton/BUILD | 1 + include/envoy/singleton/manager.h | 9 ++- include/envoy/ssl/BUILD | 1 + include/envoy/ssl/context_manager.h | 8 +-- include/envoy/ssl/private_key/BUILD | 1 + .../ssl/private_key/private_key_config.h | 17 +---- include/envoy/upstream/BUILD | 1 + include/envoy/upstream/cluster_factory.h | 17 +---- include/envoy/upstream/retry.h | 20 ++---- source/common/access_log/access_log_impl.h | 15 +--- source/common/config/api_type_oracle.cc | 9 --- source/common/config/api_type_oracle.h | 6 -- source/common/config/utility.cc | 3 + source/common/config/utility.h | 45 +----------- source/common/grpc/google_grpc_creds_impl.cc | 2 +- source/common/http/http3/BUILD | 1 + source/common/http/http3/quic_codec_factory.h | 21 +++--- source/common/network/resolver_impl.cc | 2 +- source/common/upstream/cluster_factory_impl.h | 2 +- .../extensions/access_loggers/file/config.cc | 2 +- .../extensions/access_loggers/file/config.h | 2 +- .../access_loggers/grpc/http_config.cc | 2 +- .../access_loggers/grpc/http_config.h | 2 +- .../access_loggers/grpc/tcp_config.cc | 2 +- .../access_loggers/grpc/tcp_config.h | 2 +- source/extensions/common/wasm/null/BUILD | 1 + .../common/wasm/null/null_vm_plugin.h | 18 ++--- .../http/common/empty_http_filter_config.h | 2 +- .../filters/http/common/factory_base.h | 2 +- .../filters/listener/http_inspector/config.cc | 2 +- .../filters/listener/original_dst/config.cc | 2 +- .../original_src_config_factory.h | 2 +- .../filters/listener/proxy_protocol/config.cc | 2 +- .../filters/listener/tls_inspector/config.cc | 2 +- .../filters/network/common/factory_base.h | 2 +- .../filters/network/dubbo_proxy/BUILD | 2 + .../dubbo_proxy/filters/factory_base.h | 2 +- .../dubbo_proxy/filters/filter_config.h | 15 +--- .../filters/network/dubbo_proxy/protocol.h | 19 ++--- .../filters/network/dubbo_proxy/router/BUILD | 1 + .../network/dubbo_proxy/router/route.h | 19 ++--- .../filters/network/dubbo_proxy/serializer.h | 19 ++--- .../extensions/filters/network/echo/config.cc | 2 +- .../filters/network/sni_cluster/config.h | 2 +- .../filters/network/thrift_proxy/BUILD | 2 + .../thrift_proxy/filters/factory_base.h | 2 +- .../thrift_proxy/filters/filter_config.h | 15 +--- .../filters/network/thrift_proxy/protocol.h | 19 ++--- .../filters/network/thrift_proxy/transport.h | 19 ++--- .../extensions/filters/udp/udp_proxy/config.h | 2 +- .../grpc_credentials/aws_iam/config.h | 2 +- .../grpc_credentials/example/config.h | 2 +- .../file_based_metadata/config.h | 2 +- .../extensions/health_checkers/redis/config.h | 2 +- .../quiche/active_quic_listener_config.cc | 2 +- .../quiche/active_quic_listener_config.h | 2 +- .../quic_listeners/quiche/codec_impl.h | 4 +- .../quiche/quic_transport_socket_factory.h | 8 ++- .../resource_monitors/common/factory_base.h | 4 +- .../retry/host/omit_canary_hosts/config.h | 4 +- .../retry/host/previous_hosts/config.h | 4 +- .../priority/previous_priorities/config.h | 2 +- .../stat_sinks/dog_statsd/config.cc | 2 +- .../extensions/stat_sinks/dog_statsd/config.h | 2 +- .../extensions/stat_sinks/hystrix/config.cc | 2 +- source/extensions/stat_sinks/hystrix/config.h | 2 +- .../stat_sinks/metrics_service/config.cc | 4 +- .../stat_sinks/metrics_service/config.h | 2 +- source/extensions/stat_sinks/statsd/config.cc | 2 +- source/extensions/stat_sinks/statsd/config.h | 2 +- .../extensions/tracers/common/factory_base.h | 2 +- .../transport_sockets/alts/config.h | 2 +- .../transport_sockets/raw_buffer/config.h | 2 +- .../extensions/transport_sockets/tap/config.h | 2 +- .../extensions/transport_sockets/tls/config.h | 2 +- .../server/active_raw_udp_listener_config.cc | 4 +- .../server/active_raw_udp_listener_config.h | 2 +- source/server/config_validation/server.cc | 3 +- source/server/configuration_impl.h | 15 +--- source/server/server.cc | 2 +- .../common/access_log/access_log_impl_test.cc | 4 +- test/common/config/BUILD | 1 + test/common/config/registry_test.cc | 19 +++-- test/common/network/resolver_impl_test.cc | 2 +- .../upstream/cluster_manager_impl_test.cc | 2 +- .../upstream/transport_socket_matcher_test.cc | 2 +- test/common/upstream/upstream_impl_test.cc | 12 ++-- .../filters/network/dubbo_proxy/mocks.h | 8 ++- .../network/dubbo_proxy/router_test.cc | 6 +- .../network/thrift_proxy/router_test.cc | 4 +- .../tls/test_private_key_method_provider.h | 2 +- .../cluster_filter_integration_test.cc | 2 +- .../filter_manager_integration_test.h | 2 +- .../tcp_conn_pool_integration_test.cc | 4 +- test/integration/test_host_predicate_config.h | 2 +- test/integration/xds_integration_test.cc | 1 - test/mocks/network/mocks.h | 2 +- test/mocks/upstream/mocks.h | 4 +- test/server/BUILD | 1 + test/server/configuration_impl_test.cc | 6 +- test/server/listener_manager_impl_test.cc | 8 +-- test/server/options_impl_test.cc | 17 ++--- test/server/server_test.cc | 4 +- test/test_common/registry.h | 2 +- 120 files changed, 281 insertions(+), 578 deletions(-) diff --git a/include/envoy/config/BUILD b/include/envoy/config/BUILD index 3a2db9c1c0c6..003efb8e9443 100644 --- a/include/envoy/config/BUILD +++ b/include/envoy/config/BUILD @@ -70,6 +70,7 @@ envoy_cc_library( name = "typed_metadata_interface", hdrs = ["typed_metadata.h"], deps = [ + ":typed_config_interface", "//source/common/protobuf", ], ) diff --git a/include/envoy/config/typed_config.h b/include/envoy/config/typed_config.h index c7676767e232..b1e46501ad4a 100644 --- a/include/envoy/config/typed_config.h +++ b/include/envoy/config/typed_config.h @@ -8,10 +8,38 @@ namespace Envoy { namespace Config { /** - * Base class for config defined by a typed proto message. + * Base class for an extension factory. */ -class TypedConfig { +class UntypedFactory { public: + virtual ~UntypedFactory() = default; + + /** + * Name of the factory, a reversed DNS name is encouraged to avoid cross-org conflict. + * It's used as key in the metadata map, as well as key in the factory registry. + */ + virtual const std::string name() const PURE; + + /** + * @return std::string the identifying category name for objects + * created by this factory. Used for automatic registration with + * FactoryCategoryRegistry. + */ + virtual const std::string category() const PURE; + + /** + * @return configuration proto full name, or empty for untyped factories. + */ + virtual const std::string configType() { return ""; } +}; + +/** + * Base class for an extension factory configured by a typed proto message. + */ +class TypedFactory : public UntypedFactory { +public: + virtual ~TypedFactory() = default; + /** * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The config, which * arrives in an opaque google.protobuf.Struct message, will be converted to JSON and then parsed @@ -19,18 +47,13 @@ class TypedConfig { */ virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - /** - * @return config proto full name - */ - virtual std::string type() { + const std::string configType() override { auto ptr = createEmptyConfigProto(); if (ptr == nullptr) { return ""; } return ptr->GetDescriptor()->full_name(); } - - virtual ~TypedConfig() = default; }; } // namespace Config diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index 6536ec9961a5..872be00df80a 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -4,6 +4,7 @@ #include #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "common/protobuf/protobuf.h" @@ -50,19 +51,10 @@ class TypedMetadata { * Typed metadata should implement this factory and register via Registry::registerFactory or the * convenience class RegisterFactory. */ -class TypedMetadataFactory { +class TypedMetadataFactory : public UntypedFactory { public: virtual ~TypedMetadataFactory() = default; - /** - * Name of the factory, a reversed DNS name is encouraged to avoid cross-org conflict. - * It's used as key in the metadata map, as well as key in the factory registry. - * When building a TypedMetadata from envoy::api::v2::core::Metadata, if the key is not found, the - * parse will not be called and the corresponding typedMetadata entry will be set to nullptr. - * @return the name of the factory. - */ - virtual const std::string name() const PURE; - /** * Convert the google.protobuf.Struct into an instance of TypedMetadata::Object. * It should throw an EnvoyException in case the conversion can't be completed. @@ -73,8 +65,7 @@ class TypedMetadataFactory { virtual std::unique_ptr parse(const ProtobufWkt::Struct& data) const PURE; - static std::string category() { return "typed_metadata"; } - static std::string type() { return ""; } + const std::string category() const override { return "typed_metadata"; } }; } // namespace Config diff --git a/include/envoy/grpc/BUILD b/include/envoy/grpc/BUILD index 6070ca012270..40f92ba81024 100644 --- a/include/envoy/grpc/BUILD +++ b/include/envoy/grpc/BUILD @@ -50,6 +50,7 @@ envoy_cc_library( ], deps = [ "//include/envoy/api:api_interface", + "//include/envoy/config:typed_config_interface", "@envoy_api//envoy/api/v2/core:pkg_cc_proto", ], ) diff --git a/include/envoy/grpc/google_grpc_creds.h b/include/envoy/grpc/google_grpc_creds.h index 391d8df20f3b..ba5354ff046e 100644 --- a/include/envoy/grpc/google_grpc_creds.h +++ b/include/envoy/grpc/google_grpc_creds.h @@ -5,6 +5,7 @@ #include "envoy/api/api.h" #include "envoy/api/v2/core/grpc_service.pb.h" #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "grpcpp/grpcpp.h" @@ -14,7 +15,7 @@ namespace Grpc { /** * Interface for all Google gRPC credentials factories. */ -class GoogleGrpcCredentialsFactory { +class GoogleGrpcCredentialsFactory : public Config::UntypedFactory { public: virtual ~GoogleGrpcCredentialsFactory() = default; @@ -34,19 +35,7 @@ class GoogleGrpcCredentialsFactory { getChannelCredentials(const envoy::api::v2::core::GrpcService& grpc_service_config, Api::Api& api) PURE; - /** - * @return std::string the identifying name for a particular implementation of - * a Google gRPC credentials factory. - */ - virtual std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "grpc_credentials"; } - static std::string type() { return ""; } + const std::string category() const override { return "grpc_credentials"; } }; } // namespace Grpc diff --git a/include/envoy/network/BUILD b/include/envoy/network/BUILD index c4c89fee0caa..6e49571d8b20 100644 --- a/include/envoy/network/BUILD +++ b/include/envoy/network/BUILD @@ -127,6 +127,7 @@ envoy_cc_library( hdrs = ["resolver.h"], deps = [ ":address_interface", + "//include/envoy/config:typed_config_interface", "@envoy_api//envoy/api/v2/core:pkg_cc_proto", ], ) diff --git a/include/envoy/network/resolver.h b/include/envoy/network/resolver.h index 380454e9aecd..6182f8e97b83 100644 --- a/include/envoy/network/resolver.h +++ b/include/envoy/network/resolver.h @@ -7,6 +7,7 @@ #include "envoy/api/v2/core/address.pb.h" #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "envoy/network/address.h" namespace Envoy { @@ -16,7 +17,7 @@ namespace Address { /** * Interface for all network address resolvers. */ -class Resolver { +class Resolver : public Config::UntypedFactory { public: virtual ~Resolver() = default; @@ -28,19 +29,7 @@ class Resolver { virtual InstanceConstSharedPtr resolve(const envoy::api::v2::core::SocketAddress& socket_address) PURE; - /** - * @return std::string the identifying name for a particular implementation of - * a resolver. - */ - virtual std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "resolvers"; } - static std::string type() { return ""; } + const std::string category() const override { return "resolvers"; } }; } // namespace Address diff --git a/include/envoy/registry/registry.h b/include/envoy/registry/registry.h index ed134d0e1cb6..db42e975157f 100644 --- a/include/envoy/registry/registry.h +++ b/include/envoy/registry/registry.h @@ -176,7 +176,7 @@ template class FactoryRegistry : public Logger::Loggable class FactoryRegistry : public Logger::Loggable class RegisterFactory { // register its category here. This means that we have to ignore // multiple attempts to register the same category and can't detect // duplicate categories. - if (!FactoryCategoryRegistry::isRegistered(Base::category())) { - FactoryCategoryRegistry::registerCategory(Base::category(), + if (!FactoryCategoryRegistry::isRegistered(instance_.category())) { + FactoryCategoryRegistry::registerCategory(instance_.category(), new FactoryRegistryProxyImpl()); } } @@ -343,8 +339,8 @@ template class RegisterFactory { FactoryRegistry::registerFactory(instance_, deprecated_name, instance_.name()); } - if (!FactoryCategoryRegistry::isRegistered(Base::category())) { - FactoryCategoryRegistry::registerCategory(Base::category(), + if (!FactoryCategoryRegistry::isRegistered(instance_.category())) { + FactoryCategoryRegistry::registerCategory(instance_.category(), new FactoryRegistryProxyImpl()); } } diff --git a/include/envoy/server/BUILD b/include/envoy/server/BUILD index 93a214f6c241..a6d8441355ab 100644 --- a/include/envoy/server/BUILD +++ b/include/envoy/server/BUILD @@ -73,6 +73,7 @@ envoy_cc_library( name = "health_checker_config_interface", hdrs = ["health_checker_config.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//include/envoy/upstream:health_checker_interface", "@envoy_api//envoy/api/v2/core:pkg_cc_proto", ], @@ -269,5 +270,8 @@ envoy_cc_library( envoy_cc_library( name = "active_udp_listener_config_interface", hdrs = ["active_udp_listener_config.h"], - deps = ["//include/envoy/network:connection_handler_interface"], + deps = [ + "//include/envoy/config:typed_config_interface", + "//include/envoy/network:connection_handler_interface", + ], ) diff --git a/include/envoy/server/access_log_config.h b/include/envoy/server/access_log_config.h index c06b5e76cef4..b4dcff783815 100644 --- a/include/envoy/server/access_log_config.h +++ b/include/envoy/server/access_log_config.h @@ -16,7 +16,7 @@ namespace Configuration { * Implemented for each AccessLog::Instance and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class AccessLogInstanceFactory : public Config::TypedConfig { +class AccessLogInstanceFactory : public Config::TypedFactory { public: virtual ~AccessLogInstanceFactory() = default; @@ -33,18 +33,7 @@ class AccessLogInstanceFactory : public Config::TypedConfig { AccessLog::FilterPtr&& filter, FactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular AccessLog::Instance implementation - * produced by the factory. - */ - virtual std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "access_loggers"; } + const std::string category() const override { return "access_loggers"; } }; } // namespace Configuration diff --git a/include/envoy/server/active_udp_listener_config.h b/include/envoy/server/active_udp_listener_config.h index 812e044cf37d..4235bdb02eb2 100644 --- a/include/envoy/server/active_udp_listener_config.h +++ b/include/envoy/server/active_udp_listener_config.h @@ -1,5 +1,6 @@ #pragma once +#include "envoy/config/typed_config.h" #include "envoy/network/connection_handler.h" #include "common/protobuf/protobuf.h" @@ -11,7 +12,7 @@ namespace Server { * Interface to create udp listener according to * envoy::api::v2::listener::UdpListenerConfig.udp_listener_name. */ -class ActiveUdpListenerConfigFactory { +class ActiveUdpListenerConfigFactory : public Config::UntypedFactory { public: virtual ~ActiveUdpListenerConfigFactory() = default; @@ -23,19 +24,7 @@ class ActiveUdpListenerConfigFactory { virtual Network::ActiveUdpListenerFactoryPtr createActiveUdpListenerFactory(const Protobuf::Message& message) PURE; - /** - * Used to identify which udp listener to create: quic or raw udp. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "udp_listeners"; } - - static std::string type() { return ""; } + const std::string category() const override { return "udp_listeners"; } }; } // namespace Server diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index 54acd7f82fc7..c0bee664b071 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -212,15 +212,9 @@ class ListenerFactoryContext : public virtual FactoryContext { /** * Common interface for listener filters and UDP listener filters */ -class ListenerFilterConfigFactoryBase : public Config::TypedConfig { +class ListenerFilterConfigFactoryBase : public Config::TypedFactory { public: virtual ~ListenerFilterConfigFactoryBase() = default; - - /** - * @return std::string the identifying name for a particular implementation of a listener filter - * produced by the factory. - */ - virtual std::string name() PURE; }; /** @@ -244,12 +238,7 @@ class NamedListenerFilterConfigFactory : public ListenerFilterConfigFactoryBase createFilterFactoryFromProto(const Protobuf::Message& config, ListenerFactoryContext& context) PURE; - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "filters.listener"; } + const std::string category() const override { return "filters.listener"; } }; /** @@ -272,19 +261,14 @@ class NamedUdpListenerFilterConfigFactory : public ListenerFilterConfigFactoryBa createFilterFactoryFromProto(const Protobuf::Message& config, ListenerFactoryContext& context) PURE; - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "filters.udp_listener"; } + const std::string category() const override { return "filters.udp_listener"; } }; /** * Implemented by filter factories that require more options to process the protocol used by the * upstream cluster. */ -class ProtocolOptionsFactory { +class ProtocolOptionsFactory : public Config::TypedFactory { public: virtual ~ProtocolOptionsFactory() = default; @@ -315,7 +299,7 @@ class ProtocolOptionsFactory { * Implemented by each network filter and registered via Registry::registerFactory() * or the convenience class RegisterFactory. */ -class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory, public Config::TypedConfig { +class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory { public: ~NamedNetworkFilterConfigFactory() override = default; @@ -330,18 +314,7 @@ class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory, public Co virtual Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message& config, FactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a network filter - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "filters.network"; } + const std::string category() const override { return "filters.network"; } /** * @return bool true if this filter must be the last filter in a filter chain, false otherwise. @@ -353,8 +326,7 @@ class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory, public Co * Implemented by each upstream cluster network filter and registered via * Registry::registerFactory() or the convenience class RegisterFactory. */ -class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory, - public Config::TypedConfig { +class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory { public: ~NamedUpstreamNetworkFilterConfigFactory() override = default; @@ -366,25 +338,14 @@ class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory, virtual Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message& config, CommonFactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a network filter - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "filters.upstream_network"; } + const std::string category() const override { return "filters.upstream_network"; } }; /** * Implemented by each HTTP filter and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory, public Config::TypedConfig { +class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory { public: ~NamedHttpFilterConfigFactory() override = default; @@ -423,18 +384,7 @@ class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory, public Confi return nullptr; } - /** - * @return std::string the identifying name for a particular implementation of an http filter - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "filters.http"; } + const std::string category() const override { return "filters.http"; } /** * @return bool true if this filter must be the last filter in a filter chain, false otherwise. diff --git a/include/envoy/server/health_checker_config.h b/include/envoy/server/health_checker_config.h index eeff37aace40..6423d50f0648 100644 --- a/include/envoy/server/health_checker_config.h +++ b/include/envoy/server/health_checker_config.h @@ -1,6 +1,7 @@ #pragma once #include "envoy/api/v2/core/health_check.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/runtime/runtime.h" #include "envoy/upstream/health_checker.h" @@ -55,7 +56,7 @@ class HealthCheckerFactoryContext { * Implemented by each custom health checker and registered via Registry::registerFactory() * or the convenience class RegisterFactory. */ -class CustomHealthCheckerFactory { +class CustomHealthCheckerFactory : public Config::UntypedFactory { public: virtual ~CustomHealthCheckerFactory() = default; @@ -72,19 +73,7 @@ class CustomHealthCheckerFactory { createCustomHealthChecker(const envoy::api::v2::core::HealthCheck& config, HealthCheckerFactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a custom health - * checker produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "health_checkers"; } - static std::string type() { return ""; } + const std::string category() const override { return "health_checkers"; } }; } // namespace Configuration diff --git a/include/envoy/server/resource_monitor_config.h b/include/envoy/server/resource_monitor_config.h index 1a93fcfe8260..a4720c44e2a9 100644 --- a/include/envoy/server/resource_monitor_config.h +++ b/include/envoy/server/resource_monitor_config.h @@ -39,7 +39,7 @@ class ResourceMonitorFactoryContext { * Implemented by each resource monitor and registered via Registry::registerFactory() * or the convenience class RegistryFactory. */ -class ResourceMonitorFactory : public Config::TypedConfig { +class ResourceMonitorFactory : public Config::TypedFactory { public: virtual ~ResourceMonitorFactory() = default; @@ -55,18 +55,7 @@ class ResourceMonitorFactory : public Config::TypedConfig { virtual ResourceMonitorPtr createResourceMonitor(const Protobuf::Message& config, ResourceMonitorFactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a resource - * monitor produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "resource_monitors"; } + const std::string category() const override { return "resource_monitors"; } }; } // namespace Configuration diff --git a/include/envoy/server/tracer_config.h b/include/envoy/server/tracer_config.h index 9715098cedc9..e14dddfef681 100644 --- a/include/envoy/server/tracer_config.h +++ b/include/envoy/server/tracer_config.h @@ -15,7 +15,7 @@ namespace Configuration { * Implemented by each Tracer and registered via Registry::registerFactory() or the convenience * class RegisterFactory. */ -class TracerFactory : public Config::TypedConfig { +class TracerFactory : public Config::TypedFactory { public: virtual ~TracerFactory() = default; @@ -30,18 +30,7 @@ class TracerFactory : public Config::TypedConfig { virtual Tracing::HttpTracerPtr createHttpTracer(const Protobuf::Message& config, Instance& server) PURE; - /** - * Returns the identifying name for a particular implementation of tracer produced by the - * factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "tracers"; } + const std::string category() const override { return "tracers"; } }; } // namespace Configuration diff --git a/include/envoy/server/transport_socket_config.h b/include/envoy/server/transport_socket_config.h index 78ceed411b5c..a35eaf6978b1 100644 --- a/include/envoy/server/transport_socket_config.h +++ b/include/envoy/server/transport_socket_config.h @@ -107,15 +107,9 @@ class TransportSocketFactoryContext { virtual Api::Api& api() PURE; }; -class TransportSocketConfigFactory : public Config::TypedConfig { +class TransportSocketConfigFactory : public Config::TypedFactory { public: virtual ~TransportSocketConfigFactory() = default; - - /** - * @return std::string the identifying name for a particular TransportSocketFactoryPtr - * implementation produced by the factory. - */ - virtual std::string name() const PURE; }; /** @@ -139,12 +133,7 @@ class UpstreamTransportSocketConfigFactory : public virtual TransportSocketConfi createTransportSocketFactory(const Protobuf::Message& config, TransportSocketFactoryContext& context) PURE; - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "transport_sockets.upstream"; } + const std::string category() const override { return "transport_sockets.upstream"; } }; /** @@ -171,12 +160,7 @@ class DownstreamTransportSocketConfigFactory : public virtual TransportSocketCon TransportSocketFactoryContext& context, const std::vector& server_names) PURE; - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "transport_sockets.downstream"; } + const std::string category() const override { return "transport_sockets.downstream"; } }; } // namespace Configuration diff --git a/include/envoy/singleton/BUILD b/include/envoy/singleton/BUILD index 23fd60851570..f47887a06244 100644 --- a/include/envoy/singleton/BUILD +++ b/include/envoy/singleton/BUILD @@ -18,6 +18,7 @@ envoy_cc_library( hdrs = ["manager.h"], deps = [ ":instance_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/registry", ], ) diff --git a/include/envoy/singleton/manager.h b/include/envoy/singleton/manager.h index c4bfa6f2f81c..75344aaedc8e 100644 --- a/include/envoy/singleton/manager.h +++ b/include/envoy/singleton/manager.h @@ -5,6 +5,7 @@ #include #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "envoy/registry/registry.h" #include "envoy/singleton/instance.h" @@ -14,12 +15,10 @@ namespace Singleton { /** * An abstract registration for a singleton entry. */ -class Registration { +class Registration : public Config::UntypedFactory { public: virtual ~Registration() = default; - virtual std::string name() PURE; - static std::string category() { return "singleton"; } - static std::string type() { return ""; } + const std::string category() const override { return "singleton"; } }; /** @@ -36,7 +35,7 @@ class Registration { */ template class RegistrationImpl : public Registration { public: - std::string name() override { return name_param; } + const std::string name() const override { return name_param; } }; /** diff --git a/include/envoy/ssl/BUILD b/include/envoy/ssl/BUILD index 179a34654ffd..15dbe4f01d0b 100644 --- a/include/envoy/ssl/BUILD +++ b/include/envoy/ssl/BUILD @@ -41,6 +41,7 @@ envoy_cc_library( ":context_config_interface", ":context_interface", "//include/envoy/common:time_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/stats:stats_interface", ], ) diff --git a/include/envoy/ssl/context_manager.h b/include/envoy/ssl/context_manager.h index 68e444c9baf1..e1282d421f42 100644 --- a/include/envoy/ssl/context_manager.h +++ b/include/envoy/ssl/context_manager.h @@ -3,6 +3,7 @@ #include #include "envoy/common/time.h" +#include "envoy/config/typed_config.h" #include "envoy/ssl/context.h" #include "envoy/ssl/context_config.h" #include "envoy/ssl/private_key/private_key.h" @@ -50,15 +51,14 @@ class ContextManager { using ContextManagerPtr = std::unique_ptr; -class ContextManagerFactory { +class ContextManagerFactory : public Config::UntypedFactory { public: virtual ~ContextManagerFactory() = default; virtual ContextManagerPtr createContextManager(TimeSource& time_source) PURE; // There could be only one factory thus the name is static. - static std::string name() { return "ssl_context_manager"; } - static std::string category() { return "ssl_context_manager"; } - static std::string type() { return ""; } + const std::string name() const override { return "ssl_context_manager"; } + const std::string category() const override { return "ssl_context_manager"; } }; } // namespace Ssl diff --git a/include/envoy/ssl/private_key/BUILD b/include/envoy/ssl/private_key/BUILD index 07bb3271816b..866cb26e5bd6 100644 --- a/include/envoy/ssl/private_key/BUILD +++ b/include/envoy/ssl/private_key/BUILD @@ -24,6 +24,7 @@ envoy_cc_library( hdrs = ["private_key_config.h"], deps = [ ":private_key_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/registry", "@envoy_api//envoy/api/v2/auth:pkg_cc_proto", ], diff --git a/include/envoy/ssl/private_key/private_key_config.h b/include/envoy/ssl/private_key/private_key_config.h index 95e675dd7f49..b2cea34671a5 100644 --- a/include/envoy/ssl/private_key/private_key_config.h +++ b/include/envoy/ssl/private_key/private_key_config.h @@ -1,6 +1,7 @@ #pragma once #include "envoy/api/v2/auth/cert.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/registry/registry.h" #include "envoy/ssl/private_key/private_key.h" @@ -9,7 +10,7 @@ namespace Ssl { // Base class which the private key operation provider implementations can register. -class PrivateKeyMethodProviderInstanceFactory { +class PrivateKeyMethodProviderInstanceFactory : public Config::UntypedFactory { public: virtual ~PrivateKeyMethodProviderInstanceFactory() = default; @@ -24,19 +25,7 @@ class PrivateKeyMethodProviderInstanceFactory { const envoy::api::v2::auth::PrivateKeyProvider& config, Server::Configuration::TransportSocketFactoryContext& factory_context) PURE; - /** - * @return std::string the identifying name for a particular implementation of - * PrivateKeyMethodProvider produced by the factory. - */ - virtual std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects created by this factory. - * Used for automatic registration with FactoryCategoryRegistry. - */ - static std::string category() { return "tls.key_providers"; }; - - static std::string type() { return ""; }; + const std::string category() const override { return "tls.key_providers"; }; }; } // namespace Ssl diff --git a/include/envoy/upstream/BUILD b/include/envoy/upstream/BUILD index ef4eb94ce043..924fc1095c41 100644 --- a/include/envoy/upstream/BUILD +++ b/include/envoy/upstream/BUILD @@ -167,6 +167,7 @@ envoy_cc_library( ":resource_manager_interface", ":upstream_interface", "//include/envoy/common:callback", + "//include/envoy/config:typed_config_interface", "//include/envoy/config:typed_metadata_interface", "//include/envoy/http:codec_interface", "//include/envoy/network:connection_interface", diff --git a/include/envoy/upstream/cluster_factory.h b/include/envoy/upstream/cluster_factory.h index 6529c0a060f2..46da6e60f3fd 100644 --- a/include/envoy/upstream/cluster_factory.h +++ b/include/envoy/upstream/cluster_factory.h @@ -11,6 +11,7 @@ #include "envoy/access_log/access_log.h" #include "envoy/api/api.h" #include "envoy/api/v2/cds.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/event/dispatcher.h" #include "envoy/local_info/local_info.h" #include "envoy/network/dns.h" @@ -123,7 +124,7 @@ class ClusterFactoryContext { * Implemented by cluster and registered via Registry::registerFactory() or the convenience class * RegisterFactory. */ -class ClusterFactory { +class ClusterFactory : public Config::UntypedFactory { public: virtual ~ClusterFactory() = default; @@ -138,19 +139,7 @@ class ClusterFactory { virtual std::pair create(const envoy::api::v2::Cluster& cluster, ClusterFactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a cluster factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "clusters"; } - - virtual std::string type() const { return ""; } + const std::string category() const override { return "clusters"; } }; } // namespace Upstream diff --git a/include/envoy/upstream/retry.h b/include/envoy/upstream/retry.h index b50d4891c8a2..14451b12925b 100644 --- a/include/envoy/upstream/retry.h +++ b/include/envoy/upstream/retry.h @@ -76,7 +76,7 @@ using RetryHostPredicateSharedPtr = std::shared_ptr; /** * Factory for RetryPriority. */ -class RetryPriorityFactory : public Config::TypedConfig { +class RetryPriorityFactory : public Config::TypedFactory { public: virtual ~RetryPriorityFactory() = default; @@ -85,32 +85,20 @@ class RetryPriorityFactory : public Config::TypedConfig { ProtobufMessage::ValidationVisitor& validation_visitor, uint32_t retry_count) PURE; - virtual std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "retry_priorities"; } + const std::string category() const override { return "retry_priorities"; } }; /** * Factory for RetryHostPredicate. */ -class RetryHostPredicateFactory : public Config::TypedConfig { +class RetryHostPredicateFactory : public Config::TypedFactory { public: virtual ~RetryHostPredicateFactory() = default; virtual RetryHostPredicateSharedPtr createHostPredicate(const Protobuf::Message& config, uint32_t retry_count) PURE; - /** - * @return name name of this factory. - */ - virtual std::string name() PURE; - - static std::string category() { return "retry_host_predicates"; } + const std::string category() const override { return "retry_host_predicates"; } }; } // namespace Upstream diff --git a/source/common/access_log/access_log_impl.h b/source/common/access_log/access_log_impl.h index 1bce9764b393..5c6ad5d7a1ea 100644 --- a/source/common/access_log/access_log_impl.h +++ b/source/common/access_log/access_log_impl.h @@ -231,7 +231,7 @@ class GrpcStatusFilter : public Filter { /** * Extension filter factory that reads from ExtensionFilter proto. */ -class ExtensionFilterFactory : public Config::TypedConfig { +class ExtensionFilterFactory : public Config::TypedFactory { public: virtual ~ExtensionFilterFactory() = default; @@ -248,18 +248,7 @@ class ExtensionFilterFactory : public Config::TypedConfig { createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader& runtime, Runtime::RandomGenerator& random) PURE; - /** - * @return std::string the identifying name for a particular Filter implementation - * produced by the factory. - */ - virtual std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "access_logger.extension_filters"; } + const std::string category() const override { return "access_logger.extension_filters"; } }; /** diff --git a/source/common/config/api_type_oracle.cc b/source/common/config/api_type_oracle.cc index 64d510bb14c9..3381b4bdd3c7 100644 --- a/source/common/config/api_type_oracle.cc +++ b/source/common/config/api_type_oracle.cc @@ -69,14 +69,5 @@ ApiTypeOracle::inferEarlierVersionDescriptor(absl::string_view extension_name, return nullptr; } -absl::optional ApiTypeOracle::inferEarlierExtension(absl::string_view config_type) { - for (const auto& it : v2ApiTypeMap()) { - if (config_type == it.second) { - return it.first; - } - } - return {}; -} - } // namespace Config } // namespace Envoy diff --git a/source/common/config/api_type_oracle.h b/source/common/config/api_type_oracle.h index da3ee9fecf16..b1694330fa07 100644 --- a/source/common/config/api_type_oracle.h +++ b/source/common/config/api_type_oracle.h @@ -3,7 +3,6 @@ #include "common/protobuf/protobuf.h" #include "absl/strings/string_view.h" -#include "absl/types/optional.h" namespace Envoy { namespace Config { @@ -26,11 +25,6 @@ class ApiTypeOracle { inferEarlierVersionDescriptor(absl::string_view extension_name, const ProtobufWkt::Any& typed_config, absl::string_view target_type); - - /** - * Infers an extension name for an earlier version of the configuration proto. - */ - static absl::optional inferEarlierExtension(absl::string_view config_type); }; } // namespace Config diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index 1f8c65cd8dd1..f0abdce9e249 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -15,6 +15,7 @@ #include "common/common/fmt.h" #include "common/common/hex.h" #include "common/common/utility.h" +#include "common/config/api_type_oracle.h" #include "common/config/resources.h" #include "common/config/version_converter.h" #include "common/config/well_known_names.h" @@ -23,6 +24,8 @@ #include "common/stats/stats_matcher_impl.h" #include "common/stats/tag_producer_impl.h" +#include "udpa/type/v1/typed_struct.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/utility.h b/source/common/config/utility.h index beb518442d84..87f7703a8834 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -21,14 +21,11 @@ #include "common/common/backoff_strategy.h" #include "common/common/hash.h" #include "common/common/hex.h" -#include "common/config/api_type_oracle.h" #include "common/grpc/common.h" #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" #include "common/singleton/const_singleton.h" -#include "udpa/type/v1/typed_struct.pb.h" - namespace Envoy { namespace Config { @@ -213,50 +210,12 @@ class Utility { /** * Get a Factory from the registry with error checking to ensure the name and the factory are - * valid. If the typed config references a proto that is neither Struct nor Empty, then the proto - * type is used to select a factory. + * valid. * @param message proto that contains fields 'name' and 'typed_config'. */ template static Factory& getAndCheckFactory(const ProtoMessage& message) { - const auto& name = message.name(); - - static const std::string struct_type = - ProtobufWkt::Struct::default_instance().GetDescriptor()->full_name(); - static const std::string empty_type = - ProtobufWkt::Empty::default_instance().GetDescriptor()->full_name(); - static const std::string typed_struct_type = - udpa::type::v1::TypedStruct::default_instance().GetDescriptor()->full_name(); - - if (message.has_typed_config()) { - absl::string_view type = - TypeUtil::typeUrlToDescriptorFullName(message.typed_config().type_url()); - - if (type == typed_struct_type) { - udpa::type::v1::TypedStruct typed_struct; - MessageUtil::unpackTo(message.typed_config(), typed_struct); - type = TypeUtil::typeUrlToDescriptorFullName(typed_struct.type_url()); - } - - if (!type.empty() && type != struct_type && type != empty_type) { - Factory* factory = Registry::FactoryRegistry::getFactoryByType(type); - - if (factory != nullptr) { - return *factory; - } - - // try to look up a deprecated type - auto earlier_version = ApiTypeOracle::inferEarlierExtension(type); - if (earlier_version) { - // return Utility::getAndCheckFactoryByName(earlier_version.value()); - return Utility::getAndCheckFactoryByName(name); - } - - throw EnvoyException( - fmt::format("Didn't find a registered implementation for type: '{}'", type)); - } - } - return Utility::getAndCheckFactoryByName(name); + return Utility::getAndCheckFactoryByName(message.name()); } /** diff --git a/source/common/grpc/google_grpc_creds_impl.cc b/source/common/grpc/google_grpc_creds_impl.cc index 86187ee3cb4a..94165054e992 100644 --- a/source/common/grpc/google_grpc_creds_impl.cc +++ b/source/common/grpc/google_grpc_creds_impl.cc @@ -135,7 +135,7 @@ class DefaultGoogleGrpcCredentialsFactory : public GoogleGrpcCredentialsFactory return CredsUtility::defaultChannelCredentials(grpc_service_config, api); } - std::string name() const override { return "envoy.grpc_credentials.default"; } + const std::string name() const override { return "envoy.grpc_credentials.default"; } }; /** diff --git a/source/common/http/http3/BUILD b/source/common/http/http3/BUILD index 67a18855fe7f..cadca40d0d25 100644 --- a/source/common/http/http3/BUILD +++ b/source/common/http/http3/BUILD @@ -12,6 +12,7 @@ envoy_cc_library( name = "quic_codec_factory_lib", hdrs = ["quic_codec_factory.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//include/envoy/http:codec_interface", "//include/envoy/network:connection_interface", ], diff --git a/source/common/http/http3/quic_codec_factory.h b/source/common/http/http3/quic_codec_factory.h index ded22c13ad36..a762a1328911 100644 --- a/source/common/http/http3/quic_codec_factory.h +++ b/source/common/http/http3/quic_codec_factory.h @@ -2,6 +2,7 @@ #include +#include "envoy/config/typed_config.h" #include "envoy/http/codec.h" #include "envoy/network/connection.h" @@ -9,31 +10,31 @@ namespace Envoy { namespace Http { // A factory to create Http::ServerConnection instance for QUIC. -class QuicHttpServerConnectionFactory { +class QuicHttpServerConnectionFactory : public Config::UntypedFactory { public: virtual ~QuicHttpServerConnectionFactory() {} - virtual std::string name() const PURE; - virtual std::unique_ptr createQuicServerConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; - static std::string category() { return "quic_client_codec"; } - static std::string type() { return ""; } + const std::string category() const override { return "quic_client_codec"; } + + // Prevents double registration for the same config proto + // const std::string configType() override { return ""; } }; // A factory to create Http::ClientConnection instance for QUIC. -class QuicHttpClientConnectionFactory { +class QuicHttpClientConnectionFactory : public Config::UntypedFactory { public: virtual ~QuicHttpClientConnectionFactory() {} - virtual std::string name() const PURE; - virtual std::unique_ptr createQuicClientConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; - static std::string category() { return "quic_server_codec"; } - static std::string type() { return ""; } + const std::string category() const override { return "quic_server_codec"; } + + // Prevents double registration for the same config proto + // const std::string configType() override { return ""; } }; } // namespace Http diff --git a/source/common/network/resolver_impl.cc b/source/common/network/resolver_impl.cc index f07bc304ae2a..d235fe3e4693 100644 --- a/source/common/network/resolver_impl.cc +++ b/source/common/network/resolver_impl.cc @@ -35,7 +35,7 @@ class IpResolver : public Resolver { } } - std::string name() const override { return Config::AddressResolverNames::get().IP; } + const std::string name() const override { return Config::AddressResolverNames::get().IP; } }; /** diff --git a/source/common/upstream/cluster_factory_impl.h b/source/common/upstream/cluster_factory_impl.h index 07ea992b4736..1de4465b796f 100644 --- a/source/common/upstream/cluster_factory_impl.h +++ b/source/common/upstream/cluster_factory_impl.h @@ -135,7 +135,7 @@ class ClusterFactoryImplBase : public ClusterFactory { // Upstream::ClusterFactory std::pair create(const envoy::api::v2::Cluster& cluster, ClusterFactoryContext& context) override; - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: ClusterFactoryImplBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/access_loggers/file/config.cc b/source/extensions/access_loggers/file/config.cc index 556037f5f65a..b62c317bc429 100644 --- a/source/extensions/access_loggers/file/config.cc +++ b/source/extensions/access_loggers/file/config.cc @@ -59,7 +59,7 @@ ProtobufTypes::MessagePtr FileAccessLogFactory::createEmptyConfigProto() { return ProtobufTypes::MessagePtr{new envoy::config::accesslog::v2::FileAccessLog()}; } -std::string FileAccessLogFactory::name() const { return AccessLogNames::get().File; } +const std::string FileAccessLogFactory::name() const { return AccessLogNames::get().File; } std::unordered_map FileAccessLogFactory::convertJsonFormatToMap(ProtobufWkt::Struct json_format) { diff --git a/source/extensions/access_loggers/file/config.h b/source/extensions/access_loggers/file/config.h index 7f3976adfc8b..f78ac2a0da7c 100644 --- a/source/extensions/access_loggers/file/config.h +++ b/source/extensions/access_loggers/file/config.h @@ -18,7 +18,7 @@ class FileAccessLogFactory : public Server::Configuration::AccessLogInstanceFact ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() const override; + const std::string name() const override; private: std::unordered_map convertJsonFormatToMap(ProtobufWkt::Struct config); diff --git a/source/extensions/access_loggers/grpc/http_config.cc b/source/extensions/access_loggers/grpc/http_config.cc index 89a050985b79..94fb35d1c601 100644 --- a/source/extensions/access_loggers/grpc/http_config.cc +++ b/source/extensions/access_loggers/grpc/http_config.cc @@ -39,7 +39,7 @@ ProtobufTypes::MessagePtr HttpGrpcAccessLogFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string HttpGrpcAccessLogFactory::name() const { return AccessLogNames::get().HttpGrpc; } +const std::string HttpGrpcAccessLogFactory::name() const { return AccessLogNames::get().HttpGrpc; } /** * Static registration for the HTTP gRPC access log. @see RegisterFactory. diff --git a/source/extensions/access_loggers/grpc/http_config.h b/source/extensions/access_loggers/grpc/http_config.h index c88a3a5ac62d..e508f8624a85 100644 --- a/source/extensions/access_loggers/grpc/http_config.h +++ b/source/extensions/access_loggers/grpc/http_config.h @@ -20,7 +20,7 @@ class HttpGrpcAccessLogFactory : public Server::Configuration::AccessLogInstance ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() const override; + const std::string name() const override; }; } // namespace HttpGrpc diff --git a/source/extensions/access_loggers/grpc/tcp_config.cc b/source/extensions/access_loggers/grpc/tcp_config.cc index 6af51e20b4bf..e5b21a4e8f81 100644 --- a/source/extensions/access_loggers/grpc/tcp_config.cc +++ b/source/extensions/access_loggers/grpc/tcp_config.cc @@ -38,7 +38,7 @@ ProtobufTypes::MessagePtr TcpGrpcAccessLogFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string TcpGrpcAccessLogFactory::name() const { return AccessLogNames::get().TcpGrpc; } +const std::string TcpGrpcAccessLogFactory::name() const { return AccessLogNames::get().TcpGrpc; } /** * Static registration for the TCP gRPC access log. @see RegisterFactory. diff --git a/source/extensions/access_loggers/grpc/tcp_config.h b/source/extensions/access_loggers/grpc/tcp_config.h index 39bc986146b9..29f410d8b112 100644 --- a/source/extensions/access_loggers/grpc/tcp_config.h +++ b/source/extensions/access_loggers/grpc/tcp_config.h @@ -20,7 +20,7 @@ class TcpGrpcAccessLogFactory : public Server::Configuration::AccessLogInstanceF ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() const override; + const std::string name() const override; }; } // namespace TcpGrpc diff --git a/source/extensions/common/wasm/null/BUILD b/source/extensions/common/wasm/null/BUILD index eed8e62d2e49..6dbc6e8d65a2 100644 --- a/source/extensions/common/wasm/null/BUILD +++ b/source/extensions/common/wasm/null/BUILD @@ -12,6 +12,7 @@ envoy_cc_library( name = "null_vm_plugin_interface", hdrs = ["null_vm_plugin.h"], deps = [ + "//include/envoy/config:typed_config_interface", "//source/extensions/common/wasm:wasm_vm_interface", "//source/extensions/common/wasm:well_known_names", ], diff --git a/source/extensions/common/wasm/null/null_vm_plugin.h b/source/extensions/common/wasm/null/null_vm_plugin.h index c534c8f6fe3e..cb401830fdd6 100644 --- a/source/extensions/common/wasm/null/null_vm_plugin.h +++ b/source/extensions/common/wasm/null/null_vm_plugin.h @@ -1,5 +1,7 @@ #pragma once +#include "envoy/config/typed_config.h" + #include "extensions/common/wasm/wasm_vm.h" namespace Envoy { @@ -26,23 +28,11 @@ class NullVmPlugin { * Pseudo-WASM plugins using the NullVM should implement this factory and register via * Registry::registerFactory or the convenience class RegisterFactory. */ -class NullVmPluginFactory { +class NullVmPluginFactory : public Config::UntypedFactory { public: virtual ~NullVmPluginFactory() = default; - /** - * Name of the plugin. - */ - virtual const std::string name() const PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "wasm.null_vms"; } - - static std::string type() { return ""; } + const std::string category() const override { return "wasm.null_vms"; } /** * Create an instance of the plugin. diff --git a/source/extensions/filters/http/common/empty_http_filter_config.h b/source/extensions/filters/http/common/empty_http_filter_config.h index c204aa7a21ac..4338acdeccab 100644 --- a/source/extensions/filters/http/common/empty_http_filter_config.h +++ b/source/extensions/filters/http/common/empty_http_filter_config.h @@ -32,7 +32,7 @@ class EmptyHttpFilterConfig : public Server::Configuration::NamedHttpFilterConfi return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: EmptyHttpFilterConfig(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/http/common/factory_base.h b/source/extensions/filters/http/common/factory_base.h index 71feb76c9e38..35a8593e36f8 100644 --- a/source/extensions/filters/http/common/factory_base.h +++ b/source/extensions/filters/http/common/factory_base.h @@ -40,7 +40,7 @@ class FactoryBase : public Server::Configuration::NamedHttpFilterConfigFactory { validator); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/listener/http_inspector/config.cc b/source/extensions/filters/listener/http_inspector/config.cc index 3a0833d6721f..377719b0e6a0 100644 --- a/source/extensions/filters/listener/http_inspector/config.cc +++ b/source/extensions/filters/listener/http_inspector/config.cc @@ -28,7 +28,7 @@ class HttpInspectorConfigFactory : public Server::Configuration::NamedListenerFi return std::make_unique(); } - std::string name() override { return ListenerFilterNames::get().HttpInspector; } + const std::string name() const override { return ListenerFilterNames::get().HttpInspector; } }; /** diff --git a/source/extensions/filters/listener/original_dst/config.cc b/source/extensions/filters/listener/original_dst/config.cc index c8117ca0369c..ef99384cdb0a 100644 --- a/source/extensions/filters/listener/original_dst/config.cc +++ b/source/extensions/filters/listener/original_dst/config.cc @@ -29,7 +29,7 @@ class OriginalDstConfigFactory : public Server::Configuration::NamedListenerFilt return std::make_unique(); } - std::string name() override { return ListenerFilterNames::get().OriginalDst; } + const std::string name() const override { return ListenerFilterNames::get().OriginalDst; } }; /** diff --git a/source/extensions/filters/listener/original_src/original_src_config_factory.h b/source/extensions/filters/listener/original_src/original_src_config_factory.h index 9ffda7d61e1d..6d176ca9dfed 100644 --- a/source/extensions/filters/listener/original_src/original_src_config_factory.h +++ b/source/extensions/filters/listener/original_src/original_src_config_factory.h @@ -21,7 +21,7 @@ class OriginalSrcConfigFactory : public Server::Configuration::NamedListenerFilt ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() override { return ListenerFilterNames::get().OriginalSrc; } + const std::string name() const override { return ListenerFilterNames::get().OriginalSrc; } }; } // namespace OriginalSrc diff --git a/source/extensions/filters/listener/proxy_protocol/config.cc b/source/extensions/filters/listener/proxy_protocol/config.cc index e267d994414a..e523df96e1b8 100644 --- a/source/extensions/filters/listener/proxy_protocol/config.cc +++ b/source/extensions/filters/listener/proxy_protocol/config.cc @@ -28,7 +28,7 @@ class ProxyProtocolConfigFactory : public Server::Configuration::NamedListenerFi return std::make_unique(); } - std::string name() override { return ListenerFilterNames::get().ProxyProtocol; } + const std::string name() const override { return ListenerFilterNames::get().ProxyProtocol; } }; /** diff --git a/source/extensions/filters/listener/tls_inspector/config.cc b/source/extensions/filters/listener/tls_inspector/config.cc index 8f18e2c98129..fe8b6d46a77d 100644 --- a/source/extensions/filters/listener/tls_inspector/config.cc +++ b/source/extensions/filters/listener/tls_inspector/config.cc @@ -30,7 +30,7 @@ class TlsInspectorConfigFactory : public Server::Configuration::NamedListenerFil return std::make_unique(); } - std::string name() override { return ListenerFilterNames::get().TlsInspector; } + const std::string name() const override { return ListenerFilterNames::get().TlsInspector; } }; /** diff --git a/source/extensions/filters/network/common/factory_base.h b/source/extensions/filters/network/common/factory_base.h index d72b4cd49765..8137262dd1a6 100644 --- a/source/extensions/filters/network/common/factory_base.h +++ b/source/extensions/filters/network/common/factory_base.h @@ -38,7 +38,7 @@ class FactoryBase : public Server::Configuration::NamedNetworkFilterConfigFactor proto_config, validation_visitor)); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } bool isTerminalFilter() override { return is_terminal_filter_; } diff --git a/source/extensions/filters/network/dubbo_proxy/BUILD b/source/extensions/filters/network/dubbo_proxy/BUILD index 9579275aee20..4646262fe311 100644 --- a/source/extensions/filters/network/dubbo_proxy/BUILD +++ b/source/extensions/filters/network/dubbo_proxy/BUILD @@ -38,6 +38,7 @@ envoy_cc_library( ":message_lib", ":metadata_lib", ":serializer_interface", + "//include/envoy/config:typed_config_interface", "//source/common/common:assert_lib", "//source/common/config:utility_lib", "//source/common/singleton:const_singleton", @@ -67,6 +68,7 @@ envoy_cc_library( ":message_lib", ":metadata_lib", "//include/envoy/buffer:buffer_interface", + "//include/envoy/config:typed_config_interface", "//source/common/common:assert_lib", "//source/common/config:utility_lib", "//source/common/singleton:const_singleton", diff --git a/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h b/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h index 021d99b52e2f..ee7390e6805d 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h +++ b/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h @@ -30,7 +30,7 @@ template class FactoryBase : public NamedDubboFilterConfigFa return std::make_unique(); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h index 5151dbe66132..4d9f77f917f5 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h @@ -21,7 +21,7 @@ namespace DubboFilters { * Implemented by each Dubbo filter and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedDubboFilterConfigFactory : public Envoy::Config::TypedConfig { +class NamedDubboFilterConfigFactory : public Envoy::Config::TypedFactory { public: virtual ~NamedDubboFilterConfigFactory() = default; @@ -38,18 +38,7 @@ class NamedDubboFilterConfigFactory : public Envoy::Config::TypedConfig { createFilterFactoryFromProto(const Protobuf::Message& config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a dubbo filter - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "dubbo_proxy.filters"; } + const std::string category() const override { return "dubbo_proxy.filters"; } }; } // namespace DubboFilters diff --git a/source/extensions/filters/network/dubbo_proxy/protocol.h b/source/extensions/filters/network/dubbo_proxy/protocol.h index a1f5896ba1f9..8609cb90a273 100644 --- a/source/extensions/filters/network/dubbo_proxy/protocol.h +++ b/source/extensions/filters/network/dubbo_proxy/protocol.h @@ -4,6 +4,7 @@ #include #include "envoy/buffer/buffer.h" +#include "envoy/config/typed_config.h" #include "common/common/assert.h" #include "common/common/fmt.h" @@ -97,7 +98,7 @@ using ProtocolPtr = std::unique_ptr; * Implemented by each Dubbo protocol and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedProtocolConfigFactory { +class NamedProtocolConfigFactory : public Config::UntypedFactory { public: virtual ~NamedProtocolConfigFactory() = default; @@ -108,19 +109,7 @@ class NamedProtocolConfigFactory { */ virtual ProtocolPtr createProtocol(SerializationType serialization_type) PURE; - /** - * @return std::string the identifying name for a particular implementation of Dubbo protocol - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "dubbo_proxy.protocols"; } - static std::string type() { return ""; } + const std::string category() const override { return "dubbo_proxy.protocols"; } /** * Convenience method to lookup a factory by type. @@ -144,7 +133,7 @@ template class ProtocolFactoryBase : public NamedProtocolCo return protocol; } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: ProtocolFactoryBase(ProtocolType type) : name_(ProtocolNames::get().fromType(type)) {} diff --git a/source/extensions/filters/network/dubbo_proxy/router/BUILD b/source/extensions/filters/network/dubbo_proxy/router/BUILD index 83808c43ffad..a06bbc69d8c7 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/BUILD +++ b/source/extensions/filters/network/dubbo_proxy/router/BUILD @@ -22,6 +22,7 @@ envoy_cc_library( hdrs = ["route.h"], deps = [ ":router_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/server:filter_config_interface", "//source/common/config:utility_lib", "//source/common/singleton:const_singleton", diff --git a/source/extensions/filters/network/dubbo_proxy/router/route.h b/source/extensions/filters/network/dubbo_proxy/router/route.h index 7c9e0f26c40d..011710977a1f 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route.h @@ -4,6 +4,7 @@ #include #include "envoy/config/filter/network/dubbo_proxy/v2alpha1/route.pb.h" +#include "envoy/config/typed_config.h" #include "envoy/router/router.h" #include "envoy/server/filter_config.h" @@ -66,7 +67,7 @@ using RouteMatcherConstSharedPtr = std::shared_ptr; * Implemented by each Dubbo protocol and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedRouteMatcherConfigFactory { +class NamedRouteMatcherConfigFactory : public Envoy::Config::UntypedFactory { public: virtual ~NamedRouteMatcherConfigFactory() = default; @@ -78,19 +79,7 @@ class NamedRouteMatcherConfigFactory { virtual RouteMatcherPtr createRouteMatcher(const RouteConfigurations& route_configs, Server::Configuration::FactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of Dubbo protocol - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "dubbo_proxy.route_matchers"; } - static std::string type() { return ""; } + const std::string category() const override { return "dubbo_proxy.route_matchers"; } /** * Convenience method to lookup a factory by type. @@ -114,7 +103,7 @@ class RouteMatcherFactoryBase : public NamedRouteMatcherConfigFactory { return std::make_unique(route_configs, context); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: RouteMatcherFactoryBase(RouteMatcherType type) : name_(RouteMatcherNames::get().fromType(type)) {} diff --git a/source/extensions/filters/network/dubbo_proxy/serializer.h b/source/extensions/filters/network/dubbo_proxy/serializer.h index 7eaae6ec75ae..5bfad74490e4 100644 --- a/source/extensions/filters/network/dubbo_proxy/serializer.h +++ b/source/extensions/filters/network/dubbo_proxy/serializer.h @@ -4,6 +4,7 @@ #include #include "envoy/buffer/buffer.h" +#include "envoy/config/typed_config.h" #include "common/common/assert.h" #include "common/config/utility.h" @@ -78,7 +79,7 @@ using SerializerPtr = std::unique_ptr; * Implemented by each Dubbo serialize and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedSerializerConfigFactory { +class NamedSerializerConfigFactory : public Config::UntypedFactory { public: virtual ~NamedSerializerConfigFactory() = default; @@ -88,19 +89,7 @@ class NamedSerializerConfigFactory { */ virtual SerializerPtr createSerializer() PURE; - /** - * @return std::string the identifying name for a particular implementation of Dubbo serializer - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "dubbo_proxy.serializers"; } - static std::string type() { return ""; } + const std::string category() const override { return "dubbo_proxy.serializers"; } /** * Convenience method to lookup a factory by type. @@ -121,7 +110,7 @@ template class SerializerFactoryBase : public NamedSerial public: SerializerPtr createSerializer() override { return std::make_unique(); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: SerializerFactoryBase(ProtocolType protocol_type, SerializationType type) diff --git a/source/extensions/filters/network/echo/config.cc b/source/extensions/filters/network/echo/config.cc index 34afc4458917..0e640435a787 100644 --- a/source/extensions/filters/network/echo/config.cc +++ b/source/extensions/filters/network/echo/config.cc @@ -27,7 +27,7 @@ class EchoConfigFactory : public Server::Configuration::NamedNetworkFilterConfig return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { return NetworkFilterNames::get().Echo; } + const std::string name() const override { return NetworkFilterNames::get().Echo; } bool isTerminalFilter() override { return true; } }; diff --git a/source/extensions/filters/network/sni_cluster/config.h b/source/extensions/filters/network/sni_cluster/config.h index fa0f45e68099..55cc4c06ddfa 100644 --- a/source/extensions/filters/network/sni_cluster/config.h +++ b/source/extensions/filters/network/sni_cluster/config.h @@ -19,7 +19,7 @@ class SniClusterNetworkFilterConfigFactory createFilterFactoryFromProto(const Protobuf::Message&, Server::Configuration::FactoryContext&) override; ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() override { return NetworkFilterNames::get().SniCluster; } + const std::string name() const override { return NetworkFilterNames::get().SniCluster; } }; } // namespace SniCluster diff --git a/source/extensions/filters/network/thrift_proxy/BUILD b/source/extensions/filters/network/thrift_proxy/BUILD index 67b3bb4b93fc..42d6ba3333a6 100644 --- a/source/extensions/filters/network/thrift_proxy/BUILD +++ b/source/extensions/filters/network/thrift_proxy/BUILD @@ -159,6 +159,7 @@ envoy_cc_library( ":thrift_object_interface", ":transport_interface", "//include/envoy/buffer:buffer_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/registry", "//source/common/common:assert_lib", "//source/common/config:utility_lib", @@ -250,6 +251,7 @@ envoy_cc_library( ":metadata_lib", ":thrift_lib", "//include/envoy/buffer:buffer_interface", + "//include/envoy/config:typed_config_interface", "//include/envoy/registry", "//source/common/common:assert_lib", "//source/common/config:utility_lib", diff --git a/source/extensions/filters/network/thrift_proxy/filters/factory_base.h b/source/extensions/filters/network/thrift_proxy/filters/factory_base.h index 159328b73a94..b5aa1750cbce 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/factory_base.h +++ b/source/extensions/filters/network/thrift_proxy/filters/factory_base.h @@ -25,7 +25,7 @@ template class FactoryBase : public NamedThriftFilterConfigF return std::make_unique(); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h index 0fedb23dc062..d9d31ba8bd07 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h @@ -18,7 +18,7 @@ namespace ThriftFilters { * Implemented by each Thrift filter and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedThriftFilterConfigFactory : public Envoy::Config::TypedConfig { +class NamedThriftFilterConfigFactory : public Envoy::Config::TypedFactory { public: virtual ~NamedThriftFilterConfigFactory() = default; @@ -35,18 +35,7 @@ class NamedThriftFilterConfigFactory : public Envoy::Config::TypedConfig { createFilterFactoryFromProto(const Protobuf::Message& config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) PURE; - /** - * @return std::string the identifying name for a particular implementation of a thrift filter - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "thrift_proxy.filters"; } + const std::string category() const override { return "thrift_proxy.filters"; } }; } // namespace ThriftFilters diff --git a/source/extensions/filters/network/thrift_proxy/protocol.h b/source/extensions/filters/network/thrift_proxy/protocol.h index c0b6616d4c34..ce5bc8f14f2f 100644 --- a/source/extensions/filters/network/thrift_proxy/protocol.h +++ b/source/extensions/filters/network/thrift_proxy/protocol.h @@ -5,6 +5,7 @@ #include "envoy/buffer/buffer.h" #include "envoy/common/pure.h" +#include "envoy/config/typed_config.h" #include "envoy/registry/registry.h" #include "common/common/assert.h" @@ -498,7 +499,7 @@ class DirectResponse { * Implemented by each Thrift protocol and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedProtocolConfigFactory { +class NamedProtocolConfigFactory : public Config::UntypedFactory { public: virtual ~NamedProtocolConfigFactory() = default; @@ -508,19 +509,7 @@ class NamedProtocolConfigFactory { */ virtual ProtocolPtr createProtocol() PURE; - /** - * @return std::string the identifying name for a particular implementation of thrift protocol - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "thrift_proxy.protocols"; } - static std::string type() { return ""; } + const std::string category() const override { return "thrift_proxy.protocols"; } /** * Convenience method to lookup a factory by type. @@ -540,7 +529,7 @@ template class ProtocolFactoryBase : public NamedProtocolCo public: ProtocolPtr createProtocol() override { return std::move(std::make_unique()); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: ProtocolFactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/network/thrift_proxy/transport.h b/source/extensions/filters/network/thrift_proxy/transport.h index b262674644e3..abc2e321f6bb 100644 --- a/source/extensions/filters/network/thrift_proxy/transport.h +++ b/source/extensions/filters/network/thrift_proxy/transport.h @@ -4,6 +4,7 @@ #include #include "envoy/buffer/buffer.h" +#include "envoy/config/typed_config.h" #include "envoy/registry/registry.h" #include "common/common/assert.h" @@ -82,7 +83,7 @@ using TransportPtr = std::unique_ptr; * Implemented by each Thrift transport and registered via Registry::registerFactory or the * convenience class RegisterFactory. */ -class NamedTransportConfigFactory { +class NamedTransportConfigFactory : public Envoy::Config::UntypedFactory { public: virtual ~NamedTransportConfigFactory() = default; @@ -92,19 +93,7 @@ class NamedTransportConfigFactory { */ virtual TransportPtr createTransport() PURE; - /** - * @return std::string the identifying name for a particular implementation of thrift transport - * produced by the factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "thrift_proxy.transports"; } - static std::string type() { return ""; } + const std::string category() const override { return "thrift_proxy.transports"; } /** * Convenience method to lookup a factory by type. @@ -124,7 +113,7 @@ template class TransportFactoryBase : public NamedTranspor public: TransportPtr createTransport() override { return std::move(std::make_unique()); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: TransportFactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/udp/udp_proxy/config.h b/source/extensions/filters/udp/udp_proxy/config.h index 2e6178c99b11..1dbf06f4cdd7 100644 --- a/source/extensions/filters/udp/udp_proxy/config.h +++ b/source/extensions/filters/udp/udp_proxy/config.h @@ -36,7 +36,7 @@ class UdpProxyFilterConfigFactory return std::make_unique(); } - std::string name() override { return "envoy.filters.udp_listener.udp_proxy"; } + const std::string name() const override { return "envoy.filters.udp_listener.udp_proxy"; } }; } // namespace UdpProxy diff --git a/source/extensions/grpc_credentials/aws_iam/config.h b/source/extensions/grpc_credentials/aws_iam/config.h index 68eae7fb9a89..0b1449f5212f 100644 --- a/source/extensions/grpc_credentials/aws_iam/config.h +++ b/source/extensions/grpc_credentials/aws_iam/config.h @@ -28,7 +28,7 @@ class AwsIamGrpcCredentialsFactory : public Grpc::GoogleGrpcCredentialsFactory { return std::make_unique(); } - std::string name() const override { return GrpcCredentialsNames::get().AwsIam; } + const std::string name() const override { return GrpcCredentialsNames::get().AwsIam; } private: static std::string getRegion(const envoy::config::grpc_credential::v2alpha::AwsIamConfig& config); diff --git a/source/extensions/grpc_credentials/example/config.h b/source/extensions/grpc_credentials/example/config.h index 17d3cf6da001..021f7311ca75 100644 --- a/source/extensions/grpc_credentials/example/config.h +++ b/source/extensions/grpc_credentials/example/config.h @@ -32,7 +32,7 @@ class AccessTokenExampleGrpcCredentialsFactory : public Grpc::GoogleGrpcCredenti getChannelCredentials(const envoy::api::v2::core::GrpcService& grpc_service_config, Api::Api& api) override; - std::string name() const override { return GrpcCredentialsNames::get().AccessTokenExample; } + const std::string name() const override { return GrpcCredentialsNames::get().AccessTokenExample; } }; /* diff --git a/source/extensions/grpc_credentials/file_based_metadata/config.h b/source/extensions/grpc_credentials/file_based_metadata/config.h index 18dd7cba48ba..9e7e03c1c505 100644 --- a/source/extensions/grpc_credentials/file_based_metadata/config.h +++ b/source/extensions/grpc_credentials/file_based_metadata/config.h @@ -32,7 +32,7 @@ class FileBasedMetadataGrpcCredentialsFactory : public Grpc::GoogleGrpcCredentia return std::make_unique(); } - std::string name() const override { return GrpcCredentialsNames::get().FileBasedMetadata; } + const std::string name() const override { return GrpcCredentialsNames::get().FileBasedMetadata; } }; class FileBasedMetadataAuthenticator : public grpc::MetadataCredentialsPlugin { diff --git a/source/extensions/health_checkers/redis/config.h b/source/extensions/health_checkers/redis/config.h index ab324e5e52a9..9e0c187f5849 100644 --- a/source/extensions/health_checkers/redis/config.h +++ b/source/extensions/health_checkers/redis/config.h @@ -21,7 +21,7 @@ class RedisHealthCheckerFactory : public Server::Configuration::CustomHealthChec createCustomHealthChecker(const envoy::api::v2::core::HealthCheck& config, Server::Configuration::HealthCheckerFactoryContext& context) override; - std::string name() override { return HealthCheckerNames::get().RedisHealthChecker; } + const std::string name() const override { return HealthCheckerNames::get().RedisHealthChecker; } }; } // namespace RedisHealthChecker diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc b/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc index 3cdadd8e0ae0..a84f1ca2a7d6 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc +++ b/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc @@ -17,7 +17,7 @@ ActiveQuicListenerConfigFactory::createActiveUdpListenerFactory(const Protobuf:: return std::make_unique(config); } -std::string ActiveQuicListenerConfigFactory::name() { return QuicListenerName; } +const std::string ActiveQuicListenerConfigFactory::name() const { return QuicListenerName; } REGISTER_FACTORY(ActiveQuicListenerConfigFactory, Server::ActiveUdpListenerConfigFactory); diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener_config.h b/source/extensions/quic_listeners/quiche/active_quic_listener_config.h index 78d6e7bb88c0..b4ee1ba1dcb4 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener_config.h +++ b/source/extensions/quic_listeners/quiche/active_quic_listener_config.h @@ -18,7 +18,7 @@ class ActiveQuicListenerConfigFactory : public Server::ActiveUdpListenerConfigFa Network::ActiveUdpListenerFactoryPtr createActiveUdpListenerFactory(const Protobuf::Message&) override; - std::string name() override; + const std::string name() const override; }; DECLARE_FACTORY(ActiveQuicListenerConfigFactory); diff --git a/source/extensions/quic_listeners/quiche/codec_impl.h b/source/extensions/quic_listeners/quiche/codec_impl.h index 3fabff7c3ae5..0e37c5064b0d 100644 --- a/source/extensions/quic_listeners/quiche/codec_impl.h +++ b/source/extensions/quic_listeners/quiche/codec_impl.h @@ -84,7 +84,7 @@ class QuicHttpClientConnectionFactoryImpl : public Http::QuicHttpClientConnectio createQuicClientConnection(Network::Connection& connection, Http::ConnectionCallbacks& callbacks) override; - std::string name() const override { return Http::QuicCodecNames::get().Quiche; } + const std::string name() const override { return Http::QuicCodecNames::get().Quiche; } }; // A factory to create QuicHttpServerConnection. @@ -94,7 +94,7 @@ class QuicHttpServerConnectionFactoryImpl : public Http::QuicHttpServerConnectio createQuicServerConnection(Network::Connection& connection, Http::ConnectionCallbacks& callbacks) override; - std::string name() const override { return Http::QuicCodecNames::get().Quiche; } + const std::string name() const override { return Http::QuicCodecNames::get().Quiche; } }; DECLARE_FACTORY(QuicHttpClientConnectionFactoryImpl); diff --git a/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h b/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h index 7cc538b77e2b..f2cf259f9f49 100644 --- a/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h +++ b/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h @@ -54,7 +54,7 @@ class QuicTransportSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: // Server::Configuration::TransportSocketConfigFactory - std::string name() const override { + const std::string name() const override { return Extensions::TransportSockets::TransportSocketNames::get().Quic; } }; @@ -72,7 +72,8 @@ class QuicServerTransportSocketConfigFactory // Server::Configuration::TransportSocketConfigFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string type() override { return ""; } + // Prevent double registration for the config proto + const std::string configType() override { return ""; } }; DECLARE_FACTORY(QuicServerTransportSocketConfigFactory); @@ -89,7 +90,8 @@ class QuicClientTransportSocketConfigFactory // Server::Configuration::TransportSocketConfigFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string type() override { return ""; } + // Prevent double registration for the config proto + const std::string configType() override { return ""; } }; DECLARE_FACTORY(QuicClientTransportSocketConfigFactory); diff --git a/source/extensions/resource_monitors/common/factory_base.h b/source/extensions/resource_monitors/common/factory_base.h index 65350bc6950c..28cf247a914d 100644 --- a/source/extensions/resource_monitors/common/factory_base.h +++ b/source/extensions/resource_monitors/common/factory_base.h @@ -24,7 +24,7 @@ class FactoryBase : public Server::Configuration::ResourceMonitorFactory { return std::make_unique(); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} @@ -52,7 +52,7 @@ class EmptyConfigFactoryBase : public Server::Configuration::ResourceMonitorFact return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: EmptyConfigFactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/retry/host/omit_canary_hosts/config.h b/source/extensions/retry/host/omit_canary_hosts/config.h index 53e3476499d8..fb3cb5628aa6 100644 --- a/source/extensions/retry/host/omit_canary_hosts/config.h +++ b/source/extensions/retry/host/omit_canary_hosts/config.h @@ -16,7 +16,9 @@ class OmitCanaryHostsRetryPredicateFactory : public Upstream::RetryHostPredicate return std::make_shared(); } - std::string name() override { return RetryHostPredicateValues::get().OmitCanaryHostsPredicate; } + const std::string name() const override { + return RetryHostPredicateValues::get().OmitCanaryHostsPredicate; + } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique(); diff --git a/source/extensions/retry/host/previous_hosts/config.h b/source/extensions/retry/host/previous_hosts/config.h index ddc762f661eb..b00ff324b1a5 100644 --- a/source/extensions/retry/host/previous_hosts/config.h +++ b/source/extensions/retry/host/previous_hosts/config.h @@ -17,7 +17,9 @@ class PreviousHostsRetryPredicateFactory : public Upstream::RetryHostPredicateFa return std::make_shared(retry_count); } - std::string name() override { return RetryHostPredicateValues::get().PreviousHostsPredicate; } + const std::string name() const override { + return RetryHostPredicateValues::get().PreviousHostsPredicate; + } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique(); diff --git a/source/extensions/retry/priority/previous_priorities/config.h b/source/extensions/retry/priority/previous_priorities/config.h index 10a9156aa208..31ff74578807 100644 --- a/source/extensions/retry/priority/previous_priorities/config.h +++ b/source/extensions/retry/priority/previous_priorities/config.h @@ -20,7 +20,7 @@ class PreviousPrioritiesRetryPriorityFactory : public Upstream::RetryPriorityFac ProtobufMessage::ValidationVisitor& validation_visitor, uint32_t max_retries) override; - std::string name() const override { + const std::string name() const override { return RetryPriorityValues::get().PreviousPrioritiesRetryPriority; } diff --git a/source/extensions/stat_sinks/dog_statsd/config.cc b/source/extensions/stat_sinks/dog_statsd/config.cc index 6b7ce0182bb5..e44b8e1b74bb 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.cc +++ b/source/extensions/stat_sinks/dog_statsd/config.cc @@ -32,7 +32,7 @@ ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string DogStatsdSinkFactory::name() { return StatsSinkNames::get().DogStatsd; } +const std::string DogStatsdSinkFactory::name() const { return StatsSinkNames::get().DogStatsd; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/dog_statsd/config.h b/source/extensions/stat_sinks/dog_statsd/config.h index 44e1ecaaa77f..243e820e100f 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.h +++ b/source/extensions/stat_sinks/dog_statsd/config.h @@ -20,7 +20,7 @@ class DogStatsdSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() override; + const std::string name() const override; }; } // namespace DogStatsd diff --git a/source/extensions/stat_sinks/hystrix/config.cc b/source/extensions/stat_sinks/hystrix/config.cc index a9fc2d697d60..a6fb4bdfa75a 100644 --- a/source/extensions/stat_sinks/hystrix/config.cc +++ b/source/extensions/stat_sinks/hystrix/config.cc @@ -28,7 +28,7 @@ ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string HystrixSinkFactory::name() { return StatsSinkNames::get().Hystrix; } +const std::string HystrixSinkFactory::name() const { return StatsSinkNames::get().Hystrix; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/hystrix/config.h b/source/extensions/stat_sinks/hystrix/config.h index 2f3f7c37f878..e5014b0e0ed9 100644 --- a/source/extensions/stat_sinks/hystrix/config.h +++ b/source/extensions/stat_sinks/hystrix/config.h @@ -20,7 +20,7 @@ class HystrixSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() override; + const std::string name() const override; }; } // namespace Hystrix diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index 80e74ea9925f..869cef5458b7 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -41,7 +41,9 @@ ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() { std::make_unique()); } -std::string MetricsServiceSinkFactory::name() { return StatsSinkNames::get().MetricsService; } +const std::string MetricsServiceSinkFactory::name() const { + return StatsSinkNames::get().MetricsService; +} /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/metrics_service/config.h b/source/extensions/stat_sinks/metrics_service/config.h index 5c2f95e49a64..ae470be5cc4e 100644 --- a/source/extensions/stat_sinks/metrics_service/config.h +++ b/source/extensions/stat_sinks/metrics_service/config.h @@ -21,7 +21,7 @@ class MetricsServiceSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() override; + const std::string name() const override; }; DECLARE_FACTORY(MetricsServiceSinkFactory); diff --git a/source/extensions/stat_sinks/statsd/config.cc b/source/extensions/stat_sinks/statsd/config.cc index f7e352e30bd4..4fe5145a64a9 100644 --- a/source/extensions/stat_sinks/statsd/config.cc +++ b/source/extensions/stat_sinks/statsd/config.cc @@ -45,7 +45,7 @@ ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string StatsdSinkFactory::name() { return StatsSinkNames::get().Statsd; } +const std::string StatsdSinkFactory::name() const { return StatsSinkNames::get().Statsd; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/statsd/config.h b/source/extensions/stat_sinks/statsd/config.h index 64d82f17624d..8cec6ae0317a 100644 --- a/source/extensions/stat_sinks/statsd/config.h +++ b/source/extensions/stat_sinks/statsd/config.h @@ -21,7 +21,7 @@ class StatsdSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() override; + const std::string name() const override; }; } // namespace Statsd diff --git a/source/extensions/tracers/common/factory_base.h b/source/extensions/tracers/common/factory_base.h index b32975a74e9f..27e29853a885 100644 --- a/source/extensions/tracers/common/factory_base.h +++ b/source/extensions/tracers/common/factory_base.h @@ -27,7 +27,7 @@ template class FactoryBase : public Server::Configuration::T return std::make_unique(); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/transport_sockets/alts/config.h b/source/extensions/transport_sockets/alts/config.h index adec81d3faec..e0d830224baa 100644 --- a/source/extensions/transport_sockets/alts/config.h +++ b/source/extensions/transport_sockets/alts/config.h @@ -14,7 +14,7 @@ class AltsTransportSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ProtobufTypes::MessagePtr createEmptyConfigProto() override; - std::string name() const override { return TransportSocketNames::get().Alts; } + const std::string name() const override { return TransportSocketNames::get().Alts; } }; class UpstreamAltsTransportSocketConfigFactory diff --git a/source/extensions/transport_sockets/raw_buffer/config.h b/source/extensions/transport_sockets/raw_buffer/config.h index a7c68d6875a7..a5e7cfe95ba7 100644 --- a/source/extensions/transport_sockets/raw_buffer/config.h +++ b/source/extensions/transport_sockets/raw_buffer/config.h @@ -17,7 +17,7 @@ namespace RawBuffer { class RawBufferSocketFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ~RawBufferSocketFactory() override = default; - std::string name() const override { return TransportSocketNames::get().RawBuffer; } + const std::string name() const override { return TransportSocketNames::get().RawBuffer; } ProtobufTypes::MessagePtr createEmptyConfigProto() override; }; diff --git a/source/extensions/transport_sockets/tap/config.h b/source/extensions/transport_sockets/tap/config.h index 8068779ada01..a5baa4408c60 100644 --- a/source/extensions/transport_sockets/tap/config.h +++ b/source/extensions/transport_sockets/tap/config.h @@ -16,7 +16,7 @@ namespace Tap { class TapSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ~TapSocketConfigFactory() override = default; - std::string name() const override { return TransportSocketNames::get().Tap; } + const std::string name() const override { return TransportSocketNames::get().Tap; } ProtobufTypes::MessagePtr createEmptyConfigProto() override; }; diff --git a/source/extensions/transport_sockets/tls/config.h b/source/extensions/transport_sockets/tls/config.h index a10d597e09db..25e3e90409e1 100644 --- a/source/extensions/transport_sockets/tls/config.h +++ b/source/extensions/transport_sockets/tls/config.h @@ -17,7 +17,7 @@ namespace Tls { class SslSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ~SslSocketConfigFactory() override = default; - std::string name() const override { return TransportSocketNames::get().Tls; } + const std::string name() const override { return TransportSocketNames::get().Tls; } }; class UpstreamSslSocketFactory : public Server::Configuration::UpstreamTransportSocketConfigFactory, diff --git a/source/server/active_raw_udp_listener_config.cc b/source/server/active_raw_udp_listener_config.cc index 8eea3f4742e9..5cdace6cb2af 100644 --- a/source/server/active_raw_udp_listener_config.cc +++ b/source/server/active_raw_udp_listener_config.cc @@ -23,7 +23,9 @@ ActiveRawUdpListenerConfigFactory::createActiveUdpListenerFactory( return std::make_unique(); } -std::string ActiveRawUdpListenerConfigFactory::name() { return UdpListenerNames::get().RawUdp; } +const std::string ActiveRawUdpListenerConfigFactory::name() const { + return UdpListenerNames::get().RawUdp; +} REGISTER_FACTORY(ActiveRawUdpListenerConfigFactory, Server::ActiveUdpListenerConfigFactory); diff --git a/source/server/active_raw_udp_listener_config.h b/source/server/active_raw_udp_listener_config.h index 3a2477f27492..e040236cef58 100644 --- a/source/server/active_raw_udp_listener_config.h +++ b/source/server/active_raw_udp_listener_config.h @@ -26,7 +26,7 @@ class ActiveRawUdpListenerConfigFactory : public ActiveUdpListenerConfigFactory Network::ActiveUdpListenerFactoryPtr createActiveUdpListenerFactory(const Protobuf::Message&) override; - std::string name() override; + const std::string name() const override; }; DECLARE_FACTORY(ActiveRawUdpListenerConfigFactory); diff --git a/source/server/config_validation/server.cc b/source/server/config_validation/server.cc index 475e563d24fc..ed8f677ed526 100644 --- a/source/server/config_validation/server.cc +++ b/source/server/config_validation/server.cc @@ -94,8 +94,7 @@ void ValidationInstance::initialize(const Options& options, thread_local_.registerThread(*dispatcher_, true); runtime_loader_ = component_factory.createRuntime(*this, initial_config); secret_manager_ = std::make_unique(admin().getConfigTracker()); - ssl_context_manager_ = - createContextManager(Ssl::ContextManagerFactory::name(), api_->timeSource()); + ssl_context_manager_ = createContextManager("ssl_context_manager", api_->timeSource()); cluster_manager_factory_ = std::make_unique( admin(), runtime(), stats(), threadLocal(), random(), dnsResolver(), sslContextManager(), dispatcher(), localInfo(), *secret_manager_, messageValidationContext(), *api_, http_context_, diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 821ea2178e37..9fba33fb23fe 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -31,7 +31,7 @@ namespace Configuration { * Implemented for each Stats::Sink and registered via Registry::registerFactory() or * the convenience class RegisterFactory. */ -class StatsSinkFactory : public Config::TypedConfig { +class StatsSinkFactory : public Config::TypedFactory { public: virtual ~StatsSinkFactory() = default; @@ -44,18 +44,7 @@ class StatsSinkFactory : public Config::TypedConfig { */ virtual Stats::SinkPtr createStatsSink(const Protobuf::Message& config, Instance& server) PURE; - /** - * Returns the identifying name for a particular implementation of Stats::Sink produced by the - * factory. - */ - virtual std::string name() PURE; - - /** - * @return std::string the identifying category name for objects - * created by this factory. Used for automatic registration with - * FactoryCategoryRegistry. - */ - static std::string category() { return "stats_sinks"; } + const std::string category() const override { return "stats_sinks"; } }; /** diff --git a/source/server/server.cc b/source/server/server.cc index 7a3e604d6c2c..33f034c3c402 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -368,7 +368,7 @@ void InstanceImpl::initialize(const Options& options, hooks.onRuntimeCreated(); // Once we have runtime we can initialize the SSL context manager. - ssl_context_manager_ = createContextManager(Ssl::ContextManagerFactory::name(), time_source_); + ssl_context_manager_ = createContextManager("ssl_context_manager", time_source_); const bool use_tcp_for_dns_lookups = bootstrap_.use_tcp_for_dns_lookups(); dns_resolver_ = dispatcher_->createDnsResolver({}, use_tcp_for_dns_lookups); diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index f01186dda883..f4219811d662 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -1243,7 +1243,7 @@ class TestHeaderFilterFactory : public ExtensionFilterFactory { return std::make_unique(); } - std::string name() const override { return "test_header_filter"; } + const std::string name() const override { return "test_header_filter"; } }; TEST_F(AccessLogImplTest, TestHeaderFilterPresence) { @@ -1319,7 +1319,7 @@ class SampleExtensionFilterFactory : public ExtensionFilterFactory { return std::make_unique(); } - std::string name() const override { return "sample_extension_filter"; } + const std::string name() const override { return "sample_extension_filter"; } }; TEST_F(AccessLogImplTest, SampleExtensionFilter) { diff --git a/test/common/config/BUILD b/test/common/config/BUILD index 6e3369de52be..f9762098cb2e 100644 --- a/test/common/config/BUILD +++ b/test/common/config/BUILD @@ -307,6 +307,7 @@ envoy_cc_test( name = "registry_test", srcs = ["registry_test.cc"], deps = [ + "//include/envoy/config:typed_config_interface", "//test/test_common:logging_lib", "//test/test_common:utility_lib", ], diff --git a/test/common/config/registry_test.cc b/test/common/config/registry_test.cc index 1708ef3206e5..dc4d9c4951df 100644 --- a/test/common/config/registry_test.cc +++ b/test/common/config/registry_test.cc @@ -1,5 +1,6 @@ #include +#include "envoy/config/typed_config.h" #include "envoy/registry/registry.h" #include "common/common/fmt.h" @@ -13,17 +14,15 @@ namespace Envoy { namespace Config { namespace { -class InternalFactory { +class InternalFactory : public Config::UntypedFactory { public: virtual ~InternalFactory() = default; - virtual std::string name() PURE; - static std::string category() { return ""; } - static std::string type() { return ""; } + const std::string category() const override { return ""; } }; class TestInternalFactory : public InternalFactory { public: - std::string name() override { return "testing.internal.test"; } + const std::string name() const override { return "testing.internal.test"; } }; static Registry::RegisterInternalFactory @@ -48,17 +47,15 @@ TEST(RegistryTest, InternalFactoryNotPublished) { nullptr); } -class PublishedFactory { +class PublishedFactory : public Config::UntypedFactory { public: virtual ~PublishedFactory() = default; - virtual std::string name() PURE; - static std::string category() { return "testing.published"; } - static std::string type() { return ""; } + const std::string category() const override { return "testing.published"; } }; class TestPublishedFactory : public PublishedFactory { public: - std::string name() override { return "testing.published.test"; } + const std::string name() const override { return "testing.published.test"; } }; REGISTER_FACTORY(TestPublishedFactory, PublishedFactory); @@ -80,7 +77,7 @@ TEST(RegistryTest, DefaultFactoryPublished) { class TestWithDeprecatedPublishedFactory : public PublishedFactory { public: - std::string name() override { return "testing.published.instead_name"; } + const std::string name() const override { return "testing.published.instead_name"; } }; REGISTER_FACTORY(TestWithDeprecatedPublishedFactory, diff --git a/test/common/network/resolver_impl_test.cc b/test/common/network/resolver_impl_test.cc index f5fa8daf536a..61c3142f3aa8 100644 --- a/test/common/network/resolver_impl_test.cc +++ b/test/common/network/resolver_impl_test.cc @@ -96,7 +96,7 @@ class TestResolver : public Resolver { name_mappings_[logical] = physical; } - std::string name() const override { return "envoy.test.resolver"; } + const std::string name() const override { return "envoy.test.resolver"; } private: std::string getPhysicalName(const std::string& logical) { diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index fd647957227a..4cdbc59dcdb6 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -2732,7 +2732,7 @@ class TestUpstreamNetworkFilterConfigFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique(); } - std::string name() override { return "envoy.test.filter"; } + const std::string name() const override { return "envoy.test.filter"; } }; // Verify that configured upstream filters are added to client connections. diff --git a/test/common/upstream/transport_socket_matcher_test.cc b/test/common/upstream/transport_socket_matcher_test.cc index 661a19e2d46b..7d75cfcf8789 100644 --- a/test/common/upstream/transport_socket_matcher_test.cc +++ b/test/common/upstream/transport_socket_matcher_test.cc @@ -64,7 +64,7 @@ class FooTransportSocketFactory return std::make_unique(); } - std::string name() const override { return "foo"; } + const std::string name() const override { return "foo"; } }; class TransportSocketMatcherTest : public testing::Test { diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 243ad43296c1..e25d251a438a 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -2133,8 +2133,10 @@ class TestNetworkFilterConfigFactory ProtobufMessage::ValidationVisitor&) override { return parent_.createProtocolOptionsConfig(msg); } - std::string name() override { CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); } - std::string type() override { return name(); } + const std::string name() const override { + CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); + } + const std::string configType() override { return ""; }; TestFilterConfigFactoryBase& parent_; }; @@ -2168,8 +2170,10 @@ class TestHttpFilterConfigFactory : public Server::Configuration::NamedHttpFilte ProtobufMessage::ValidationVisitor&) override { return parent_.createProtocolOptionsConfig(msg); } - std::string name() override { CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); } - std::string type() override { return name(); } + const std::string name() const override { + CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); + } + const std::string configType() override { return ""; }; TestFilterConfigFactoryBase& parent_; }; diff --git a/test/extensions/filters/network/dubbo_proxy/mocks.h b/test/extensions/filters/network/dubbo_proxy/mocks.h index dbe59849c523..77e2d3b41706 100644 --- a/test/extensions/filters/network/dubbo_proxy/mocks.h +++ b/test/extensions/filters/network/dubbo_proxy/mocks.h @@ -125,7 +125,7 @@ class MockNamedSerializerConfigFactory : public NamedSerializerConfigFactory { MockNamedSerializerConfigFactory(std::function f) : f_(f) {} SerializerPtr createSerializer() override { return SerializerPtr{f_()}; } - std::string name() override { + const std::string name() const override { return SerializerNames::get().fromType(SerializationType::Hessian2); } @@ -141,7 +141,9 @@ class MockNamedProtocolConfigFactory : public NamedProtocolConfigFactory { protocol->initSerializer(serialization_type); return protocol; } - std::string name() override { return ProtocolNames::get().fromType(ProtocolType::Dubbo); } + const std::string name() const override { + return ProtocolNames::get().fromType(ProtocolType::Dubbo); + } std::function f_; }; @@ -287,7 +289,7 @@ template class MockFactoryBase : public NamedDubboFilterConf return std::make_unique(); } - std::string name() override { return name_; } + const std::string name() const override { return name_; } protected: MockFactoryBase(const std::string& name) : name_(name) {} diff --git a/test/extensions/filters/network/dubbo_proxy/router_test.cc b/test/extensions/filters/network/dubbo_proxy/router_test.cc index e37c9f12bbb9..23f0f208082a 100644 --- a/test/extensions/filters/network/dubbo_proxy/router_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/router_test.cc @@ -35,7 +35,7 @@ class TestNamedSerializerConfigFactory : public NamedSerializerConfigFactory { TestNamedSerializerConfigFactory(std::function f) : f_(f) {} SerializerPtr createSerializer() override { return SerializerPtr{f_()}; } - std::string name() override { + const std::string name() const override { return SerializerNames::get().fromType(SerializationType::Hessian2); } @@ -51,7 +51,9 @@ class TestNamedProtocolConfigFactory : public NamedProtocolConfigFactory { protocol->initSerializer(serialization_type); return protocol; } - std::string name() override { return ProtocolNames::get().fromType(ProtocolType::Dubbo); } + const std::string name() const override { + return ProtocolNames::get().fromType(ProtocolType::Dubbo); + } std::function f_; }; diff --git a/test/extensions/filters/network/thrift_proxy/router_test.cc b/test/extensions/filters/network/thrift_proxy/router_test.cc index 652ec3ca5f40..0fecc7a0e6b7 100644 --- a/test/extensions/filters/network/thrift_proxy/router_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_test.cc @@ -42,7 +42,7 @@ class TestNamedTransportConfigFactory : public NamedTransportConfigFactory { TestNamedTransportConfigFactory(std::function f) : f_(f) {} TransportPtr createTransport() override { return TransportPtr{f_()}; } - std::string name() override { return TransportNames::get().FRAMED; } + const std::string name() const override { return TransportNames::get().FRAMED; } std::function f_; }; @@ -52,7 +52,7 @@ class TestNamedProtocolConfigFactory : public NamedProtocolConfigFactory { TestNamedProtocolConfigFactory(std::function f) : f_(f) {} ProtocolPtr createProtocol() override { return ProtocolPtr{f_()}; } - std::string name() override { return ProtocolNames::get().BINARY; } + const std::string name() const override { return ProtocolNames::get().BINARY; } std::function f_; }; diff --git a/test/extensions/transport_sockets/tls/test_private_key_method_provider.h b/test/extensions/transport_sockets/tls/test_private_key_method_provider.h index 417ddff3ebb6..de608cde775e 100644 --- a/test/extensions/transport_sockets/tls/test_private_key_method_provider.h +++ b/test/extensions/transport_sockets/tls/test_private_key_method_provider.h @@ -89,7 +89,7 @@ class TestPrivateKeyMethodFactory : public Ssl::PrivateKeyMethodProviderInstance return std::make_shared(config.typed_config(), factory_context); } - std::string name() const override { return std::string("test"); }; + const std::string name() const override { return std::string("test"); }; }; } // namespace PrivateKeyMethodProvider diff --git a/test/integration/cluster_filter_integration_test.cc b/test/integration/cluster_filter_integration_test.cc index 4f63cfe2d81f..e00e7c582868 100644 --- a/test/integration/cluster_filter_integration_test.cc +++ b/test/integration/cluster_filter_integration_test.cc @@ -70,7 +70,7 @@ class PoliteFilterConfigFactory return std::make_unique(); } - std::string name() override { return "envoy.upstream.polite"; } + const std::string name() const override { return "envoy.upstream.polite"; } }; // perform static registration diff --git a/test/integration/filter_manager_integration_test.h b/test/integration/filter_manager_integration_test.h index 9e1f90567047..d508ffe73ad3 100644 --- a/test/integration/filter_manager_integration_test.h +++ b/test/integration/filter_manager_integration_test.h @@ -256,7 +256,7 @@ class DispenserFilterConfigFactory : public Server::Configuration::NamedNetworkF return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { return name_; } + const std::string name() const override { return name_; } private: const std::string name_; diff --git a/test/integration/tcp_conn_pool_integration_test.cc b/test/integration/tcp_conn_pool_integration_test.cc index e481799f3814..d822914922de 100644 --- a/test/integration/tcp_conn_pool_integration_test.cc +++ b/test/integration/tcp_conn_pool_integration_test.cc @@ -97,7 +97,9 @@ class TestFilterConfigFactory : public Server::Configuration::NamedNetworkFilter return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.router"); } + const std::string name() const override { + CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.router"); + } bool isTerminalFilter() override { return true; } }; diff --git a/test/integration/test_host_predicate_config.h b/test/integration/test_host_predicate_config.h index 06b6dd576f7f..786270f474a2 100644 --- a/test/integration/test_host_predicate_config.h +++ b/test/integration/test_host_predicate_config.h @@ -9,7 +9,7 @@ namespace Envoy { class TestHostPredicateFactory : public Upstream::RetryHostPredicateFactory { public: - std::string name() override { return "envoy.test_host_predicate"; } + const std::string name() const override { return "envoy.test_host_predicate"; } Upstream::RetryHostPredicateSharedPtr createHostPredicate(const Protobuf::Message&, uint32_t) override { diff --git a/test/integration/xds_integration_test.cc b/test/integration/xds_integration_test.cc index 5986409a6673..5cc4791c1b6f 100644 --- a/test/integration/xds_integration_test.cc +++ b/test/integration/xds_integration_test.cc @@ -119,7 +119,6 @@ TEST_P(LdsIntegrationTest, FailConfigLoad) { auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0); auto* filter_chain = listener->mutable_filter_chains(0); filter_chain->mutable_filters(0)->set_name("grewgragra"); - filter_chain->mutable_filters(0)->clear_typed_config(); }); EXPECT_DEATH_LOG_TO_STDERR(initialize(), "Didn't find a registered implementation for name: 'grewgragra'"); diff --git a/test/mocks/network/mocks.h b/test/mocks/network/mocks.h index bc7b2f76ca1d..8ca0d83c8c1f 100644 --- a/test/mocks/network/mocks.h +++ b/test/mocks/network/mocks.h @@ -55,7 +55,7 @@ class MockAddressResolver : public Address::Resolver { MOCK_METHOD1(resolve, Address::InstanceConstSharedPtr(const envoy::api::v2::core::SocketAddress&)); - MOCK_CONST_METHOD0(name, std::string()); + MOCK_CONST_METHOD0(name, const std::string()); }; class MockReadFilterCallbacks : public ReadFilterCallbacks { diff --git a/test/mocks/upstream/mocks.h b/test/mocks/upstream/mocks.h index d653f754b34f..1aa8307d3685 100644 --- a/test/mocks/upstream/mocks.h +++ b/test/mocks/upstream/mocks.h @@ -153,7 +153,7 @@ class MockRetryPriorityFactory : public RetryPriorityFactory { return std::make_shared>(retry_priority_); } - std::string name() const override { return "envoy.test_retry_priority"; } + const std::string name() const override { return "envoy.test_retry_priority"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } @@ -423,7 +423,7 @@ class TestRetryHostPredicateFactory : public RetryHostPredicateFactory { return std::make_shared>(); } - std::string name() override { return "envoy.test_host_predicate"; } + const std::string name() const override { return "envoy.test_host_predicate"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } diff --git a/test/server/BUILD b/test/server/BUILD index 8c4c13f19ea3..f8e952eddd9f 100644 --- a/test/server/BUILD +++ b/test/server/BUILD @@ -126,6 +126,7 @@ envoy_cc_test( name = "options_impl_test", srcs = ["options_impl_test.cc"], deps = [ + "//include/envoy/config:typed_config_interface", "//source/common/common:utility_lib", "//source/common/stats:stats_lib", "//source/server:options_lib", diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index e441f0d02787..e591c4197f5e 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -271,9 +271,9 @@ TEST_F(ConfigurationImplTest, ConfigurationFailsWhenInvalidTracerSpecified) { auto bootstrap = Upstream::parseBootstrapFromV2Json(json); MainImpl config; - EXPECT_THROW_WITH_MESSAGE( - config.initialize(bootstrap, server_, cluster_manager_factory_), EnvoyException, - "Didn't find a registered implementation for type: 'envoy.config.trace.v2.LightstepConfig'"); + EXPECT_THROW_WITH_MESSAGE(config.initialize(bootstrap, server_, cluster_manager_factory_), + EnvoyException, + "Didn't find a registered implementation for name: 'invalid'"); } TEST_F(ConfigurationImplTest, ProtoSpecifiedStatsSink) { diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index a442773af148..4b500f1a6b8b 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -339,7 +339,7 @@ class NonTerminalFilterFactory : public Configuration::NamedNetworkFilterConfigF return std::make_unique(); } - std::string name() override { return "non_terminal"; } + const std::string name() const override { return "non_terminal"; } }; TEST_F(ListenerManagerImplWithRealFiltersTest, TerminalNotLast) { @@ -412,7 +412,7 @@ class TestStatsConfigFactory : public Configuration::NamedNetworkFilterConfigFac return std::make_unique(); } - std::string name() override { return "stats_test"; } + const std::string name() const override { return "stats_test"; } bool isTerminalFilter() override { return true; } private: @@ -3157,7 +3157,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilter) { return std::make_unique(); } - std::string name() override { return "test.listener.original_dst"; } + const std::string name() const override { return "test.listener.original_dst"; } }; /** @@ -3231,7 +3231,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilterIPv6) { return std::make_unique(); } - std::string name() override { return "test.listener.original_dstipv6"; } + const std::string name() const override { return "test.listener.original_dstipv6"; } }; /** diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index 096850399a05..eb192f723ec1 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -8,6 +8,7 @@ #include "envoy/admin/v2alpha/server_info.pb.h" #include "envoy/common/exception.h" #include "envoy/config/bootstrap/v2/bootstrap.pb.h" +#include "envoy/config/typed_config.h" #include "common/common/utility.h" @@ -450,30 +451,26 @@ TEST_F(OptionsImplPlatformLinuxTest, AffinityTest4) { #endif -class TestFactory { +class TestFactory : public Config::UntypedFactory { public: virtual ~TestFactory() = default; - virtual std::string name() PURE; - static std::string category() { return "test"; } - static std::string type() { return ""; } + const std::string category() const override { return "test"; } }; class TestTestFactory : public TestFactory { public: - std::string name() override { return "test"; } + const std::string name() const override { return "test"; } }; -class TestingFactory { +class TestingFactory : public Config::UntypedFactory { public: virtual ~TestingFactory() = default; - virtual std::string name() PURE; - static std::string category() { return "testing"; } - static std::string type() { return ""; } + const std::string category() const override { return "testing"; } }; class TestTestingFactory : public TestingFactory { public: - std::string name() override { return "test"; } + const std::string name() const override { return "test"; } }; REGISTER_FACTORY(TestTestFactory, TestFactory){"test-1", "test-2"}; diff --git a/test/server/server_test.cc b/test/server/server_test.cc index 877c884e8c8f..f94fd7d48057 100644 --- a/test/server/server_test.cc +++ b/test/server/server_test.cc @@ -268,7 +268,7 @@ class CustomStatsSinkFactory : public Server::Configuration::StatsSinkFactory { return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { return "envoy.custom_stats_sink"; } + const std::string name() const override { return "envoy.custom_stats_sink"; } }; INSTANTIATE_TEST_SUITE_P(IpVersions, ServerInstanceImplTest, @@ -993,7 +993,7 @@ class CallbacksStatsSinkFactory : public Server::Configuration::StatsSinkFactory return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - std::string name() override { return "envoy.callbacks_stats_sink"; } + const std::string name() const override { return "envoy.callbacks_stats_sink"; } }; REGISTER_FACTORY(CallbacksStatsSinkFactory, Server::Configuration::StatsSinkFactory); diff --git a/test/test_common/registry.h b/test/test_common/registry.h index 6c58095594dc..ccbbac80ef66 100644 --- a/test/test_common/registry.h +++ b/test/test_common/registry.h @@ -15,7 +15,7 @@ namespace Registry { template class InjectFactory { public: InjectFactory(Base& instance) : instance_(instance) { - EXPECT_STRNE(Base::category().c_str(), ""); + EXPECT_STRNE(instance.category().c_str(), ""); displaced_ = Registry::FactoryRegistry::replaceFactoryForTest(instance_); } From 1fc3c60f75fbac02f8c5d0d0c33a8b8ff106a000 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Mon, 23 Dec 2019 17:12:05 -0800 Subject: [PATCH 05/12] stale comment Signed-off-by: Kuat Yessenov --- source/common/http/http3/quic_codec_factory.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/common/http/http3/quic_codec_factory.h b/source/common/http/http3/quic_codec_factory.h index a762a1328911..de6d53e4b334 100644 --- a/source/common/http/http3/quic_codec_factory.h +++ b/source/common/http/http3/quic_codec_factory.h @@ -18,9 +18,6 @@ class QuicHttpServerConnectionFactory : public Config::UntypedFactory { createQuicServerConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; const std::string category() const override { return "quic_client_codec"; } - - // Prevents double registration for the same config proto - // const std::string configType() override { return ""; } }; // A factory to create Http::ClientConnection instance for QUIC. @@ -32,9 +29,6 @@ class QuicHttpClientConnectionFactory : public Config::UntypedFactory { createQuicClientConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; const std::string category() const override { return "quic_server_codec"; } - - // Prevents double registration for the same config proto - // const std::string configType() override { return ""; } }; } // namespace Http From 6edc214d53d81913093a6b9b636b3c4e3682d894 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Mon, 23 Dec 2019 20:02:32 -0800 Subject: [PATCH 06/12] unresolved initialization fiasco Signed-off-by: Kuat Yessenov --- include/envoy/registry/registry.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/include/envoy/registry/registry.h b/include/envoy/registry/registry.h index db42e975157f..7695f1994e62 100644 --- a/include/envoy/registry/registry.h +++ b/include/envoy/registry/registry.h @@ -158,11 +158,6 @@ template class FactoryRegistry : public Logger::Loggable& typeNames() { - static auto* type_names = new absl::flat_hash_map; - return *type_names; - } - /** * instead_value are used when passed name was deprecated. */ @@ -175,15 +170,6 @@ template class FactoryRegistry : public Logger::Loggable class FactoryRegistry : public Logger::Loggablesecond; } - /** - * Gets a factory by type URL. If not found, returns nullptr. - */ - static Base* getFactoryByType(absl::string_view type) { - auto it = typeNames().find(type); - if (it == typeNames().end()) { - return nullptr; - } - return it->second; - } - /** * @return the canonical name of the factory. If the given name is a * deprecated factory name, the canonical name is returned instead. From 144a5f194f17a3f130fac80faa0b8f1c501d775f Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Fri, 27 Dec 2019 11:11:12 -0800 Subject: [PATCH 07/12] change to assert Signed-off-by: Kuat Yessenov --- include/envoy/config/BUILD | 1 + include/envoy/config/typed_config.h | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/envoy/config/BUILD b/include/envoy/config/BUILD index 003efb8e9443..94c827312abe 100644 --- a/include/envoy/config/BUILD +++ b/include/envoy/config/BUILD @@ -62,6 +62,7 @@ envoy_cc_library( name = "typed_config_interface", hdrs = ["typed_config.h"], deps = [ + "//source/common/common:assert_lib", "//source/common/protobuf", ], ) diff --git a/include/envoy/config/typed_config.h b/include/envoy/config/typed_config.h index b1e46501ad4a..1dc3fab84ffa 100644 --- a/include/envoy/config/typed_config.h +++ b/include/envoy/config/typed_config.h @@ -2,6 +2,7 @@ #include "envoy/common/pure.h" +#include "common/common/assert.h" #include "common/protobuf/protobuf.h" namespace Envoy { @@ -49,9 +50,7 @@ class TypedFactory : public UntypedFactory { const std::string configType() override { auto ptr = createEmptyConfigProto(); - if (ptr == nullptr) { - return ""; - } + ASSERT(ptr != nullptr); return ptr->GetDescriptor()->full_name(); } }; From b3a65bc8c5bb215209901dbecc47da4908cbaac9 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Mon, 30 Dec 2019 14:07:04 -0800 Subject: [PATCH 08/12] fix signatures Signed-off-by: Kuat Yessenov --- include/envoy/config/typed_config.h | 8 ++++---- include/envoy/config/typed_metadata.h | 2 +- include/envoy/grpc/google_grpc_creds.h | 2 +- include/envoy/network/resolver.h | 2 +- include/envoy/server/access_log_config.h | 2 +- include/envoy/server/active_udp_listener_config.h | 2 +- include/envoy/server/filter_config.h | 10 +++++----- include/envoy/server/health_checker_config.h | 2 +- include/envoy/server/resource_monitor_config.h | 2 +- include/envoy/server/tracer_config.h | 2 +- include/envoy/server/transport_socket_config.h | 4 ++-- include/envoy/singleton/manager.h | 4 ++-- include/envoy/ssl/context_manager.h | 4 ++-- include/envoy/ssl/private_key/private_key_config.h | 2 +- include/envoy/upstream/cluster_factory.h | 2 +- include/envoy/upstream/retry.h | 4 ++-- source/common/access_log/access_log_impl.h | 2 +- source/common/grpc/google_grpc_creds_impl.cc | 2 +- source/common/http/http3/quic_codec_factory.h | 4 ++-- source/common/network/resolver_impl.cc | 2 +- source/common/upstream/cluster_factory_impl.h | 2 +- source/extensions/access_loggers/file/config.cc | 2 +- source/extensions/access_loggers/file/config.h | 2 +- .../extensions/access_loggers/grpc/http_config.cc | 2 +- .../extensions/access_loggers/grpc/http_config.h | 2 +- .../extensions/access_loggers/grpc/tcp_config.cc | 2 +- source/extensions/access_loggers/grpc/tcp_config.h | 2 +- .../extensions/common/wasm/null/null_vm_plugin.h | 2 +- .../filters/http/common/empty_http_filter_config.h | 2 +- .../extensions/filters/http/common/factory_base.h | 2 +- .../filters/listener/http_inspector/config.cc | 2 +- .../filters/listener/original_dst/config.cc | 2 +- .../original_src/original_src_config_factory.h | 2 +- .../filters/listener/proxy_protocol/config.cc | 2 +- .../filters/listener/tls_inspector/config.cc | 2 +- .../filters/network/common/factory_base.h | 2 +- .../network/dubbo_proxy/filters/factory_base.h | 2 +- .../network/dubbo_proxy/filters/filter_config.h | 2 +- .../filters/network/dubbo_proxy/protocol.h | 4 ++-- .../filters/network/dubbo_proxy/router/route.h | 4 ++-- .../filters/network/dubbo_proxy/serializer.h | 4 ++-- source/extensions/filters/network/echo/config.cc | 2 +- .../filters/network/sni_cluster/config.h | 2 +- .../network/thrift_proxy/filters/factory_base.h | 2 +- .../network/thrift_proxy/filters/filter_config.h | 2 +- .../filters/network/thrift_proxy/protocol.h | 4 ++-- .../filters/network/thrift_proxy/transport.h | 4 ++-- source/extensions/filters/udp/udp_proxy/config.h | 2 +- .../extensions/grpc_credentials/aws_iam/config.h | 2 +- .../extensions/grpc_credentials/example/config.h | 2 +- .../grpc_credentials/file_based_metadata/config.h | 2 +- source/extensions/health_checkers/redis/config.h | 2 +- .../quiche/active_quic_listener_config.cc | 2 +- .../quiche/active_quic_listener_config.h | 2 +- .../extensions/quic_listeners/quiche/codec_impl.h | 4 ++-- .../quiche/quic_transport_socket_factory.h | 6 +++--- .../resource_monitors/common/factory_base.h | 4 ++-- .../retry/host/omit_canary_hosts/config.h | 2 +- .../extensions/retry/host/previous_hosts/config.h | 2 +- .../retry/priority/previous_priorities/config.h | 2 +- source/extensions/stat_sinks/dog_statsd/config.cc | 2 +- source/extensions/stat_sinks/dog_statsd/config.h | 2 +- source/extensions/stat_sinks/hystrix/config.cc | 2 +- source/extensions/stat_sinks/hystrix/config.h | 2 +- .../stat_sinks/metrics_service/config.cc | 4 +--- .../extensions/stat_sinks/metrics_service/config.h | 2 +- source/extensions/stat_sinks/statsd/config.cc | 2 +- source/extensions/stat_sinks/statsd/config.h | 2 +- source/extensions/tracers/common/factory_base.h | 2 +- source/extensions/transport_sockets/alts/config.h | 2 +- .../transport_sockets/raw_buffer/config.h | 2 +- source/extensions/transport_sockets/tap/config.h | 2 +- source/extensions/transport_sockets/tls/config.h | 2 +- source/server/active_raw_udp_listener_config.cc | 2 +- source/server/active_raw_udp_listener_config.h | 2 +- source/server/configuration_impl.h | 2 +- test/common/access_log/access_log_impl_test.cc | 4 ++-- test/common/config/metadata_test.cc | 2 +- test/common/config/registry_test.cc | 10 +++++----- test/common/network/resolver_impl_test.cc | 2 +- test/common/router/config_impl_test.cc | 2 +- test/common/upstream/cluster_manager_impl_test.cc | 2 +- .../upstream/transport_socket_matcher_test.cc | 2 +- test/common/upstream/upstream_impl_test.cc | 14 +++++--------- test/extensions/common/wasm/wasm_vm_test.cc | 2 +- .../extensions/filters/network/dubbo_proxy/mocks.h | 8 +++----- .../filters/network/dubbo_proxy/router_test.cc | 6 ++---- .../filters/network/thrift_proxy/router_test.cc | 4 ++-- .../tls/test_private_key_method_provider.h | 2 +- .../integration/cluster_filter_integration_test.cc | 2 +- test/integration/filter_manager_integration_test.h | 2 +- test/integration/tcp_conn_pool_integration_test.cc | 4 +--- test/integration/test_host_predicate_config.h | 2 +- test/mocks/network/mocks.h | 2 +- test/mocks/upstream/mocks.h | 4 ++-- test/server/listener_manager_impl_test.cc | 8 ++++---- test/server/options_impl_test.cc | 8 ++++---- test/server/server_test.cc | 4 ++-- 98 files changed, 140 insertions(+), 152 deletions(-) diff --git a/include/envoy/config/typed_config.h b/include/envoy/config/typed_config.h index 1dc3fab84ffa..574562ff6bc0 100644 --- a/include/envoy/config/typed_config.h +++ b/include/envoy/config/typed_config.h @@ -19,19 +19,19 @@ class UntypedFactory { * Name of the factory, a reversed DNS name is encouraged to avoid cross-org conflict. * It's used as key in the metadata map, as well as key in the factory registry. */ - virtual const std::string name() const PURE; + virtual std::string name() const PURE; /** * @return std::string the identifying category name for objects * created by this factory. Used for automatic registration with * FactoryCategoryRegistry. */ - virtual const std::string category() const PURE; + virtual std::string category() const PURE; /** * @return configuration proto full name, or empty for untyped factories. */ - virtual const std::string configType() { return ""; } + virtual std::string configType() { return ""; } }; /** @@ -48,7 +48,7 @@ class TypedFactory : public UntypedFactory { */ virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; - const std::string configType() override { + std::string configType() override { auto ptr = createEmptyConfigProto(); ASSERT(ptr != nullptr); return ptr->GetDescriptor()->full_name(); diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index 872be00df80a..0604f09c7a8d 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -65,7 +65,7 @@ class TypedMetadataFactory : public UntypedFactory { virtual std::unique_ptr parse(const ProtobufWkt::Struct& data) const PURE; - const std::string category() const override { return "typed_metadata"; } + std::string category() const override { return "typed_metadata"; } }; } // namespace Config diff --git a/include/envoy/grpc/google_grpc_creds.h b/include/envoy/grpc/google_grpc_creds.h index ba5354ff046e..fe2fefdd584a 100644 --- a/include/envoy/grpc/google_grpc_creds.h +++ b/include/envoy/grpc/google_grpc_creds.h @@ -35,7 +35,7 @@ class GoogleGrpcCredentialsFactory : public Config::UntypedFactory { getChannelCredentials(const envoy::api::v2::core::GrpcService& grpc_service_config, Api::Api& api) PURE; - const std::string category() const override { return "grpc_credentials"; } + std::string category() const override { return "grpc_credentials"; } }; } // namespace Grpc diff --git a/include/envoy/network/resolver.h b/include/envoy/network/resolver.h index 6182f8e97b83..22b7c652ba96 100644 --- a/include/envoy/network/resolver.h +++ b/include/envoy/network/resolver.h @@ -29,7 +29,7 @@ class Resolver : public Config::UntypedFactory { virtual InstanceConstSharedPtr resolve(const envoy::api::v2::core::SocketAddress& socket_address) PURE; - const std::string category() const override { return "resolvers"; } + std::string category() const override { return "resolvers"; } }; } // namespace Address diff --git a/include/envoy/server/access_log_config.h b/include/envoy/server/access_log_config.h index b4dcff783815..596c63d41e8a 100644 --- a/include/envoy/server/access_log_config.h +++ b/include/envoy/server/access_log_config.h @@ -33,7 +33,7 @@ class AccessLogInstanceFactory : public Config::TypedFactory { AccessLog::FilterPtr&& filter, FactoryContext& context) PURE; - const std::string category() const override { return "access_loggers"; } + std::string category() const override { return "access_loggers"; } }; } // namespace Configuration diff --git a/include/envoy/server/active_udp_listener_config.h b/include/envoy/server/active_udp_listener_config.h index 4235bdb02eb2..56ea2f4f00b0 100644 --- a/include/envoy/server/active_udp_listener_config.h +++ b/include/envoy/server/active_udp_listener_config.h @@ -24,7 +24,7 @@ class ActiveUdpListenerConfigFactory : public Config::UntypedFactory { virtual Network::ActiveUdpListenerFactoryPtr createActiveUdpListenerFactory(const Protobuf::Message& message) PURE; - const std::string category() const override { return "udp_listeners"; } + std::string category() const override { return "udp_listeners"; } }; } // namespace Server diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index c0bee664b071..268d7d8fce0f 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -238,7 +238,7 @@ class NamedListenerFilterConfigFactory : public ListenerFilterConfigFactoryBase createFilterFactoryFromProto(const Protobuf::Message& config, ListenerFactoryContext& context) PURE; - const std::string category() const override { return "filters.listener"; } + std::string category() const override { return "filters.listener"; } }; /** @@ -261,7 +261,7 @@ class NamedUdpListenerFilterConfigFactory : public ListenerFilterConfigFactoryBa createFilterFactoryFromProto(const Protobuf::Message& config, ListenerFactoryContext& context) PURE; - const std::string category() const override { return "filters.udp_listener"; } + std::string category() const override { return "filters.udp_listener"; } }; /** @@ -314,7 +314,7 @@ class NamedNetworkFilterConfigFactory : public ProtocolOptionsFactory { virtual Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message& config, FactoryContext& context) PURE; - const std::string category() const override { return "filters.network"; } + std::string category() const override { return "filters.network"; } /** * @return bool true if this filter must be the last filter in a filter chain, false otherwise. @@ -338,7 +338,7 @@ class NamedUpstreamNetworkFilterConfigFactory : public ProtocolOptionsFactory { virtual Network::FilterFactoryCb createFilterFactoryFromProto(const Protobuf::Message& config, CommonFactoryContext& context) PURE; - const std::string category() const override { return "filters.upstream_network"; } + std::string category() const override { return "filters.upstream_network"; } }; /** @@ -384,7 +384,7 @@ class NamedHttpFilterConfigFactory : public ProtocolOptionsFactory { return nullptr; } - const std::string category() const override { return "filters.http"; } + std::string category() const override { return "filters.http"; } /** * @return bool true if this filter must be the last filter in a filter chain, false otherwise. diff --git a/include/envoy/server/health_checker_config.h b/include/envoy/server/health_checker_config.h index 6423d50f0648..36ba792c848e 100644 --- a/include/envoy/server/health_checker_config.h +++ b/include/envoy/server/health_checker_config.h @@ -73,7 +73,7 @@ class CustomHealthCheckerFactory : public Config::UntypedFactory { createCustomHealthChecker(const envoy::api::v2::core::HealthCheck& config, HealthCheckerFactoryContext& context) PURE; - const std::string category() const override { return "health_checkers"; } + std::string category() const override { return "health_checkers"; } }; } // namespace Configuration diff --git a/include/envoy/server/resource_monitor_config.h b/include/envoy/server/resource_monitor_config.h index a4720c44e2a9..cc439602016e 100644 --- a/include/envoy/server/resource_monitor_config.h +++ b/include/envoy/server/resource_monitor_config.h @@ -55,7 +55,7 @@ class ResourceMonitorFactory : public Config::TypedFactory { virtual ResourceMonitorPtr createResourceMonitor(const Protobuf::Message& config, ResourceMonitorFactoryContext& context) PURE; - const std::string category() const override { return "resource_monitors"; } + std::string category() const override { return "resource_monitors"; } }; } // namespace Configuration diff --git a/include/envoy/server/tracer_config.h b/include/envoy/server/tracer_config.h index e14dddfef681..590f0475a13a 100644 --- a/include/envoy/server/tracer_config.h +++ b/include/envoy/server/tracer_config.h @@ -30,7 +30,7 @@ class TracerFactory : public Config::TypedFactory { virtual Tracing::HttpTracerPtr createHttpTracer(const Protobuf::Message& config, Instance& server) PURE; - const std::string category() const override { return "tracers"; } + std::string category() const override { return "tracers"; } }; } // namespace Configuration diff --git a/include/envoy/server/transport_socket_config.h b/include/envoy/server/transport_socket_config.h index a35eaf6978b1..e0436eafd638 100644 --- a/include/envoy/server/transport_socket_config.h +++ b/include/envoy/server/transport_socket_config.h @@ -133,7 +133,7 @@ class UpstreamTransportSocketConfigFactory : public virtual TransportSocketConfi createTransportSocketFactory(const Protobuf::Message& config, TransportSocketFactoryContext& context) PURE; - const std::string category() const override { return "transport_sockets.upstream"; } + std::string category() const override { return "transport_sockets.upstream"; } }; /** @@ -160,7 +160,7 @@ class DownstreamTransportSocketConfigFactory : public virtual TransportSocketCon TransportSocketFactoryContext& context, const std::vector& server_names) PURE; - const std::string category() const override { return "transport_sockets.downstream"; } + std::string category() const override { return "transport_sockets.downstream"; } }; } // namespace Configuration diff --git a/include/envoy/singleton/manager.h b/include/envoy/singleton/manager.h index 75344aaedc8e..9363363e8c42 100644 --- a/include/envoy/singleton/manager.h +++ b/include/envoy/singleton/manager.h @@ -18,7 +18,7 @@ namespace Singleton { class Registration : public Config::UntypedFactory { public: virtual ~Registration() = default; - const std::string category() const override { return "singleton"; } + std::string category() const override { return "singleton"; } }; /** @@ -35,7 +35,7 @@ class Registration : public Config::UntypedFactory { */ template class RegistrationImpl : public Registration { public: - const std::string name() const override { return name_param; } + std::string name() const override { return name_param; } }; /** diff --git a/include/envoy/ssl/context_manager.h b/include/envoy/ssl/context_manager.h index e1282d421f42..dcc49f7e314a 100644 --- a/include/envoy/ssl/context_manager.h +++ b/include/envoy/ssl/context_manager.h @@ -57,8 +57,8 @@ class ContextManagerFactory : public Config::UntypedFactory { virtual ContextManagerPtr createContextManager(TimeSource& time_source) PURE; // There could be only one factory thus the name is static. - const std::string name() const override { return "ssl_context_manager"; } - const std::string category() const override { return "ssl_context_manager"; } + std::string name() const override { return "ssl_context_manager"; } + std::string category() const override { return "ssl_context_manager"; } }; } // namespace Ssl diff --git a/include/envoy/ssl/private_key/private_key_config.h b/include/envoy/ssl/private_key/private_key_config.h index b2cea34671a5..69285cdf79ab 100644 --- a/include/envoy/ssl/private_key/private_key_config.h +++ b/include/envoy/ssl/private_key/private_key_config.h @@ -25,7 +25,7 @@ class PrivateKeyMethodProviderInstanceFactory : public Config::UntypedFactory { const envoy::api::v2::auth::PrivateKeyProvider& config, Server::Configuration::TransportSocketFactoryContext& factory_context) PURE; - const std::string category() const override { return "tls.key_providers"; }; + std::string category() const override { return "tls.key_providers"; }; }; } // namespace Ssl diff --git a/include/envoy/upstream/cluster_factory.h b/include/envoy/upstream/cluster_factory.h index 46da6e60f3fd..01a4fbf3d109 100644 --- a/include/envoy/upstream/cluster_factory.h +++ b/include/envoy/upstream/cluster_factory.h @@ -139,7 +139,7 @@ class ClusterFactory : public Config::UntypedFactory { virtual std::pair create(const envoy::api::v2::Cluster& cluster, ClusterFactoryContext& context) PURE; - const std::string category() const override { return "clusters"; } + std::string category() const override { return "clusters"; } }; } // namespace Upstream diff --git a/include/envoy/upstream/retry.h b/include/envoy/upstream/retry.h index 14451b12925b..590354ee2f6b 100644 --- a/include/envoy/upstream/retry.h +++ b/include/envoy/upstream/retry.h @@ -85,7 +85,7 @@ class RetryPriorityFactory : public Config::TypedFactory { ProtobufMessage::ValidationVisitor& validation_visitor, uint32_t retry_count) PURE; - const std::string category() const override { return "retry_priorities"; } + std::string category() const override { return "retry_priorities"; } }; /** @@ -98,7 +98,7 @@ class RetryHostPredicateFactory : public Config::TypedFactory { virtual RetryHostPredicateSharedPtr createHostPredicate(const Protobuf::Message& config, uint32_t retry_count) PURE; - const std::string category() const override { return "retry_host_predicates"; } + std::string category() const override { return "retry_host_predicates"; } }; } // namespace Upstream diff --git a/source/common/access_log/access_log_impl.h b/source/common/access_log/access_log_impl.h index 5c6ad5d7a1ea..7db1d8c0345d 100644 --- a/source/common/access_log/access_log_impl.h +++ b/source/common/access_log/access_log_impl.h @@ -248,7 +248,7 @@ class ExtensionFilterFactory : public Config::TypedFactory { createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader& runtime, Runtime::RandomGenerator& random) PURE; - const std::string category() const override { return "access_logger.extension_filters"; } + std::string category() const override { return "access_logger.extension_filters"; } }; /** diff --git a/source/common/grpc/google_grpc_creds_impl.cc b/source/common/grpc/google_grpc_creds_impl.cc index 94165054e992..86187ee3cb4a 100644 --- a/source/common/grpc/google_grpc_creds_impl.cc +++ b/source/common/grpc/google_grpc_creds_impl.cc @@ -135,7 +135,7 @@ class DefaultGoogleGrpcCredentialsFactory : public GoogleGrpcCredentialsFactory return CredsUtility::defaultChannelCredentials(grpc_service_config, api); } - const std::string name() const override { return "envoy.grpc_credentials.default"; } + std::string name() const override { return "envoy.grpc_credentials.default"; } }; /** diff --git a/source/common/http/http3/quic_codec_factory.h b/source/common/http/http3/quic_codec_factory.h index de6d53e4b334..64d732814f9c 100644 --- a/source/common/http/http3/quic_codec_factory.h +++ b/source/common/http/http3/quic_codec_factory.h @@ -17,7 +17,7 @@ class QuicHttpServerConnectionFactory : public Config::UntypedFactory { virtual std::unique_ptr createQuicServerConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; - const std::string category() const override { return "quic_client_codec"; } + std::string category() const override { return "quic_client_codec"; } }; // A factory to create Http::ClientConnection instance for QUIC. @@ -28,7 +28,7 @@ class QuicHttpClientConnectionFactory : public Config::UntypedFactory { virtual std::unique_ptr createQuicClientConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; - const std::string category() const override { return "quic_server_codec"; } + std::string category() const override { return "quic_server_codec"; } }; } // namespace Http diff --git a/source/common/network/resolver_impl.cc b/source/common/network/resolver_impl.cc index d235fe3e4693..f07bc304ae2a 100644 --- a/source/common/network/resolver_impl.cc +++ b/source/common/network/resolver_impl.cc @@ -35,7 +35,7 @@ class IpResolver : public Resolver { } } - const std::string name() const override { return Config::AddressResolverNames::get().IP; } + std::string name() const override { return Config::AddressResolverNames::get().IP; } }; /** diff --git a/source/common/upstream/cluster_factory_impl.h b/source/common/upstream/cluster_factory_impl.h index 1de4465b796f..70f3f8bfd53e 100644 --- a/source/common/upstream/cluster_factory_impl.h +++ b/source/common/upstream/cluster_factory_impl.h @@ -135,7 +135,7 @@ class ClusterFactoryImplBase : public ClusterFactory { // Upstream::ClusterFactory std::pair create(const envoy::api::v2::Cluster& cluster, ClusterFactoryContext& context) override; - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: ClusterFactoryImplBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/access_loggers/file/config.cc b/source/extensions/access_loggers/file/config.cc index b62c317bc429..556037f5f65a 100644 --- a/source/extensions/access_loggers/file/config.cc +++ b/source/extensions/access_loggers/file/config.cc @@ -59,7 +59,7 @@ ProtobufTypes::MessagePtr FileAccessLogFactory::createEmptyConfigProto() { return ProtobufTypes::MessagePtr{new envoy::config::accesslog::v2::FileAccessLog()}; } -const std::string FileAccessLogFactory::name() const { return AccessLogNames::get().File; } +std::string FileAccessLogFactory::name() const { return AccessLogNames::get().File; } std::unordered_map FileAccessLogFactory::convertJsonFormatToMap(ProtobufWkt::Struct json_format) { diff --git a/source/extensions/access_loggers/file/config.h b/source/extensions/access_loggers/file/config.h index f78ac2a0da7c..7f3976adfc8b 100644 --- a/source/extensions/access_loggers/file/config.h +++ b/source/extensions/access_loggers/file/config.h @@ -18,7 +18,7 @@ class FileAccessLogFactory : public Server::Configuration::AccessLogInstanceFact ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; private: std::unordered_map convertJsonFormatToMap(ProtobufWkt::Struct config); diff --git a/source/extensions/access_loggers/grpc/http_config.cc b/source/extensions/access_loggers/grpc/http_config.cc index 94fb35d1c601..89a050985b79 100644 --- a/source/extensions/access_loggers/grpc/http_config.cc +++ b/source/extensions/access_loggers/grpc/http_config.cc @@ -39,7 +39,7 @@ ProtobufTypes::MessagePtr HttpGrpcAccessLogFactory::createEmptyConfigProto() { return std::make_unique(); } -const std::string HttpGrpcAccessLogFactory::name() const { return AccessLogNames::get().HttpGrpc; } +std::string HttpGrpcAccessLogFactory::name() const { return AccessLogNames::get().HttpGrpc; } /** * Static registration for the HTTP gRPC access log. @see RegisterFactory. diff --git a/source/extensions/access_loggers/grpc/http_config.h b/source/extensions/access_loggers/grpc/http_config.h index e508f8624a85..c88a3a5ac62d 100644 --- a/source/extensions/access_loggers/grpc/http_config.h +++ b/source/extensions/access_loggers/grpc/http_config.h @@ -20,7 +20,7 @@ class HttpGrpcAccessLogFactory : public Server::Configuration::AccessLogInstance ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; }; } // namespace HttpGrpc diff --git a/source/extensions/access_loggers/grpc/tcp_config.cc b/source/extensions/access_loggers/grpc/tcp_config.cc index e5b21a4e8f81..6af51e20b4bf 100644 --- a/source/extensions/access_loggers/grpc/tcp_config.cc +++ b/source/extensions/access_loggers/grpc/tcp_config.cc @@ -38,7 +38,7 @@ ProtobufTypes::MessagePtr TcpGrpcAccessLogFactory::createEmptyConfigProto() { return std::make_unique(); } -const std::string TcpGrpcAccessLogFactory::name() const { return AccessLogNames::get().TcpGrpc; } +std::string TcpGrpcAccessLogFactory::name() const { return AccessLogNames::get().TcpGrpc; } /** * Static registration for the TCP gRPC access log. @see RegisterFactory. diff --git a/source/extensions/access_loggers/grpc/tcp_config.h b/source/extensions/access_loggers/grpc/tcp_config.h index 29f410d8b112..39bc986146b9 100644 --- a/source/extensions/access_loggers/grpc/tcp_config.h +++ b/source/extensions/access_loggers/grpc/tcp_config.h @@ -20,7 +20,7 @@ class TcpGrpcAccessLogFactory : public Server::Configuration::AccessLogInstanceF ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; }; } // namespace TcpGrpc diff --git a/source/extensions/common/wasm/null/null_vm_plugin.h b/source/extensions/common/wasm/null/null_vm_plugin.h index cb401830fdd6..5f6a62ead9ec 100644 --- a/source/extensions/common/wasm/null/null_vm_plugin.h +++ b/source/extensions/common/wasm/null/null_vm_plugin.h @@ -32,7 +32,7 @@ class NullVmPluginFactory : public Config::UntypedFactory { public: virtual ~NullVmPluginFactory() = default; - const std::string category() const override { return "wasm.null_vms"; } + std::string category() const override { return "wasm.null_vms"; } /** * Create an instance of the plugin. diff --git a/source/extensions/filters/http/common/empty_http_filter_config.h b/source/extensions/filters/http/common/empty_http_filter_config.h index 4338acdeccab..7e5fd3522985 100644 --- a/source/extensions/filters/http/common/empty_http_filter_config.h +++ b/source/extensions/filters/http/common/empty_http_filter_config.h @@ -32,7 +32,7 @@ class EmptyHttpFilterConfig : public Server::Configuration::NamedHttpFilterConfi return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: EmptyHttpFilterConfig(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/http/common/factory_base.h b/source/extensions/filters/http/common/factory_base.h index 35a8593e36f8..6aee7a15b36a 100644 --- a/source/extensions/filters/http/common/factory_base.h +++ b/source/extensions/filters/http/common/factory_base.h @@ -40,7 +40,7 @@ class FactoryBase : public Server::Configuration::NamedHttpFilterConfigFactory { validator); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/listener/http_inspector/config.cc b/source/extensions/filters/listener/http_inspector/config.cc index 377719b0e6a0..cb81bfa1505b 100644 --- a/source/extensions/filters/listener/http_inspector/config.cc +++ b/source/extensions/filters/listener/http_inspector/config.cc @@ -28,7 +28,7 @@ class HttpInspectorConfigFactory : public Server::Configuration::NamedListenerFi return std::make_unique(); } - const std::string name() const override { return ListenerFilterNames::get().HttpInspector; } + std::string name() const override { return ListenerFilterNames::get().HttpInspector; } }; /** diff --git a/source/extensions/filters/listener/original_dst/config.cc b/source/extensions/filters/listener/original_dst/config.cc index ef99384cdb0a..230f99a54e5b 100644 --- a/source/extensions/filters/listener/original_dst/config.cc +++ b/source/extensions/filters/listener/original_dst/config.cc @@ -29,7 +29,7 @@ class OriginalDstConfigFactory : public Server::Configuration::NamedListenerFilt return std::make_unique(); } - const std::string name() const override { return ListenerFilterNames::get().OriginalDst; } + std::string name() const override { return ListenerFilterNames::get().OriginalDst; } }; /** diff --git a/source/extensions/filters/listener/original_src/original_src_config_factory.h b/source/extensions/filters/listener/original_src/original_src_config_factory.h index 6d176ca9dfed..ea1a3cbd4ee3 100644 --- a/source/extensions/filters/listener/original_src/original_src_config_factory.h +++ b/source/extensions/filters/listener/original_src/original_src_config_factory.h @@ -21,7 +21,7 @@ class OriginalSrcConfigFactory : public Server::Configuration::NamedListenerFilt ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override { return ListenerFilterNames::get().OriginalSrc; } + std::string name() const override { return ListenerFilterNames::get().OriginalSrc; } }; } // namespace OriginalSrc diff --git a/source/extensions/filters/listener/proxy_protocol/config.cc b/source/extensions/filters/listener/proxy_protocol/config.cc index e523df96e1b8..e3c2f8122462 100644 --- a/source/extensions/filters/listener/proxy_protocol/config.cc +++ b/source/extensions/filters/listener/proxy_protocol/config.cc @@ -28,7 +28,7 @@ class ProxyProtocolConfigFactory : public Server::Configuration::NamedListenerFi return std::make_unique(); } - const std::string name() const override { return ListenerFilterNames::get().ProxyProtocol; } + std::string name() const override { return ListenerFilterNames::get().ProxyProtocol; } }; /** diff --git a/source/extensions/filters/listener/tls_inspector/config.cc b/source/extensions/filters/listener/tls_inspector/config.cc index fe8b6d46a77d..cfe5ace74e2d 100644 --- a/source/extensions/filters/listener/tls_inspector/config.cc +++ b/source/extensions/filters/listener/tls_inspector/config.cc @@ -30,7 +30,7 @@ class TlsInspectorConfigFactory : public Server::Configuration::NamedListenerFil return std::make_unique(); } - const std::string name() const override { return ListenerFilterNames::get().TlsInspector; } + std::string name() const override { return ListenerFilterNames::get().TlsInspector; } }; /** diff --git a/source/extensions/filters/network/common/factory_base.h b/source/extensions/filters/network/common/factory_base.h index 8137262dd1a6..d11eca0ec750 100644 --- a/source/extensions/filters/network/common/factory_base.h +++ b/source/extensions/filters/network/common/factory_base.h @@ -38,7 +38,7 @@ class FactoryBase : public Server::Configuration::NamedNetworkFilterConfigFactor proto_config, validation_visitor)); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } bool isTerminalFilter() override { return is_terminal_filter_; } diff --git a/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h b/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h index ee7390e6805d..4591ca9aac82 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h +++ b/source/extensions/filters/network/dubbo_proxy/filters/factory_base.h @@ -30,7 +30,7 @@ template class FactoryBase : public NamedDubboFilterConfigFa return std::make_unique(); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h index 4d9f77f917f5..2ccbd9047790 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h @@ -38,7 +38,7 @@ class NamedDubboFilterConfigFactory : public Envoy::Config::TypedFactory { createFilterFactoryFromProto(const Protobuf::Message& config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) PURE; - const std::string category() const override { return "dubbo_proxy.filters"; } + std::string category() const override { return "dubbo_proxy.filters"; } }; } // namespace DubboFilters diff --git a/source/extensions/filters/network/dubbo_proxy/protocol.h b/source/extensions/filters/network/dubbo_proxy/protocol.h index 8609cb90a273..e75e82bcc574 100644 --- a/source/extensions/filters/network/dubbo_proxy/protocol.h +++ b/source/extensions/filters/network/dubbo_proxy/protocol.h @@ -109,7 +109,7 @@ class NamedProtocolConfigFactory : public Config::UntypedFactory { */ virtual ProtocolPtr createProtocol(SerializationType serialization_type) PURE; - const std::string category() const override { return "dubbo_proxy.protocols"; } + std::string category() const override { return "dubbo_proxy.protocols"; } /** * Convenience method to lookup a factory by type. @@ -133,7 +133,7 @@ template class ProtocolFactoryBase : public NamedProtocolCo return protocol; } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: ProtocolFactoryBase(ProtocolType type) : name_(ProtocolNames::get().fromType(type)) {} diff --git a/source/extensions/filters/network/dubbo_proxy/router/route.h b/source/extensions/filters/network/dubbo_proxy/router/route.h index 011710977a1f..87d451272b8d 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route.h @@ -79,7 +79,7 @@ class NamedRouteMatcherConfigFactory : public Envoy::Config::UntypedFactory { virtual RouteMatcherPtr createRouteMatcher(const RouteConfigurations& route_configs, Server::Configuration::FactoryContext& context) PURE; - const std::string category() const override { return "dubbo_proxy.route_matchers"; } + std::string category() const override { return "dubbo_proxy.route_matchers"; } /** * Convenience method to lookup a factory by type. @@ -103,7 +103,7 @@ class RouteMatcherFactoryBase : public NamedRouteMatcherConfigFactory { return std::make_unique(route_configs, context); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: RouteMatcherFactoryBase(RouteMatcherType type) : name_(RouteMatcherNames::get().fromType(type)) {} diff --git a/source/extensions/filters/network/dubbo_proxy/serializer.h b/source/extensions/filters/network/dubbo_proxy/serializer.h index 5bfad74490e4..32623f36910f 100644 --- a/source/extensions/filters/network/dubbo_proxy/serializer.h +++ b/source/extensions/filters/network/dubbo_proxy/serializer.h @@ -89,7 +89,7 @@ class NamedSerializerConfigFactory : public Config::UntypedFactory { */ virtual SerializerPtr createSerializer() PURE; - const std::string category() const override { return "dubbo_proxy.serializers"; } + std::string category() const override { return "dubbo_proxy.serializers"; } /** * Convenience method to lookup a factory by type. @@ -110,7 +110,7 @@ template class SerializerFactoryBase : public NamedSerial public: SerializerPtr createSerializer() override { return std::make_unique(); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: SerializerFactoryBase(ProtocolType protocol_type, SerializationType type) diff --git a/source/extensions/filters/network/echo/config.cc b/source/extensions/filters/network/echo/config.cc index 0e640435a787..47375949ed4f 100644 --- a/source/extensions/filters/network/echo/config.cc +++ b/source/extensions/filters/network/echo/config.cc @@ -27,7 +27,7 @@ class EchoConfigFactory : public Server::Configuration::NamedNetworkFilterConfig return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { return NetworkFilterNames::get().Echo; } + std::string name() const override { return NetworkFilterNames::get().Echo; } bool isTerminalFilter() override { return true; } }; diff --git a/source/extensions/filters/network/sni_cluster/config.h b/source/extensions/filters/network/sni_cluster/config.h index 55cc4c06ddfa..9091e7685401 100644 --- a/source/extensions/filters/network/sni_cluster/config.h +++ b/source/extensions/filters/network/sni_cluster/config.h @@ -19,7 +19,7 @@ class SniClusterNetworkFilterConfigFactory createFilterFactoryFromProto(const Protobuf::Message&, Server::Configuration::FactoryContext&) override; ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override { return NetworkFilterNames::get().SniCluster; } + std::string name() const override { return NetworkFilterNames::get().SniCluster; } }; } // namespace SniCluster diff --git a/source/extensions/filters/network/thrift_proxy/filters/factory_base.h b/source/extensions/filters/network/thrift_proxy/filters/factory_base.h index b5aa1750cbce..3f6f1b144d11 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/factory_base.h +++ b/source/extensions/filters/network/thrift_proxy/filters/factory_base.h @@ -25,7 +25,7 @@ template class FactoryBase : public NamedThriftFilterConfigF return std::make_unique(); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h index d9d31ba8bd07..47e7f5f37bd6 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h @@ -35,7 +35,7 @@ class NamedThriftFilterConfigFactory : public Envoy::Config::TypedFactory { createFilterFactoryFromProto(const Protobuf::Message& config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) PURE; - const std::string category() const override { return "thrift_proxy.filters"; } + std::string category() const override { return "thrift_proxy.filters"; } }; } // namespace ThriftFilters diff --git a/source/extensions/filters/network/thrift_proxy/protocol.h b/source/extensions/filters/network/thrift_proxy/protocol.h index ce5bc8f14f2f..c6406ceb7e82 100644 --- a/source/extensions/filters/network/thrift_proxy/protocol.h +++ b/source/extensions/filters/network/thrift_proxy/protocol.h @@ -509,7 +509,7 @@ class NamedProtocolConfigFactory : public Config::UntypedFactory { */ virtual ProtocolPtr createProtocol() PURE; - const std::string category() const override { return "thrift_proxy.protocols"; } + std::string category() const override { return "thrift_proxy.protocols"; } /** * Convenience method to lookup a factory by type. @@ -529,7 +529,7 @@ template class ProtocolFactoryBase : public NamedProtocolCo public: ProtocolPtr createProtocol() override { return std::move(std::make_unique()); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: ProtocolFactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/network/thrift_proxy/transport.h b/source/extensions/filters/network/thrift_proxy/transport.h index abc2e321f6bb..f1801973b10a 100644 --- a/source/extensions/filters/network/thrift_proxy/transport.h +++ b/source/extensions/filters/network/thrift_proxy/transport.h @@ -93,7 +93,7 @@ class NamedTransportConfigFactory : public Envoy::Config::UntypedFactory { */ virtual TransportPtr createTransport() PURE; - const std::string category() const override { return "thrift_proxy.transports"; } + std::string category() const override { return "thrift_proxy.transports"; } /** * Convenience method to lookup a factory by type. @@ -113,7 +113,7 @@ template class TransportFactoryBase : public NamedTranspor public: TransportPtr createTransport() override { return std::move(std::make_unique()); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: TransportFactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/filters/udp/udp_proxy/config.h b/source/extensions/filters/udp/udp_proxy/config.h index 1dbf06f4cdd7..a82991f5dd57 100644 --- a/source/extensions/filters/udp/udp_proxy/config.h +++ b/source/extensions/filters/udp/udp_proxy/config.h @@ -36,7 +36,7 @@ class UdpProxyFilterConfigFactory return std::make_unique(); } - const std::string name() const override { return "envoy.filters.udp_listener.udp_proxy"; } + std::string name() const override { return "envoy.filters.udp_listener.udp_proxy"; } }; } // namespace UdpProxy diff --git a/source/extensions/grpc_credentials/aws_iam/config.h b/source/extensions/grpc_credentials/aws_iam/config.h index 0b1449f5212f..68eae7fb9a89 100644 --- a/source/extensions/grpc_credentials/aws_iam/config.h +++ b/source/extensions/grpc_credentials/aws_iam/config.h @@ -28,7 +28,7 @@ class AwsIamGrpcCredentialsFactory : public Grpc::GoogleGrpcCredentialsFactory { return std::make_unique(); } - const std::string name() const override { return GrpcCredentialsNames::get().AwsIam; } + std::string name() const override { return GrpcCredentialsNames::get().AwsIam; } private: static std::string getRegion(const envoy::config::grpc_credential::v2alpha::AwsIamConfig& config); diff --git a/source/extensions/grpc_credentials/example/config.h b/source/extensions/grpc_credentials/example/config.h index 021f7311ca75..17d3cf6da001 100644 --- a/source/extensions/grpc_credentials/example/config.h +++ b/source/extensions/grpc_credentials/example/config.h @@ -32,7 +32,7 @@ class AccessTokenExampleGrpcCredentialsFactory : public Grpc::GoogleGrpcCredenti getChannelCredentials(const envoy::api::v2::core::GrpcService& grpc_service_config, Api::Api& api) override; - const std::string name() const override { return GrpcCredentialsNames::get().AccessTokenExample; } + std::string name() const override { return GrpcCredentialsNames::get().AccessTokenExample; } }; /* diff --git a/source/extensions/grpc_credentials/file_based_metadata/config.h b/source/extensions/grpc_credentials/file_based_metadata/config.h index 9e7e03c1c505..18dd7cba48ba 100644 --- a/source/extensions/grpc_credentials/file_based_metadata/config.h +++ b/source/extensions/grpc_credentials/file_based_metadata/config.h @@ -32,7 +32,7 @@ class FileBasedMetadataGrpcCredentialsFactory : public Grpc::GoogleGrpcCredentia return std::make_unique(); } - const std::string name() const override { return GrpcCredentialsNames::get().FileBasedMetadata; } + std::string name() const override { return GrpcCredentialsNames::get().FileBasedMetadata; } }; class FileBasedMetadataAuthenticator : public grpc::MetadataCredentialsPlugin { diff --git a/source/extensions/health_checkers/redis/config.h b/source/extensions/health_checkers/redis/config.h index 9e0c187f5849..1a1ebb8cfd03 100644 --- a/source/extensions/health_checkers/redis/config.h +++ b/source/extensions/health_checkers/redis/config.h @@ -21,7 +21,7 @@ class RedisHealthCheckerFactory : public Server::Configuration::CustomHealthChec createCustomHealthChecker(const envoy::api::v2::core::HealthCheck& config, Server::Configuration::HealthCheckerFactoryContext& context) override; - const std::string name() const override { return HealthCheckerNames::get().RedisHealthChecker; } + std::string name() const override { return HealthCheckerNames::get().RedisHealthChecker; } }; } // namespace RedisHealthChecker diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc b/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc index a84f1ca2a7d6..74c9d8355bcf 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc +++ b/source/extensions/quic_listeners/quiche/active_quic_listener_config.cc @@ -17,7 +17,7 @@ ActiveQuicListenerConfigFactory::createActiveUdpListenerFactory(const Protobuf:: return std::make_unique(config); } -const std::string ActiveQuicListenerConfigFactory::name() const { return QuicListenerName; } +std::string ActiveQuicListenerConfigFactory::name() const { return QuicListenerName; } REGISTER_FACTORY(ActiveQuicListenerConfigFactory, Server::ActiveUdpListenerConfigFactory); diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener_config.h b/source/extensions/quic_listeners/quiche/active_quic_listener_config.h index b4ee1ba1dcb4..f63e655d258c 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener_config.h +++ b/source/extensions/quic_listeners/quiche/active_quic_listener_config.h @@ -18,7 +18,7 @@ class ActiveQuicListenerConfigFactory : public Server::ActiveUdpListenerConfigFa Network::ActiveUdpListenerFactoryPtr createActiveUdpListenerFactory(const Protobuf::Message&) override; - const std::string name() const override; + std::string name() const override; }; DECLARE_FACTORY(ActiveQuicListenerConfigFactory); diff --git a/source/extensions/quic_listeners/quiche/codec_impl.h b/source/extensions/quic_listeners/quiche/codec_impl.h index 0e37c5064b0d..3fabff7c3ae5 100644 --- a/source/extensions/quic_listeners/quiche/codec_impl.h +++ b/source/extensions/quic_listeners/quiche/codec_impl.h @@ -84,7 +84,7 @@ class QuicHttpClientConnectionFactoryImpl : public Http::QuicHttpClientConnectio createQuicClientConnection(Network::Connection& connection, Http::ConnectionCallbacks& callbacks) override; - const std::string name() const override { return Http::QuicCodecNames::get().Quiche; } + std::string name() const override { return Http::QuicCodecNames::get().Quiche; } }; // A factory to create QuicHttpServerConnection. @@ -94,7 +94,7 @@ class QuicHttpServerConnectionFactoryImpl : public Http::QuicHttpServerConnectio createQuicServerConnection(Network::Connection& connection, Http::ConnectionCallbacks& callbacks) override; - const std::string name() const override { return Http::QuicCodecNames::get().Quiche; } + std::string name() const override { return Http::QuicCodecNames::get().Quiche; } }; DECLARE_FACTORY(QuicHttpClientConnectionFactoryImpl); diff --git a/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h b/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h index f2cf259f9f49..009af3008368 100644 --- a/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h +++ b/source/extensions/quic_listeners/quiche/quic_transport_socket_factory.h @@ -54,7 +54,7 @@ class QuicTransportSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: // Server::Configuration::TransportSocketConfigFactory - const std::string name() const override { + std::string name() const override { return Extensions::TransportSockets::TransportSocketNames::get().Quic; } }; @@ -73,7 +73,7 @@ class QuicServerTransportSocketConfigFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override; // Prevent double registration for the config proto - const std::string configType() override { return ""; } + std::string configType() override { return ""; } }; DECLARE_FACTORY(QuicServerTransportSocketConfigFactory); @@ -91,7 +91,7 @@ class QuicClientTransportSocketConfigFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override; // Prevent double registration for the config proto - const std::string configType() override { return ""; } + std::string configType() override { return ""; } }; DECLARE_FACTORY(QuicClientTransportSocketConfigFactory); diff --git a/source/extensions/resource_monitors/common/factory_base.h b/source/extensions/resource_monitors/common/factory_base.h index 28cf247a914d..97253f648960 100644 --- a/source/extensions/resource_monitors/common/factory_base.h +++ b/source/extensions/resource_monitors/common/factory_base.h @@ -24,7 +24,7 @@ class FactoryBase : public Server::Configuration::ResourceMonitorFactory { return std::make_unique(); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} @@ -52,7 +52,7 @@ class EmptyConfigFactoryBase : public Server::Configuration::ResourceMonitorFact return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: EmptyConfigFactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/retry/host/omit_canary_hosts/config.h b/source/extensions/retry/host/omit_canary_hosts/config.h index fb3cb5628aa6..e2240e4471af 100644 --- a/source/extensions/retry/host/omit_canary_hosts/config.h +++ b/source/extensions/retry/host/omit_canary_hosts/config.h @@ -16,7 +16,7 @@ class OmitCanaryHostsRetryPredicateFactory : public Upstream::RetryHostPredicate return std::make_shared(); } - const std::string name() const override { + std::string name() const override { return RetryHostPredicateValues::get().OmitCanaryHostsPredicate; } diff --git a/source/extensions/retry/host/previous_hosts/config.h b/source/extensions/retry/host/previous_hosts/config.h index b00ff324b1a5..8c76ba65a9c8 100644 --- a/source/extensions/retry/host/previous_hosts/config.h +++ b/source/extensions/retry/host/previous_hosts/config.h @@ -17,7 +17,7 @@ class PreviousHostsRetryPredicateFactory : public Upstream::RetryHostPredicateFa return std::make_shared(retry_count); } - const std::string name() const override { + std::string name() const override { return RetryHostPredicateValues::get().PreviousHostsPredicate; } diff --git a/source/extensions/retry/priority/previous_priorities/config.h b/source/extensions/retry/priority/previous_priorities/config.h index 31ff74578807..10a9156aa208 100644 --- a/source/extensions/retry/priority/previous_priorities/config.h +++ b/source/extensions/retry/priority/previous_priorities/config.h @@ -20,7 +20,7 @@ class PreviousPrioritiesRetryPriorityFactory : public Upstream::RetryPriorityFac ProtobufMessage::ValidationVisitor& validation_visitor, uint32_t max_retries) override; - const std::string name() const override { + std::string name() const override { return RetryPriorityValues::get().PreviousPrioritiesRetryPriority; } diff --git a/source/extensions/stat_sinks/dog_statsd/config.cc b/source/extensions/stat_sinks/dog_statsd/config.cc index e44b8e1b74bb..89b7d48ae47b 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.cc +++ b/source/extensions/stat_sinks/dog_statsd/config.cc @@ -32,7 +32,7 @@ ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -const std::string DogStatsdSinkFactory::name() const { return StatsSinkNames::get().DogStatsd; } +std::string DogStatsdSinkFactory::name() const { return StatsSinkNames::get().DogStatsd; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/dog_statsd/config.h b/source/extensions/stat_sinks/dog_statsd/config.h index 243e820e100f..5e9cfdef1cb2 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.h +++ b/source/extensions/stat_sinks/dog_statsd/config.h @@ -20,7 +20,7 @@ class DogStatsdSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; }; } // namespace DogStatsd diff --git a/source/extensions/stat_sinks/hystrix/config.cc b/source/extensions/stat_sinks/hystrix/config.cc index a6fb4bdfa75a..6d430e291318 100644 --- a/source/extensions/stat_sinks/hystrix/config.cc +++ b/source/extensions/stat_sinks/hystrix/config.cc @@ -28,7 +28,7 @@ ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -const std::string HystrixSinkFactory::name() const { return StatsSinkNames::get().Hystrix; } +std::string HystrixSinkFactory::name() const { return StatsSinkNames::get().Hystrix; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/hystrix/config.h b/source/extensions/stat_sinks/hystrix/config.h index e5014b0e0ed9..396cab600254 100644 --- a/source/extensions/stat_sinks/hystrix/config.h +++ b/source/extensions/stat_sinks/hystrix/config.h @@ -20,7 +20,7 @@ class HystrixSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; }; } // namespace Hystrix diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index 869cef5458b7..c2ddacea6dbd 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -41,9 +41,7 @@ ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() { std::make_unique()); } -const std::string MetricsServiceSinkFactory::name() const { - return StatsSinkNames::get().MetricsService; -} +std::string MetricsServiceSinkFactory::name() const { return StatsSinkNames::get().MetricsService; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/metrics_service/config.h b/source/extensions/stat_sinks/metrics_service/config.h index ae470be5cc4e..702ea0e97821 100644 --- a/source/extensions/stat_sinks/metrics_service/config.h +++ b/source/extensions/stat_sinks/metrics_service/config.h @@ -21,7 +21,7 @@ class MetricsServiceSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; }; DECLARE_FACTORY(MetricsServiceSinkFactory); diff --git a/source/extensions/stat_sinks/statsd/config.cc b/source/extensions/stat_sinks/statsd/config.cc index 4fe5145a64a9..67b7d5440075 100644 --- a/source/extensions/stat_sinks/statsd/config.cc +++ b/source/extensions/stat_sinks/statsd/config.cc @@ -45,7 +45,7 @@ ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -const std::string StatsdSinkFactory::name() const { return StatsSinkNames::get().Statsd; } +std::string StatsdSinkFactory::name() const { return StatsSinkNames::get().Statsd; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/statsd/config.h b/source/extensions/stat_sinks/statsd/config.h index 8cec6ae0317a..591308a70ef4 100644 --- a/source/extensions/stat_sinks/statsd/config.h +++ b/source/extensions/stat_sinks/statsd/config.h @@ -21,7 +21,7 @@ class StatsdSinkFactory : Logger::Loggable, ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override; + std::string name() const override; }; } // namespace Statsd diff --git a/source/extensions/tracers/common/factory_base.h b/source/extensions/tracers/common/factory_base.h index 27e29853a885..7a6c3e0d1ad0 100644 --- a/source/extensions/tracers/common/factory_base.h +++ b/source/extensions/tracers/common/factory_base.h @@ -27,7 +27,7 @@ template class FactoryBase : public Server::Configuration::T return std::make_unique(); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: FactoryBase(const std::string& name) : name_(name) {} diff --git a/source/extensions/transport_sockets/alts/config.h b/source/extensions/transport_sockets/alts/config.h index e0d830224baa..adec81d3faec 100644 --- a/source/extensions/transport_sockets/alts/config.h +++ b/source/extensions/transport_sockets/alts/config.h @@ -14,7 +14,7 @@ class AltsTransportSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ProtobufTypes::MessagePtr createEmptyConfigProto() override; - const std::string name() const override { return TransportSocketNames::get().Alts; } + std::string name() const override { return TransportSocketNames::get().Alts; } }; class UpstreamAltsTransportSocketConfigFactory diff --git a/source/extensions/transport_sockets/raw_buffer/config.h b/source/extensions/transport_sockets/raw_buffer/config.h index a5e7cfe95ba7..a7c68d6875a7 100644 --- a/source/extensions/transport_sockets/raw_buffer/config.h +++ b/source/extensions/transport_sockets/raw_buffer/config.h @@ -17,7 +17,7 @@ namespace RawBuffer { class RawBufferSocketFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ~RawBufferSocketFactory() override = default; - const std::string name() const override { return TransportSocketNames::get().RawBuffer; } + std::string name() const override { return TransportSocketNames::get().RawBuffer; } ProtobufTypes::MessagePtr createEmptyConfigProto() override; }; diff --git a/source/extensions/transport_sockets/tap/config.h b/source/extensions/transport_sockets/tap/config.h index a5baa4408c60..8068779ada01 100644 --- a/source/extensions/transport_sockets/tap/config.h +++ b/source/extensions/transport_sockets/tap/config.h @@ -16,7 +16,7 @@ namespace Tap { class TapSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ~TapSocketConfigFactory() override = default; - const std::string name() const override { return TransportSocketNames::get().Tap; } + std::string name() const override { return TransportSocketNames::get().Tap; } ProtobufTypes::MessagePtr createEmptyConfigProto() override; }; diff --git a/source/extensions/transport_sockets/tls/config.h b/source/extensions/transport_sockets/tls/config.h index 25e3e90409e1..a10d597e09db 100644 --- a/source/extensions/transport_sockets/tls/config.h +++ b/source/extensions/transport_sockets/tls/config.h @@ -17,7 +17,7 @@ namespace Tls { class SslSocketConfigFactory : public virtual Server::Configuration::TransportSocketConfigFactory { public: ~SslSocketConfigFactory() override = default; - const std::string name() const override { return TransportSocketNames::get().Tls; } + std::string name() const override { return TransportSocketNames::get().Tls; } }; class UpstreamSslSocketFactory : public Server::Configuration::UpstreamTransportSocketConfigFactory, diff --git a/source/server/active_raw_udp_listener_config.cc b/source/server/active_raw_udp_listener_config.cc index 5cdace6cb2af..269b64450aa5 100644 --- a/source/server/active_raw_udp_listener_config.cc +++ b/source/server/active_raw_udp_listener_config.cc @@ -23,7 +23,7 @@ ActiveRawUdpListenerConfigFactory::createActiveUdpListenerFactory( return std::make_unique(); } -const std::string ActiveRawUdpListenerConfigFactory::name() const { +std::string ActiveRawUdpListenerConfigFactory::name() const { return UdpListenerNames::get().RawUdp; } diff --git a/source/server/active_raw_udp_listener_config.h b/source/server/active_raw_udp_listener_config.h index e040236cef58..337709bd29bb 100644 --- a/source/server/active_raw_udp_listener_config.h +++ b/source/server/active_raw_udp_listener_config.h @@ -26,7 +26,7 @@ class ActiveRawUdpListenerConfigFactory : public ActiveUdpListenerConfigFactory Network::ActiveUdpListenerFactoryPtr createActiveUdpListenerFactory(const Protobuf::Message&) override; - const std::string name() const override; + std::string name() const override; }; DECLARE_FACTORY(ActiveRawUdpListenerConfigFactory); diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 9fba33fb23fe..973245f49d1a 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -44,7 +44,7 @@ class StatsSinkFactory : public Config::TypedFactory { */ virtual Stats::SinkPtr createStatsSink(const Protobuf::Message& config, Instance& server) PURE; - const std::string category() const override { return "stats_sinks"; } + std::string category() const override { return "stats_sinks"; } }; /** diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index f4219811d662..f01186dda883 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -1243,7 +1243,7 @@ class TestHeaderFilterFactory : public ExtensionFilterFactory { return std::make_unique(); } - const std::string name() const override { return "test_header_filter"; } + std::string name() const override { return "test_header_filter"; } }; TEST_F(AccessLogImplTest, TestHeaderFilterPresence) { @@ -1319,7 +1319,7 @@ class SampleExtensionFilterFactory : public ExtensionFilterFactory { return std::make_unique(); } - const std::string name() const override { return "sample_extension_filter"; } + std::string name() const override { return "sample_extension_filter"; } }; TEST_F(AccessLogImplTest, SampleExtensionFilter) { diff --git a/test/common/config/metadata_test.cc b/test/common/config/metadata_test.cc index 548f5078f54a..c5d6bc9b3e81 100644 --- a/test/common/config/metadata_test.cc +++ b/test/common/config/metadata_test.cc @@ -62,7 +62,7 @@ class TypedMetadataTest : public testing::Test { class FooFactory : public TypedMetadataFactory { public: - const std::string name() const override { return "foo"; } + std::string name() const override { return "foo"; } // Throws EnvoyException (conversion failure) if d is empty. std::unique_ptr parse(const ProtobufWkt::Struct& d) const override { diff --git a/test/common/config/registry_test.cc b/test/common/config/registry_test.cc index dc4d9c4951df..287b3c49e20a 100644 --- a/test/common/config/registry_test.cc +++ b/test/common/config/registry_test.cc @@ -17,12 +17,12 @@ namespace { class InternalFactory : public Config::UntypedFactory { public: virtual ~InternalFactory() = default; - const std::string category() const override { return ""; } + std::string category() const override { return ""; } }; class TestInternalFactory : public InternalFactory { public: - const std::string name() const override { return "testing.internal.test"; } + std::string name() const override { return "testing.internal.test"; } }; static Registry::RegisterInternalFactory @@ -50,12 +50,12 @@ TEST(RegistryTest, InternalFactoryNotPublished) { class PublishedFactory : public Config::UntypedFactory { public: virtual ~PublishedFactory() = default; - const std::string category() const override { return "testing.published"; } + std::string category() const override { return "testing.published"; } }; class TestPublishedFactory : public PublishedFactory { public: - const std::string name() const override { return "testing.published.test"; } + std::string name() const override { return "testing.published.test"; } }; REGISTER_FACTORY(TestPublishedFactory, PublishedFactory); @@ -77,7 +77,7 @@ TEST(RegistryTest, DefaultFactoryPublished) { class TestWithDeprecatedPublishedFactory : public PublishedFactory { public: - const std::string name() const override { return "testing.published.instead_name"; } + std::string name() const override { return "testing.published.instead_name"; } }; REGISTER_FACTORY(TestWithDeprecatedPublishedFactory, diff --git a/test/common/network/resolver_impl_test.cc b/test/common/network/resolver_impl_test.cc index 61c3142f3aa8..f5fa8daf536a 100644 --- a/test/common/network/resolver_impl_test.cc +++ b/test/common/network/resolver_impl_test.cc @@ -96,7 +96,7 @@ class TestResolver : public Resolver { name_mappings_[logical] = physical; } - const std::string name() const override { return "envoy.test.resolver"; } + std::string name() const override { return "envoy.test.resolver"; } private: std::string getPhysicalName(const std::string& logical) { diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index 82d67b2dbfa8..a637a2df2624 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -4065,7 +4065,7 @@ struct Baz : public Envoy::Config::TypedMetadata::Object { }; class BazFactory : public HttpRouteTypedMetadataFactory { public: - const std::string name() const override { return "baz"; } + std::string name() const override { return "baz"; } // Returns nullptr (conversion failure) if d is empty. std::unique_ptr parse(const ProtobufWkt::Struct& d) const override { diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index 4cdbc59dcdb6..2d1d5e3f8cfa 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -2732,7 +2732,7 @@ class TestUpstreamNetworkFilterConfigFactory ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique(); } - const std::string name() const override { return "envoy.test.filter"; } + std::string name() const override { return "envoy.test.filter"; } }; // Verify that configured upstream filters are added to client connections. diff --git a/test/common/upstream/transport_socket_matcher_test.cc b/test/common/upstream/transport_socket_matcher_test.cc index 7d75cfcf8789..661a19e2d46b 100644 --- a/test/common/upstream/transport_socket_matcher_test.cc +++ b/test/common/upstream/transport_socket_matcher_test.cc @@ -64,7 +64,7 @@ class FooTransportSocketFactory return std::make_unique(); } - const std::string name() const override { return "foo"; } + std::string name() const override { return "foo"; } }; class TransportSocketMatcherTest : public testing::Test { diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index e25d251a438a..a9676fe169b6 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -1867,7 +1867,7 @@ struct Baz : public Envoy::Config::TypedMetadata::Object { class BazFactory : public ClusterTypedMetadataFactory { public: - const std::string name() const override { return "baz"; } + std::string name() const override { return "baz"; } // Returns nullptr (conversion failure) if d is empty. std::unique_ptr parse(const ProtobufWkt::Struct& d) const override { @@ -2133,10 +2133,8 @@ class TestNetworkFilterConfigFactory ProtobufMessage::ValidationVisitor&) override { return parent_.createProtocolOptionsConfig(msg); } - const std::string name() const override { - CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); - } - const std::string configType() override { return ""; }; + std::string name() const override { CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); } + std::string configType() override { return ""; }; TestFilterConfigFactoryBase& parent_; }; @@ -2170,10 +2168,8 @@ class TestHttpFilterConfigFactory : public Server::Configuration::NamedHttpFilte ProtobufMessage::ValidationVisitor&) override { return parent_.createProtocolOptionsConfig(msg); } - const std::string name() const override { - CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); - } - const std::string configType() override { return ""; }; + std::string name() const override { CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.filter"); } + std::string configType() override { return ""; }; TestFilterConfigFactoryBase& parent_; }; diff --git a/test/extensions/common/wasm/wasm_vm_test.cc b/test/extensions/common/wasm/wasm_vm_test.cc index 1584406c8909..853174bc7fe3 100644 --- a/test/extensions/common/wasm/wasm_vm_test.cc +++ b/test/extensions/common/wasm/wasm_vm_test.cc @@ -30,7 +30,7 @@ class PluginFactory : public Null::NullVmPluginFactory { public: PluginFactory() = default; - const std::string name() const override { return "test_null_vm_plugin"; } + std::string name() const override { return "test_null_vm_plugin"; } std::unique_ptr create() const override; }; diff --git a/test/extensions/filters/network/dubbo_proxy/mocks.h b/test/extensions/filters/network/dubbo_proxy/mocks.h index 77e2d3b41706..557b40f557da 100644 --- a/test/extensions/filters/network/dubbo_proxy/mocks.h +++ b/test/extensions/filters/network/dubbo_proxy/mocks.h @@ -125,7 +125,7 @@ class MockNamedSerializerConfigFactory : public NamedSerializerConfigFactory { MockNamedSerializerConfigFactory(std::function f) : f_(f) {} SerializerPtr createSerializer() override { return SerializerPtr{f_()}; } - const std::string name() const override { + std::string name() const override { return SerializerNames::get().fromType(SerializationType::Hessian2); } @@ -141,9 +141,7 @@ class MockNamedProtocolConfigFactory : public NamedProtocolConfigFactory { protocol->initSerializer(serialization_type); return protocol; } - const std::string name() const override { - return ProtocolNames::get().fromType(ProtocolType::Dubbo); - } + std::string name() const override { return ProtocolNames::get().fromType(ProtocolType::Dubbo); } std::function f_; }; @@ -289,7 +287,7 @@ template class MockFactoryBase : public NamedDubboFilterConf return std::make_unique(); } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } protected: MockFactoryBase(const std::string& name) : name_(name) {} diff --git a/test/extensions/filters/network/dubbo_proxy/router_test.cc b/test/extensions/filters/network/dubbo_proxy/router_test.cc index 23f0f208082a..13796ab9fead 100644 --- a/test/extensions/filters/network/dubbo_proxy/router_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/router_test.cc @@ -35,7 +35,7 @@ class TestNamedSerializerConfigFactory : public NamedSerializerConfigFactory { TestNamedSerializerConfigFactory(std::function f) : f_(f) {} SerializerPtr createSerializer() override { return SerializerPtr{f_()}; } - const std::string name() const override { + std::string name() const override { return SerializerNames::get().fromType(SerializationType::Hessian2); } @@ -51,9 +51,7 @@ class TestNamedProtocolConfigFactory : public NamedProtocolConfigFactory { protocol->initSerializer(serialization_type); return protocol; } - const std::string name() const override { - return ProtocolNames::get().fromType(ProtocolType::Dubbo); - } + std::string name() const override { return ProtocolNames::get().fromType(ProtocolType::Dubbo); } std::function f_; }; diff --git a/test/extensions/filters/network/thrift_proxy/router_test.cc b/test/extensions/filters/network/thrift_proxy/router_test.cc index 0fecc7a0e6b7..6a009055c1e5 100644 --- a/test/extensions/filters/network/thrift_proxy/router_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_test.cc @@ -42,7 +42,7 @@ class TestNamedTransportConfigFactory : public NamedTransportConfigFactory { TestNamedTransportConfigFactory(std::function f) : f_(f) {} TransportPtr createTransport() override { return TransportPtr{f_()}; } - const std::string name() const override { return TransportNames::get().FRAMED; } + std::string name() const override { return TransportNames::get().FRAMED; } std::function f_; }; @@ -52,7 +52,7 @@ class TestNamedProtocolConfigFactory : public NamedProtocolConfigFactory { TestNamedProtocolConfigFactory(std::function f) : f_(f) {} ProtocolPtr createProtocol() override { return ProtocolPtr{f_()}; } - const std::string name() const override { return ProtocolNames::get().BINARY; } + std::string name() const override { return ProtocolNames::get().BINARY; } std::function f_; }; diff --git a/test/extensions/transport_sockets/tls/test_private_key_method_provider.h b/test/extensions/transport_sockets/tls/test_private_key_method_provider.h index de608cde775e..4df6a3b08e8e 100644 --- a/test/extensions/transport_sockets/tls/test_private_key_method_provider.h +++ b/test/extensions/transport_sockets/tls/test_private_key_method_provider.h @@ -89,7 +89,7 @@ class TestPrivateKeyMethodFactory : public Ssl::PrivateKeyMethodProviderInstance return std::make_shared(config.typed_config(), factory_context); } - const std::string name() const override { return std::string("test"); }; + std::string name() const override { return "test"; }; }; } // namespace PrivateKeyMethodProvider diff --git a/test/integration/cluster_filter_integration_test.cc b/test/integration/cluster_filter_integration_test.cc index e00e7c582868..726f9073951c 100644 --- a/test/integration/cluster_filter_integration_test.cc +++ b/test/integration/cluster_filter_integration_test.cc @@ -70,7 +70,7 @@ class PoliteFilterConfigFactory return std::make_unique(); } - const std::string name() const override { return "envoy.upstream.polite"; } + std::string name() const override { return "envoy.upstream.polite"; } }; // perform static registration diff --git a/test/integration/filter_manager_integration_test.h b/test/integration/filter_manager_integration_test.h index d508ffe73ad3..e6966b85729e 100644 --- a/test/integration/filter_manager_integration_test.h +++ b/test/integration/filter_manager_integration_test.h @@ -256,7 +256,7 @@ class DispenserFilterConfigFactory : public Server::Configuration::NamedNetworkF return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { return name_; } + std::string name() const override { return name_; } private: const std::string name_; diff --git a/test/integration/tcp_conn_pool_integration_test.cc b/test/integration/tcp_conn_pool_integration_test.cc index d822914922de..3bf48355b00a 100644 --- a/test/integration/tcp_conn_pool_integration_test.cc +++ b/test/integration/tcp_conn_pool_integration_test.cc @@ -97,9 +97,7 @@ class TestFilterConfigFactory : public Server::Configuration::NamedNetworkFilter return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { - CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.router"); - } + std::string name() const override { CONSTRUCT_ON_FIRST_USE(std::string, "envoy.test.router"); } bool isTerminalFilter() override { return true; } }; diff --git a/test/integration/test_host_predicate_config.h b/test/integration/test_host_predicate_config.h index 786270f474a2..dc4bbf89802a 100644 --- a/test/integration/test_host_predicate_config.h +++ b/test/integration/test_host_predicate_config.h @@ -9,7 +9,7 @@ namespace Envoy { class TestHostPredicateFactory : public Upstream::RetryHostPredicateFactory { public: - const std::string name() const override { return "envoy.test_host_predicate"; } + std::string name() const override { return "envoy.test_host_predicate"; } Upstream::RetryHostPredicateSharedPtr createHostPredicate(const Protobuf::Message&, uint32_t) override { diff --git a/test/mocks/network/mocks.h b/test/mocks/network/mocks.h index 8ca0d83c8c1f..bc7b2f76ca1d 100644 --- a/test/mocks/network/mocks.h +++ b/test/mocks/network/mocks.h @@ -55,7 +55,7 @@ class MockAddressResolver : public Address::Resolver { MOCK_METHOD1(resolve, Address::InstanceConstSharedPtr(const envoy::api::v2::core::SocketAddress&)); - MOCK_CONST_METHOD0(name, const std::string()); + MOCK_CONST_METHOD0(name, std::string()); }; class MockReadFilterCallbacks : public ReadFilterCallbacks { diff --git a/test/mocks/upstream/mocks.h b/test/mocks/upstream/mocks.h index 1aa8307d3685..c0cf10bf1b7c 100644 --- a/test/mocks/upstream/mocks.h +++ b/test/mocks/upstream/mocks.h @@ -153,7 +153,7 @@ class MockRetryPriorityFactory : public RetryPriorityFactory { return std::make_shared>(retry_priority_); } - const std::string name() const override { return "envoy.test_retry_priority"; } + std::string name() const override { return "envoy.test_retry_priority"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } @@ -423,7 +423,7 @@ class TestRetryHostPredicateFactory : public RetryHostPredicateFactory { return std::make_shared>(); } - const std::string name() const override { return "envoy.test_host_predicate"; } + std::string name() const override { return "envoy.test_host_predicate"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index 4b500f1a6b8b..a009811cc8cf 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -339,7 +339,7 @@ class NonTerminalFilterFactory : public Configuration::NamedNetworkFilterConfigF return std::make_unique(); } - const std::string name() const override { return "non_terminal"; } + std::string name() const override { return "non_terminal"; } }; TEST_F(ListenerManagerImplWithRealFiltersTest, TerminalNotLast) { @@ -412,7 +412,7 @@ class TestStatsConfigFactory : public Configuration::NamedNetworkFilterConfigFac return std::make_unique(); } - const std::string name() const override { return "stats_test"; } + std::string name() const override { return "stats_test"; } bool isTerminalFilter() override { return true; } private: @@ -3157,7 +3157,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilter) { return std::make_unique(); } - const std::string name() const override { return "test.listener.original_dst"; } + std::string name() const override { return "test.listener.original_dst"; } }; /** @@ -3231,7 +3231,7 @@ TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilterIPv6) { return std::make_unique(); } - const std::string name() const override { return "test.listener.original_dstipv6"; } + std::string name() const override { return "test.listener.original_dstipv6"; } }; /** diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index eb192f723ec1..9594623ee2ed 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -454,23 +454,23 @@ TEST_F(OptionsImplPlatformLinuxTest, AffinityTest4) { class TestFactory : public Config::UntypedFactory { public: virtual ~TestFactory() = default; - const std::string category() const override { return "test"; } + std::string category() const override { return "test"; } }; class TestTestFactory : public TestFactory { public: - const std::string name() const override { return "test"; } + std::string name() const override { return "test"; } }; class TestingFactory : public Config::UntypedFactory { public: virtual ~TestingFactory() = default; - const std::string category() const override { return "testing"; } + std::string category() const override { return "testing"; } }; class TestTestingFactory : public TestingFactory { public: - const std::string name() const override { return "test"; } + std::string name() const override { return "test"; } }; REGISTER_FACTORY(TestTestFactory, TestFactory){"test-1", "test-2"}; diff --git a/test/server/server_test.cc b/test/server/server_test.cc index f94fd7d48057..3183f7b4360f 100644 --- a/test/server/server_test.cc +++ b/test/server/server_test.cc @@ -268,7 +268,7 @@ class CustomStatsSinkFactory : public Server::Configuration::StatsSinkFactory { return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { return "envoy.custom_stats_sink"; } + std::string name() const override { return "envoy.custom_stats_sink"; } }; INSTANTIATE_TEST_SUITE_P(IpVersions, ServerInstanceImplTest, @@ -993,7 +993,7 @@ class CallbacksStatsSinkFactory : public Server::Configuration::StatsSinkFactory return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Empty()}; } - const std::string name() const override { return "envoy.callbacks_stats_sink"; } + std::string name() const override { return "envoy.callbacks_stats_sink"; } }; REGISTER_FACTORY(CallbacksStatsSinkFactory, Server::Configuration::StatsSinkFactory); From b0e7ee5d6311c482adf8846efe145bd4f2c04b61 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Fri, 3 Jan 2020 21:11:23 -0800 Subject: [PATCH 09/12] update filter-example git SHA Signed-off-by: Kuat Yessenov --- ci/build_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index abf67e3c02d7..991a1e6d34a7 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -101,7 +101,7 @@ if [ "$1" != "-nofetch" ]; then fi # This is the hash on https://github.com/envoyproxy/envoy-filter-example.git we pin to. - (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f 03b45933284b332fd1df42cfb3270751fe543842) + (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f f5f70838351084ff5df992ef34719f08289945b8) sed -e "s|{ENVOY_SRCDIR}|${ENVOY_SRCDIR}|" "${ENVOY_SRCDIR}"/ci/WORKSPACE.filter.example > "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/WORKSPACE cp -f "${ENVOY_SRCDIR}"/.bazelversion "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/.bazelversion fi From ffb764ae2c5d35d8e624e3e12d61692be4c52934 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Fri, 3 Jan 2020 21:19:48 -0800 Subject: [PATCH 10/12] update filter-example git SHA Signed-off-by: Kuat Yessenov --- ci/build_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index 991a1e6d34a7..e4eaded26b84 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -101,7 +101,7 @@ if [ "$1" != "-nofetch" ]; then fi # This is the hash on https://github.com/envoyproxy/envoy-filter-example.git we pin to. - (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f f5f70838351084ff5df992ef34719f08289945b8) + (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f 5a05fb056a632a30b890ca85e69792558e90ffa9) sed -e "s|{ENVOY_SRCDIR}|${ENVOY_SRCDIR}|" "${ENVOY_SRCDIR}"/ci/WORKSPACE.filter.example > "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/WORKSPACE cp -f "${ENVOY_SRCDIR}"/.bazelversion "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/.bazelversion fi From afff1d59cc1b0c796fbcb9d83c3c332e07efb763 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Mon, 6 Jan 2020 10:42:36 -0800 Subject: [PATCH 11/12] fix format Signed-off-by: Kuat Yessenov --- include/envoy/grpc/google_grpc_creds.h | 2 +- include/envoy/ssl/private_key/private_key_config.h | 2 +- source/extensions/filters/network/dubbo_proxy/router/route.h | 2 +- source/extensions/filters/network/thrift_proxy/config.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/envoy/grpc/google_grpc_creds.h b/include/envoy/grpc/google_grpc_creds.h index 2ab5402d0fa0..e421bc5b4060 100644 --- a/include/envoy/grpc/google_grpc_creds.h +++ b/include/envoy/grpc/google_grpc_creds.h @@ -4,8 +4,8 @@ #include "envoy/api/api.h" #include "envoy/common/pure.h" -#include "envoy/config/typed_config.h" #include "envoy/config/core/v3alpha/grpc_service.pb.h" +#include "envoy/config/typed_config.h" #include "grpcpp/grpcpp.h" diff --git a/include/envoy/ssl/private_key/private_key_config.h b/include/envoy/ssl/private_key/private_key_config.h index 1ceb69ba535c..0024ecd81d72 100644 --- a/include/envoy/ssl/private_key/private_key_config.h +++ b/include/envoy/ssl/private_key/private_key_config.h @@ -1,7 +1,7 @@ #pragma once -#include "envoy/extensions/transport_sockets/tls/v3alpha/cert.pb.h" #include "envoy/config/typed_config.h" +#include "envoy/extensions/transport_sockets/tls/v3alpha/cert.pb.h" #include "envoy/registry/registry.h" #include "envoy/ssl/private_key/private_key.h" diff --git a/source/extensions/filters/network/dubbo_proxy/router/route.h b/source/extensions/filters/network/dubbo_proxy/router/route.h index da41b2025b12..590c26e3127a 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route.h @@ -3,8 +3,8 @@ #include #include -#include "envoy/extensions/filters/network/dubbo_proxy/v3alpha/route.pb.h" #include "envoy/config/typed_config.h" +#include "envoy/extensions/filters/network/dubbo_proxy/v3alpha/route.pb.h" #include "envoy/router/router.h" #include "envoy/server/filter_config.h" diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index dc3e91a2f253..bfd415d4b0d0 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -162,7 +162,7 @@ void ConfigImpl::processFilter( const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " thrift filter #{}", filter_factories_.size()); - ENVOY_LOG(debug, " name: {}", proto_config.name()); + ENVOY_LOG(debug, " name: {}", string_name); ENVOY_LOG( debug, " config: {}", MessageUtil::getJsonStringFromMessage(proto_config.hidden_envoy_deprecated_config(), true)); From 7406cef4310992dd80059a3a3fedeb44b9d89e5d Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Mon, 6 Jan 2020 12:34:06 -0800 Subject: [PATCH 12/12] try removing the symlink Signed-off-by: Kuat Yessenov --- ci/build_setup.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/build_setup.sh b/ci/build_setup.sh index e4eaded26b84..35bac42d1c92 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -103,7 +103,6 @@ if [ "$1" != "-nofetch" ]; then # This is the hash on https://github.com/envoyproxy/envoy-filter-example.git we pin to. (cd "${ENVOY_FILTER_EXAMPLE_SRCDIR}" && git fetch origin && git checkout -f 5a05fb056a632a30b890ca85e69792558e90ffa9) sed -e "s|{ENVOY_SRCDIR}|${ENVOY_SRCDIR}|" "${ENVOY_SRCDIR}"/ci/WORKSPACE.filter.example > "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/WORKSPACE - cp -f "${ENVOY_SRCDIR}"/.bazelversion "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/.bazelversion fi # Also setup some space for building Envoy standalone.