diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index d96767b619a88..ad82244b56703 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -130,6 +130,69 @@ def _go_deps(skip_targets): def _envoy_api_deps(): _repository_impl("envoy_api") + api_bind_targets = [ + "address", + "base", + "bootstrap", + "discovery", + "cds", + "discovery", + "eds", + "grpc_service", + "health_check", + "lds", + "metrics", + "protocol", + "rds", + "sds", + "stats", + "trace", + ] + for t in api_bind_targets: + native.bind( + name = "envoy_" + t, + actual = "@envoy_api//api:" + t + "_cc", + ) + filter_bind_targets = [ + "fault", + ] + for t in filter_bind_targets: + native.bind( + name = "envoy_filter_" + t, + actual = "@envoy_api//api/filter:" + t + "_cc", + ) + http_filter_bind_targets = [ + "buffer", + "fault", + "health_check", + "ip_tagging", + "lua", + "rate_limit", + "router", + "transcoder", + ] + for t in http_filter_bind_targets: + native.bind( + name = "envoy_filter_http_" + t, + actual = "@envoy_api//api/filter/http:" + t + "_cc", + ) + network_filter_bind_targets = [ + "http_connection_manager", + "tcp_proxy", + "mongo_proxy", + "redis_proxy", + "rate_limit", + "client_ssl_auth", + ] + for t in network_filter_bind_targets: + native.bind( + name = "envoy_filter_network_" + t, + actual = "@envoy_api//api/filter/network:" + t + "_cc", + ) + native.bind( + name = "envoy_filter_accesslog", + actual = "@envoy_api//api/filter/accesslog:accesslog_cc", + ) native.bind( name = "http_api_protos", actual = "@googleapis//:http_api_protos", diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 57ca924168760..9710cc4dd3617 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -71,7 +71,7 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://github.com/google/protobuf/archive/v3.5.0.tar.gz"], ), envoy_api = dict( - commit = "a66448b203e3a4f8ebbea0a5b7beede5c25640f6", + commit = "5aa0208c3bf0ba35833dc4ac16c73839b032e70a", remote = "https://github.com/envoyproxy/data-plane-api", ), grpc_httpjson_transcoding = dict( diff --git a/include/envoy/config/grpc_mux.h b/include/envoy/config/grpc_mux.h index bd5ccfc9a54a7..41008f18fa3e0 100644 --- a/include/envoy/config/grpc_mux.h +++ b/include/envoy/config/grpc_mux.h @@ -57,7 +57,7 @@ class GrpcMux { /** * Start a configuration subscription asynchronously for some API type and resources. * @param type_url type URL corresponding to xDS API, e.g. - * type.googleapis.com/envoy.api.v2.cluster.Cluster. + * type.googleapis.com/envoy.api.v2.Cluster. * @param resources vector of resource names to watch for. If this is empty, then all * resources for type_url will result in callbacks. * @param callbacks the callbacks to be notified of configuration updates. These must be valid @@ -74,7 +74,7 @@ class GrpcMux { * for LDS or CDS and don't want a flood of updates for RDS or EDS respectively. Discovery * requests may later be resumed with resume(). * @param type_url type URL corresponding to xDS API, e.g. - * type.googleapis.com/envoy.api.v2.cluster.Cluster. + * type.googleapis.com/envoy.api.v2.Cluster. */ virtual void pause(const std::string& type_url) PURE; @@ -82,7 +82,7 @@ class GrpcMux { * Resume discovery requests for a given API type. This will send a discovery request if one would * have been sent during the pause. * @param type_url type URL corresponding to xDS API, - * e.g.type.googleapis.com/envoy.api.v2.cluster.Cluster. + * e.g.type.googleapis.com/envoy.api.v2.Cluster. */ virtual void resume(const std::string& type_url) PURE; }; diff --git a/include/envoy/grpc/BUILD b/include/envoy/grpc/BUILD index 16921a15cdde1..477ec0049e918 100644 --- a/include/envoy/grpc/BUILD +++ b/include/envoy/grpc/BUILD @@ -23,10 +23,10 @@ envoy_cc_library( envoy_cc_library( name = "async_client_manager_interface", hdrs = ["async_client_manager.h"], + external_deps = ["envoy_grpc_service"], deps = [ ":async_client_interface", "//include/envoy/stats:stats_interface", - "@envoy_api//envoy/api/v2:grpc_service_cc", ], ) diff --git a/include/envoy/grpc/async_client_manager.h b/include/envoy/grpc/async_client_manager.h index 766405ada3a1c..8291a3cbbf53e 100644 --- a/include/envoy/grpc/async_client_manager.h +++ b/include/envoy/grpc/async_client_manager.h @@ -1,9 +1,10 @@ #pragma once -#include "envoy/api/v2/grpc_service.pb.h" #include "envoy/grpc/async_client.h" #include "envoy/stats/stats.h" +#include "api/grpc_service.pb.h" + namespace Envoy { namespace Grpc { diff --git a/include/envoy/local_info/BUILD b/include/envoy/local_info/BUILD index 217cfb6acca4c..108a0a06a56c6 100644 --- a/include/envoy/local_info/BUILD +++ b/include/envoy/local_info/BUILD @@ -11,8 +11,6 @@ envoy_package() envoy_cc_library( name = "local_info_interface", hdrs = ["local_info.h"], - deps = [ - "//include/envoy/network:address_interface", - "@envoy_api//envoy/api/v2:base_cc", - ], + external_deps = ["envoy_base"], + deps = ["//include/envoy/network:address_interface"], ) diff --git a/include/envoy/local_info/local_info.h b/include/envoy/local_info/local_info.h index f4beb8c08ef8b..4acefb52654a6 100644 --- a/include/envoy/local_info/local_info.h +++ b/include/envoy/local_info/local_info.h @@ -2,10 +2,11 @@ #include -#include "envoy/api/v2/base.pb.h" #include "envoy/common/pure.h" #include "envoy/network/address.h" +#include "api/base.pb.h" + namespace Envoy { namespace LocalInfo { diff --git a/include/envoy/network/resolver.h b/include/envoy/network/resolver.h index 1bc7dd92a94bf..b4c93bc145dcc 100644 --- a/include/envoy/network/resolver.h +++ b/include/envoy/network/resolver.h @@ -5,10 +5,11 @@ #include #include -#include "envoy/api/v2/address.pb.h" #include "envoy/common/pure.h" #include "envoy/network/address.h" +#include "api/address.pb.h" + namespace Envoy { namespace Network { namespace Address { diff --git a/include/envoy/router/BUILD b/include/envoy/router/BUILD index 102640b0a6184..db0e05cee1502 100644 --- a/include/envoy/router/BUILD +++ b/include/envoy/router/BUILD @@ -17,6 +17,7 @@ envoy_cc_library( envoy_cc_library( name = "route_config_provider_manager_interface", hdrs = ["route_config_provider_manager.h"], + external_deps = ["envoy_filter_network_http_connection_manager"], deps = [ ":rds_interface", "//include/envoy/event:dispatcher_interface", @@ -27,7 +28,6 @@ envoy_cc_library( "//include/envoy/stats:stats_interface", "//include/envoy/thread_local:thread_local_interface", "//include/envoy/upstream:cluster_manager_interface", - "@envoy_api//envoy/api/v2/filter/network:http_connection_manager_cc", ], ) diff --git a/include/envoy/router/route_config_provider_manager.h b/include/envoy/router/route_config_provider_manager.h index d9f17990898d7..32d9db045deac 100644 --- a/include/envoy/router/route_config_provider_manager.h +++ b/include/envoy/router/route_config_provider_manager.h @@ -2,7 +2,6 @@ #include -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" #include "envoy/event/dispatcher.h" #include "envoy/init/init.h" #include "envoy/json/json_object.h" @@ -13,6 +12,8 @@ #include "envoy/thread_local/thread_local.h" #include "envoy/upstream/cluster_manager.h" +#include "api/filter/network/http_connection_manager.pb.h" + namespace Envoy { namespace Router { diff --git a/include/envoy/router/router.h b/include/envoy/router/router.h index 63d19df1ee62d..bb030bc9481c7 100644 --- a/include/envoy/router/router.h +++ b/include/envoy/router/router.h @@ -9,7 +9,6 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/base.pb.h" #include "envoy/common/optional.h" #include "envoy/http/codec.h" #include "envoy/http/codes.h" @@ -20,6 +19,8 @@ #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" +#include "api/base.pb.h" + namespace Envoy { namespace Router { diff --git a/include/envoy/server/BUILD b/include/envoy/server/BUILD index b69ecf15b7082..0772aac42be72 100644 --- a/include/envoy/server/BUILD +++ b/include/envoy/server/BUILD @@ -110,6 +110,7 @@ envoy_cc_library( envoy_cc_library( name = "filter_config_interface", hdrs = ["filter_config.h"], + external_deps = ["envoy_base"], deps = [ ":admin_interface", "//include/envoy/access_log:access_log_interface", @@ -127,13 +128,13 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/common:macros", "//source/common/protobuf", - "@envoy_api//envoy/api/v2:base_cc", ], ) envoy_cc_library( name = "listener_manager_interface", hdrs = ["listener_manager.h"], + external_deps = ["envoy_lds"], deps = [ ":drain_manager_interface", ":filter_config_interface", @@ -142,7 +143,6 @@ envoy_cc_library( "//include/envoy/network:listen_socket_interface", "//include/envoy/ssl:context_interface", "//source/common/protobuf", - "@envoy_api//envoy/api/v2/listener:listener_cc", ], ) diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index c48d63774e368..b349788bdd23d 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -3,7 +3,6 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/base.pb.h" #include "envoy/http/filter.h" #include "envoy/init/init.h" #include "envoy/json/json_object.h" @@ -21,6 +20,8 @@ #include "common/common/macros.h" #include "common/protobuf/protobuf.h" +#include "api/base.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/include/envoy/server/listener_manager.h b/include/envoy/server/listener_manager.h index 17a6c4b1925e7..fccafe7ed2aed 100644 --- a/include/envoy/server/listener_manager.h +++ b/include/envoy/server/listener_manager.h @@ -1,6 +1,5 @@ #pragma once -#include "envoy/api/v2/listener/listener.pb.h" #include "envoy/network/filter.h" #include "envoy/network/listen_socket.h" #include "envoy/network/listener.h" @@ -10,6 +9,8 @@ #include "common/protobuf/protobuf.h" +#include "api/lds.pb.h" + namespace Envoy { namespace Server { @@ -35,9 +36,9 @@ class ListenerComponentFactory { * @param context supplies the factory creation context. * @return std::vector the list of filter factories. */ - virtual std::vector createNetworkFilterFactoryList( - const Protobuf::RepeatedPtrField& filters, - Configuration::FactoryContext& context) PURE; + virtual std::vector + createNetworkFilterFactoryList(const Protobuf::RepeatedPtrField& filters, + Configuration::FactoryContext& context) PURE; /** * Creates a list of listener filter factories. @@ -46,15 +47,14 @@ class ListenerComponentFactory { * @return std::vector the list of filter factories. */ virtual std::vector createListenerFilterFactoryList( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context) PURE; /** * @return DrainManagerPtr a new drain manager. * @param drain_type supplies the type of draining to do for the owning listener. */ - virtual DrainManagerPtr - createDrainManager(envoy::api::v2::listener::Listener::DrainType drain_type) PURE; + virtual DrainManagerPtr createDrainManager(envoy::api::v2::Listener::DrainType drain_type) PURE; /** * @return uint64_t a listener tag usable for connection handler tracking. @@ -84,8 +84,7 @@ class ListenerManager { * a duplicate of the existing listener. This routine will throw an EnvoyException if * there is a fundamental error preventing the listener from being added or updated. */ - virtual bool addOrUpdateListener(const envoy::api::v2::listener::Listener& config, - bool modifiable) PURE; + virtual bool addOrUpdateListener(const envoy::api::v2::Listener& config, bool modifiable) PURE; /** * @return std::vector> a list of the currently diff --git a/include/envoy/upstream/BUILD b/include/envoy/upstream/BUILD index 5172149d82dc7..b54670667038f 100644 --- a/include/envoy/upstream/BUILD +++ b/include/envoy/upstream/BUILD @@ -11,6 +11,10 @@ envoy_package() envoy_cc_library( name = "cluster_manager_interface", hdrs = ["cluster_manager.h"], + external_deps = [ + "envoy_bootstrap", + "envoy_cds", + ], deps = [ ":load_balancer_interface", ":thread_local_cluster_interface", @@ -22,8 +26,6 @@ envoy_cc_library( "//include/envoy/http:conn_pool_interface", "//include/envoy/local_info:local_info_interface", "//include/envoy/runtime:runtime_interface", - "@envoy_api//envoy/api/v2/cluster:cluster_cc", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) @@ -41,12 +43,12 @@ envoy_cc_library( envoy_cc_library( name = "host_description_interface", hdrs = ["host_description.h"], + external_deps = ["envoy_base"], deps = [ ":health_check_host_monitor_interface", ":outlier_detection_interface", "//include/envoy/network:address_interface", "//include/envoy/stats:stats_macros", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -62,9 +64,9 @@ envoy_cc_library( envoy_cc_library( name = "load_balancer_type_interface", hdrs = ["load_balancer_type.h"], + external_deps = ["envoy_cds"], deps = [ "//source/common/protobuf", - "@envoy_api//envoy/api/v2/cluster:cluster_cc", ], ) diff --git a/include/envoy/upstream/cluster_manager.h b/include/envoy/upstream/cluster_manager.h index 9d3c8c21b5cb7..8b73151201864 100644 --- a/include/envoy/upstream/cluster_manager.h +++ b/include/envoy/upstream/cluster_manager.h @@ -7,8 +7,6 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/cluster/cluster.pb.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/config/grpc_mux.h" #include "envoy/grpc/async_client_manager.h" #include "envoy/http/async_client.h" @@ -19,6 +17,9 @@ #include "envoy/upstream/thread_local_cluster.h" #include "envoy/upstream/upstream.h" +#include "api/bootstrap.pb.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { @@ -38,7 +39,7 @@ class ClusterManager { * * @return true if the action results in an add/update of a cluster. */ - virtual bool addOrUpdatePrimaryCluster(const envoy::api::v2::cluster::Cluster& cluster) PURE; + virtual bool addOrUpdatePrimaryCluster(const envoy::api::v2::Cluster& cluster) PURE; /** * Set a callback that will be invoked when all owned clusters have been initialized. @@ -192,11 +193,12 @@ class ClusterManagerFactory { /** * Allocate a cluster manager from configuration proto. */ - virtual ClusterManagerPtr - clusterManagerFromProto(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, - AccessLog::AccessLogManager& log_manager) PURE; + virtual ClusterManagerPtr clusterManagerFromProto(const envoy::api::v2::Bootstrap& bootstrap, + Stats::Store& stats, ThreadLocal::Instance& tls, + Runtime::Loader& runtime, + Runtime::RandomGenerator& random, + const LocalInfo::LocalInfo& local_info, + AccessLog::AccessLogManager& log_manager) PURE; /** * Allocate an HTTP connection pool. @@ -209,7 +211,7 @@ class ClusterManagerFactory { /** * Allocate a cluster from configuration proto. */ - virtual ClusterSharedPtr clusterFromProto(const envoy::api::v2::cluster::Cluster& cluster, + virtual ClusterSharedPtr clusterFromProto(const envoy::api::v2::Cluster& cluster, ClusterManager& cm, Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) PURE; diff --git a/include/envoy/upstream/host_description.h b/include/envoy/upstream/host_description.h index d4dab625f754d..4e37ccfdfbf9b 100644 --- a/include/envoy/upstream/host_description.h +++ b/include/envoy/upstream/host_description.h @@ -3,12 +3,13 @@ #include #include -#include "envoy/api/v2/base.pb.h" #include "envoy/network/address.h" #include "envoy/stats/stats_macros.h" #include "envoy/upstream/health_check_host_monitor.h" #include "envoy/upstream/outlier_detection.h" +#include "api/base.pb.h" + namespace Envoy { namespace Upstream { @@ -16,8 +17,8 @@ namespace Upstream { * All per host stats. @see stats_macros.h * * {rq_success, rq_error} have specific semantics driven by the needs of EDS load reporting. See - * envoy.api.v2.endpoint.UpstreamLocalityStats for the definitions of success/error. These are - * latched by LoadStatsReporter, independent of the normal stats sink flushing. + * envoy.api.v2.UpstreamLocalityStats for the definitions of success/error. These are latched by + * LoadStatsReporter, independent of the normal stats sink flushing. */ // clang-format off #define ALL_HOST_STATS(COUNTER, GAUGE) \ diff --git a/include/envoy/upstream/load_balancer_type.h b/include/envoy/upstream/load_balancer_type.h index 41e2976b04f2c..201ac13a3c699 100644 --- a/include/envoy/upstream/load_balancer_type.h +++ b/include/envoy/upstream/load_balancer_type.h @@ -4,10 +4,10 @@ #include #include -#include "envoy/api/v2/cluster/cluster.pb.h" - #include "common/protobuf/protobuf.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { @@ -32,7 +32,7 @@ class LoadBalancerSubsetInfo { * @return LbSubsetFallbackPolicy the fallback policy used when * route metadata does not match any subset. */ - virtual envoy::api::v2::cluster::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy + virtual envoy::api::v2::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy fallbackPolicy() const PURE; /** diff --git a/include/envoy/upstream/upstream.h b/include/envoy/upstream/upstream.h index bb52bdc7a2014..59ddae9ce419e 100644 --- a/include/envoy/upstream/upstream.h +++ b/include/envoy/upstream/upstream.h @@ -8,7 +8,6 @@ #include #include -#include "envoy/api/v2/base.pb.h" #include "envoy/common/callback.h" #include "envoy/common/optional.h" #include "envoy/http/codec.h" @@ -20,6 +19,8 @@ #include "envoy/upstream/outlier_detection.h" #include "envoy/upstream/resource_manager.h" +#include "api/base.pb.h" + namespace Envoy { namespace Upstream { @@ -294,8 +295,8 @@ class PrioritySet { /** * All cluster load report stats. These are only use for EDS load reporting and not sent to the - * stats sink. See envoy.api.v2.endpoint.ClusterStats for the definition of upstream_rq_dropped. - * These are latched by LoadStatsReporter, independent of the normal stats sink flushing. + * stats sink. See envoy.api.v2.ClusterStats for the definition of upstream_rq_dropped. These are + * latched by LoadStatsReporter, independent of the normal stats sink flushing. */ // clang-format off #define ALL_CLUSTER_LOAD_REPORT_STATS(COUNTER) \ @@ -366,13 +367,12 @@ class ClusterInfo { /** * @return the service discovery type to use for resolving the cluster. */ - virtual envoy::api::v2::cluster::Cluster::DiscoveryType type() const PURE; + virtual envoy::api::v2::Cluster::DiscoveryType type() const PURE; /** * @return configuration for ring hash load balancing, only used if type is set to ring_hash_lb. */ - virtual const Optional& - lbRingHashConfig() const PURE; + virtual const Optional& lbRingHashConfig() const PURE; /** * @return Whether the cluster is currently in maintenance mode and should not be routed to. diff --git a/source/common/access_log/BUILD b/source/common/access_log/BUILD index cf2b12f8bdc70..d116f7a441224 100644 --- a/source/common/access_log/BUILD +++ b/source/common/access_log/BUILD @@ -57,6 +57,7 @@ envoy_cc_library( name = "grpc_access_log_lib", srcs = ["grpc_access_log_impl.cc"], hdrs = ["grpc_access_log_impl.h"], + external_deps = ["envoy_filter_accesslog"], deps = [ "//include/envoy/access_log:access_log_interface", "//include/envoy/grpc:async_client_interface", @@ -65,8 +66,5 @@ envoy_cc_library( "//include/envoy/thread_local:thread_local_interface", "//include/envoy/upstream:cluster_manager_interface", "//source/common/grpc:async_client_lib", - "@envoy_api//envoy/api/v2/filter/accesslog:accesslog_cc", - "@envoy_api//envoy/config/accesslog/v2:als_cc", - "@envoy_api//envoy/service/accesslog/v2:als_cc", ], ) diff --git a/source/common/access_log/access_log_impl.h b/source/common/access_log/access_log_impl.h index 59e2fc138f32e..a9cbe4ccda265 100644 --- a/source/common/access_log/access_log_impl.h +++ b/source/common/access_log/access_log_impl.h @@ -5,13 +5,14 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/filter/accesslog/accesslog.pb.h" #include "envoy/request_info/request_info.h" #include "envoy/runtime/runtime.h" #include "envoy/server/access_log_config.h" #include "common/protobuf/protobuf.h" +#include "api/filter/accesslog/accesslog.pb.h" + namespace Envoy { namespace AccessLog { diff --git a/source/common/access_log/grpc_access_log_impl.cc b/source/common/access_log/grpc_access_log_impl.cc index 2487cdaa98a00..b747efaf5e766 100644 --- a/source/common/access_log/grpc_access_log_impl.cc +++ b/source/common/access_log/grpc_access_log_impl.cc @@ -32,7 +32,8 @@ GrpcAccessLogStreamerImpl::ThreadLocalStreamer::ThreadLocalStreamer( : client_(shared_state->factory_->create()), shared_state_(shared_state) {} void GrpcAccessLogStreamerImpl::ThreadLocalStreamer::send( - envoy::service::accesslog::v2::StreamAccessLogsMessage& message, const std::string& log_name) { + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage& message, + const std::string& log_name) { auto stream_it = stream_map_.find(log_name); if (stream_it == stream_map_.end()) { stream_it = stream_map_.emplace(log_name, ThreadLocalStream(*this, log_name)).first; @@ -42,7 +43,7 @@ void GrpcAccessLogStreamerImpl::ThreadLocalStreamer::send( if (stream_entry.stream_ == nullptr) { stream_entry.stream_ = client_->start(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.accesslog.v2.AccessLogService.StreamAccessLogs"), + "envoy.api.v2.filter.accesslog.AccessLogService.StreamAccessLogs"), stream_entry); auto* identifier = message.mutable_identifier(); @@ -59,7 +60,7 @@ void GrpcAccessLogStreamerImpl::ThreadLocalStreamer::send( } HttpGrpcAccessLog::HttpGrpcAccessLog( - FilterPtr&& filter, const envoy::config::accesslog::v2::HttpGrpcAccessLogConfig& config, + FilterPtr&& filter, const envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig& config, GrpcAccessLogStreamerSharedPtr grpc_access_log_streamer) : filter_(std::move(filter)), config_(config), grpc_access_log_streamer_(grpc_access_log_streamer) {} @@ -149,7 +150,7 @@ void HttpGrpcAccessLog::log(const Http::HeaderMap* request_headers, } } - envoy::service::accesslog::v2::StreamAccessLogsMessage message; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage message; auto* log_entry = message.mutable_http_logs()->add_log_entry(); // Common log properties. diff --git a/source/common/access_log/grpc_access_log_impl.h b/source/common/access_log/grpc_access_log_impl.h index 4c79b02d65e69..3d9d5ceac9469 100644 --- a/source/common/access_log/grpc_access_log_impl.h +++ b/source/common/access_log/grpc_access_log_impl.h @@ -3,15 +3,14 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/filter/accesslog/accesslog.pb.h" -#include "envoy/config/accesslog/v2/als.pb.h" #include "envoy/grpc/async_client.h" #include "envoy/grpc/async_client_manager.h" #include "envoy/local_info/local_info.h" -#include "envoy/service/accesslog/v2/als.pb.h" #include "envoy/singleton/instance.h" #include "envoy/thread_local/thread_local.h" +#include "api/filter/accesslog/accesslog.pb.h" + namespace Envoy { namespace AccessLog { @@ -30,7 +29,7 @@ class GrpcAccessLogStreamer { * @param message supplies the access log to send. * @param log_name supplies the name of the log stream to send on. */ - virtual void send(envoy::service::accesslog::v2::StreamAccessLogsMessage& message, + virtual void send(envoy::api::v2::filter::accesslog::StreamAccessLogsMessage& message, const std::string& log_name) PURE; }; @@ -46,7 +45,7 @@ class GrpcAccessLogStreamerImpl : public Singleton::Instance, public GrpcAccessL const LocalInfo::LocalInfo& local_info); // GrpcAccessLogStreamer - void send(envoy::service::accesslog::v2::StreamAccessLogsMessage& message, + void send(envoy::api::v2::filter::accesslog::StreamAccessLogsMessage& message, const std::string& log_name) override { tls_slot_->getTyped().send(message, log_name); } @@ -72,7 +71,7 @@ class GrpcAccessLogStreamerImpl : public Singleton::Instance, public GrpcAccessL * Per-thread stream state. */ struct ThreadLocalStream : public Grpc::TypedAsyncStreamCallbacks< - envoy::service::accesslog::v2::StreamAccessLogsResponse> { + envoy::api::v2::filter::accesslog::StreamAccessLogsResponse> { ThreadLocalStream(ThreadLocalStreamer& parent, const std::string& log_name) : parent_(parent), log_name_(log_name) {} @@ -80,7 +79,7 @@ class GrpcAccessLogStreamerImpl : public Singleton::Instance, public GrpcAccessL void onCreateInitialMetadata(Http::HeaderMap&) override {} void onReceiveInitialMetadata(Http::HeaderMapPtr&&) override {} void onReceiveMessage( - std::unique_ptr&&) override {} + std::unique_ptr&&) override {} void onReceiveTrailingMetadata(Http::HeaderMapPtr&&) override {} void onRemoteClose(Grpc::Status::GrpcStatus status, const std::string& message) override; @@ -94,7 +93,7 @@ class GrpcAccessLogStreamerImpl : public Singleton::Instance, public GrpcAccessL */ struct ThreadLocalStreamer : public ThreadLocal::ThreadLocalObject { ThreadLocalStreamer(const SharedStateSharedPtr& shared_state); - void send(envoy::service::accesslog::v2::StreamAccessLogsMessage& message, + void send(envoy::api::v2::filter::accesslog::StreamAccessLogsMessage& message, const std::string& log_name); Grpc::AsyncClientPtr client_; @@ -111,7 +110,7 @@ class GrpcAccessLogStreamerImpl : public Singleton::Instance, public GrpcAccessL class HttpGrpcAccessLog : public Instance { public: HttpGrpcAccessLog(FilterPtr&& filter, - const envoy::config::accesslog::v2::HttpGrpcAccessLogConfig& config, + const envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig& config, GrpcAccessLogStreamerSharedPtr grpc_access_log_streamer); static void addressToAccessLogAddress(envoy::api::v2::Address& proto_address, @@ -126,7 +125,7 @@ class HttpGrpcAccessLog : public Instance { private: FilterPtr filter_; - const envoy::config::accesslog::v2::HttpGrpcAccessLogConfig config_; + const envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig config_; GrpcAccessLogStreamerSharedPtr grpc_access_log_streamer_; }; diff --git a/source/common/config/BUILD b/source/common/config/BUILD index c6a6e5143f18e..0173cd4620849 100644 --- a/source/common/config/BUILD +++ b/source/common/config/BUILD @@ -12,12 +12,12 @@ envoy_cc_library( name = "address_json_lib", srcs = ["address_json.cc"], hdrs = ["address_json.h"], + external_deps = ["envoy_address"], deps = [ "//include/envoy/json:json_object_interface", "//source/common/common:assert_lib", "//source/common/network:cidr_range_lib", "//source/common/network:utility_lib", - "@envoy_api//envoy/api/v2:address_cc", ], ) @@ -25,6 +25,7 @@ envoy_cc_library( name = "bootstrap_json_lib", srcs = ["bootstrap_json.cc"], hdrs = ["bootstrap_json.h"], + external_deps = ["envoy_bootstrap"], deps = [ ":address_json_lib", ":cds_json_lib", @@ -36,7 +37,6 @@ envoy_cc_library( "//source/common/config:well_known_names", "//source/common/json:config_schemas_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) @@ -44,9 +44,9 @@ envoy_cc_library( name = "base_json_lib", srcs = ["base_json.cc"], hdrs = ["base_json.h"], + external_deps = ["envoy_base"], deps = [ "//include/envoy/json:json_object_interface", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -54,6 +54,7 @@ envoy_cc_library( name = "cds_json_lib", srcs = ["cds_json.cc"], hdrs = ["cds_json.h"], + external_deps = ["envoy_cds"], deps = [ ":address_json_lib", ":json_utility_lib", @@ -66,8 +67,6 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/json:config_schemas_lib", "//source/common/network:utility_lib", - "@envoy_api//envoy/api/v2/cluster:circuit_breaker_cc", - "@envoy_api//envoy/api/v2/cluster:cluster_cc", ], ) @@ -89,6 +88,21 @@ envoy_cc_library( name = "filter_json_lib", srcs = ["filter_json.cc"], hdrs = ["filter_json.h"], + external_deps = [ + "envoy_filter_network_http_connection_manager", + "envoy_filter_http_buffer", + "envoy_filter_http_lua", + "envoy_filter_http_fault", + "envoy_filter_http_health_check", + "envoy_filter_http_rate_limit", + "envoy_filter_http_transcoder", + "envoy_filter_http_router", + "envoy_filter_network_mongo_proxy", + "envoy_filter_network_redis_proxy", + "envoy_filter_network_tcp_proxy", + "envoy_filter_network_rate_limit", + "envoy_filter_network_client_ssl_auth", + ], deps = [ ":address_json_lib", ":json_utility_lib", @@ -102,19 +116,6 @@ envoy_cc_library( "//source/common/json:config_schemas_lib", "//source/common/protobuf", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2/filter/http:buffer_cc", - "@envoy_api//envoy/api/v2/filter/http:fault_cc", - "@envoy_api//envoy/api/v2/filter/http:health_check_cc", - "@envoy_api//envoy/api/v2/filter/http:lua_cc", - "@envoy_api//envoy/api/v2/filter/http:rate_limit_cc", - "@envoy_api//envoy/api/v2/filter/http:router_cc", - "@envoy_api//envoy/api/v2/filter/http:transcoder_cc", - "@envoy_api//envoy/api/v2/filter/network:client_ssl_auth_cc", - "@envoy_api//envoy/api/v2/filter/network:http_connection_manager_cc", - "@envoy_api//envoy/api/v2/filter/network:mongo_proxy_cc", - "@envoy_api//envoy/api/v2/filter/network:rate_limit_cc", - "@envoy_api//envoy/api/v2/filter/network:redis_proxy_cc", - "@envoy_api//envoy/api/v2/filter/network:tcp_proxy_cc", ], ) @@ -122,6 +123,7 @@ envoy_cc_library( name = "grpc_mux_lib", srcs = ["grpc_mux_impl.cc"], hdrs = ["grpc_mux_impl.h"], + external_deps = ["envoy_discovery"], deps = [ ":utility_lib", "//include/envoy/config:grpc_mux_interface", @@ -130,14 +132,13 @@ envoy_cc_library( "//include/envoy/upstream:cluster_manager_interface", "//source/common/common:logger_lib", "//source/common/protobuf", - "@envoy_api//envoy/service/discovery/v2:ads_cc", - "@envoy_api//envoy/service/discovery/v2:common_cc", ], ) envoy_cc_library( name = "grpc_mux_subscription_lib", hdrs = ["grpc_mux_subscription_impl.h"], + external_deps = ["envoy_discovery"], deps = [ "//include/envoy/config:grpc_mux_interface", "//include/envoy/config:subscription_interface", @@ -145,26 +146,29 @@ envoy_cc_library( "//source/common/common:logger_lib", "//source/common/grpc:common_lib", "//source/common/protobuf", - "@envoy_api//envoy/service/discovery/v2:common_cc", ], ) envoy_cc_library( name = "grpc_subscription_lib", hdrs = ["grpc_subscription_impl.h"], + external_deps = ["envoy_base"], deps = [ ":grpc_mux_lib", ":grpc_mux_subscription_lib", "//include/envoy/config:subscription_interface", "//include/envoy/event:dispatcher_interface", "//include/envoy/grpc:async_client_interface", - "@envoy_api//envoy/api/v2:base_cc", ], ) envoy_cc_library( name = "http_subscription_lib", hdrs = ["http_subscription_impl.h"], + external_deps = [ + "envoy_base", + "http_api_protos", + ], deps = [ "//include/envoy/config:subscription_interface", "//source/common/buffer:buffer_lib", @@ -174,8 +178,6 @@ envoy_cc_library( "//source/common/http:rest_api_fetcher_lib", "//source/common/protobuf", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2:base_cc", - "@googleapis//:http_api_protos", ], ) @@ -193,6 +195,7 @@ envoy_cc_library( name = "lds_json_lib", srcs = ["lds_json.cc"], hdrs = ["lds_json.h"], + external_deps = ["envoy_lds"], deps = [ ":address_json_lib", ":json_utility_lib", @@ -203,7 +206,6 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/json:config_schemas_lib", "//source/common/network:utility_lib", - "@envoy_api//envoy/service/discovery/v2:lds_cc", ], ) @@ -211,10 +213,10 @@ envoy_cc_library( name = "metadata_lib", srcs = ["metadata.cc"], hdrs = ["metadata.h"], + external_deps = ["envoy_base"], deps = [ "//source/common/protobuf", "//source/common/singleton:const_singleton", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -222,10 +224,10 @@ envoy_cc_library( name = "protocol_json_lib", srcs = ["protocol_json.cc"], hdrs = ["protocol_json.h"], + external_deps = ["envoy_protocol"], deps = [ ":json_utility_lib", "//include/envoy/json:json_object_interface", - "@envoy_api//envoy/api/v2:protocol_cc", ], ) @@ -239,6 +241,7 @@ envoy_cc_library( name = "rds_json_lib", srcs = ["rds_json.cc"], hdrs = ["rds_json.h"], + external_deps = ["envoy_rds"], deps = [ ":base_json_lib", ":json_utility_lib", @@ -248,13 +251,13 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/config:utility_lib", "//source/common/json:config_schemas_lib", - "@envoy_api//envoy/service/discovery/v2:rds_cc", ], ) envoy_cc_library( name = "subscription_factory_lib", hdrs = ["subscription_factory.h"], + external_deps = ["envoy_base"], deps = [ ":filesystem_subscription_lib", ":grpc_mux_subscription_lib", @@ -265,7 +268,6 @@ envoy_cc_library( "//include/envoy/upstream:cluster_manager_interface", "//source/common/filesystem:filesystem_lib", "//source/common/protobuf", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -273,11 +275,11 @@ envoy_cc_library( name = "tls_context_json_lib", srcs = ["tls_context_json.cc"], hdrs = ["tls_context_json.h"], + external_deps = ["envoy_sds"], deps = [ ":json_utility_lib", "//include/envoy/json:json_object_interface", "//source/common/common:utility_lib", - "@envoy_api//envoy/api/v2/auth:cert_cc", ], ) @@ -285,6 +287,14 @@ envoy_cc_library( name = "utility_lib", srcs = ["utility.cc"], hdrs = ["utility.h"], + external_deps = [ + "envoy_base", + "envoy_cds", + "envoy_eds", + "envoy_lds", + "envoy_rds", + "envoy_filter_network_http_connection_manager", + ], deps = [ ":json_utility_lib", ":resources_lib", @@ -304,12 +314,6 @@ envoy_cc_library( "//source/common/protobuf:utility_lib", "//source/common/singleton:const_singleton", "//source/common/stats:stats_lib", - "@envoy_api//envoy/api/v2:base_cc", - "@envoy_api//envoy/api/v2/filter/network:http_connection_manager_cc", - "@envoy_api//envoy/service/discovery/v2:cds_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", - "@envoy_api//envoy/service/discovery/v2:lds_cc", - "@envoy_api//envoy/service/discovery/v2:rds_cc", ], ) diff --git a/source/common/config/address_json.h b/source/common/config/address_json.h index c8659a6fe0b56..f79b4ee2411ad 100644 --- a/source/common/config/address_json.h +++ b/source/common/config/address_json.h @@ -1,10 +1,11 @@ #pragma once -#include "envoy/api/v2/address.pb.h" #include "envoy/json/json_object.h" #include "common/protobuf/protobuf.h" +#include "api/address.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/base_json.h b/source/common/config/base_json.h index f6c611c830c39..507bbea9a9a88 100644 --- a/source/common/config/base_json.h +++ b/source/common/config/base_json.h @@ -1,8 +1,9 @@ #pragma once -#include "envoy/api/v2/base.pb.h" #include "envoy/json/json_object.h" +#include "api/base.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/bootstrap_json.cc b/source/common/config/bootstrap_json.cc index 332a7b72e3c53..e06c4207391af 100644 --- a/source/common/config/bootstrap_json.cc +++ b/source/common/config/bootstrap_json.cc @@ -13,8 +13,8 @@ namespace Envoy { namespace Config { -void BootstrapJson::translateClusterManagerBootstrap( - const Json::Object& json_cluster_manager, envoy::config::bootstrap::v2::Bootstrap& bootstrap) { +void BootstrapJson::translateClusterManagerBootstrap(const Json::Object& json_cluster_manager, + envoy::api::v2::Bootstrap& bootstrap) { json_cluster_manager.validateSchema(Json::Schema::CLUSTER_MANAGER_SCHEMA); Optional eds_config; @@ -52,7 +52,7 @@ void BootstrapJson::translateClusterManagerBootstrap( } void BootstrapJson::translateBootstrap(const Json::Object& json_config, - envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + envoy::api::v2::Bootstrap& bootstrap) { json_config.validateSchema(Json::Schema::TOP_LEVEL_CONFIG_SCHEMA); translateClusterManagerBootstrap(*json_config.getObject("cluster_manager"), bootstrap); @@ -73,7 +73,7 @@ void BootstrapJson::translateBootstrap(const Json::Object& json_config, if (json_config.hasObject("statsd_udp_ip_address")) { auto* stats_sink = stats_sinks->Add(); stats_sink->set_name(Config::StatsSinkNames::get().STATSD); - envoy::config::metrics::v2::StatsdSink statsd_sink; + envoy::api::v2::StatsdSink statsd_sink; AddressJson::translateAddress(json_config.getString("statsd_udp_ip_address"), false, true, *statsd_sink.mutable_address()); MessageUtil::jsonConvert(statsd_sink, *stats_sink->mutable_config()); @@ -82,7 +82,7 @@ void BootstrapJson::translateBootstrap(const Json::Object& json_config, if (json_config.hasObject("statsd_tcp_cluster_name")) { auto* stats_sink = stats_sinks->Add(); stats_sink->set_name(Config::StatsSinkNames::get().STATSD); - envoy::config::metrics::v2::StatsdSink statsd_sink; + envoy::api::v2::StatsdSink statsd_sink; statsd_sink.set_tcp_cluster_name(json_config.getString("statsd_tcp_cluster_name")); MessageUtil::jsonConvert(statsd_sink, *stats_sink->mutable_config()); } diff --git a/source/common/config/bootstrap_json.h b/source/common/config/bootstrap_json.h index 80c567d7264ad..114f6c3a646ff 100644 --- a/source/common/config/bootstrap_json.h +++ b/source/common/config/bootstrap_json.h @@ -1,28 +1,29 @@ #pragma once -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/json/json_object.h" +#include "api/bootstrap.pb.h" + namespace Envoy { namespace Config { class BootstrapJson { public: /** - * Translate a v1 JSON cluster manager object to v2 envoy::config::bootstrap::v2::Bootstrap. + * Translate a v1 JSON cluster manager object to v2 envoy::api::v2::Bootstrap. * @param json_cluster_manager source v1 JSON cluster manager object. - * @param bootstrap destination v2 envoy::config::bootstrap::v2::Bootstrap. + * @param bootstrap destination v2 envoy::api::v2::Bootstrap. */ static void translateClusterManagerBootstrap(const Json::Object& json_cluster_manager, - envoy::config::bootstrap::v2::Bootstrap& bootstrap); + envoy::api::v2::Bootstrap& bootstrap); /** - * Translate a v1 JSON static config object to v2 envoy::config::bootstrap::v2::Bootstrap. + * Translate a v1 JSON static config object to v2 envoy::api::v2::Bootstrap. * @param json_config source v1 JSON static config object. - * @param bootstrap destination v2 envoy::config::bootstrap::v2::Bootstrap. + * @param bootstrap destination v2 envoy::api::v2::Bootstrap. */ static void translateBootstrap(const Json::Object& json_config, - envoy::config::bootstrap::v2::Bootstrap& bootstrap); + envoy::api::v2::Bootstrap& bootstrap); }; } // namespace Config diff --git a/source/common/config/cds_json.cc b/source/common/config/cds_json.cc index 803a1a31af978..a118a2d4448b0 100644 --- a/source/common/config/cds_json.cc +++ b/source/common/config/cds_json.cc @@ -13,7 +13,7 @@ namespace Config { void CdsJson::translateRingHashLbConfig( const Json::Object& json_ring_hash_lb_config, - envoy::api::v2::cluster::Cluster::RingHashLbConfig& ring_hash_lb_config) { + envoy::api::v2::Cluster::RingHashLbConfig& ring_hash_lb_config) { JSON_UTIL_SET_INTEGER(json_ring_hash_lb_config, ring_hash_lb_config, minimum_ring_size); JSON_UTIL_SET_BOOL(json_ring_hash_lb_config, *ring_hash_lb_config.mutable_deprecated_v1(), use_std_hash); @@ -57,9 +57,9 @@ void CdsJson::translateHealthCheck(const Json::Object& json_health_check, } } -void CdsJson::translateThresholds( - const Json::Object& json_thresholds, const envoy::api::v2::RoutingPriority& priority, - envoy::api::v2::cluster::CircuitBreakers::Thresholds& thresholds) { +void CdsJson::translateThresholds(const Json::Object& json_thresholds, + const envoy::api::v2::RoutingPriority& priority, + envoy::api::v2::CircuitBreakers::Thresholds& thresholds) { thresholds.set_priority(priority); JSON_UTIL_SET_INTEGER(json_thresholds, thresholds, max_connections); JSON_UTIL_SET_INTEGER(json_thresholds, thresholds, max_pending_requests); @@ -68,7 +68,7 @@ void CdsJson::translateThresholds( } void CdsJson::translateCircuitBreakers(const Json::Object& json_circuit_breakers, - envoy::api::v2::cluster::CircuitBreakers& circuit_breakers) { + envoy::api::v2::CircuitBreakers& circuit_breakers) { translateThresholds(*json_circuit_breakers.getObject("default", true), envoy::api::v2::RoutingPriority::DEFAULT, *circuit_breakers.mutable_thresholds()->Add()); @@ -79,7 +79,7 @@ void CdsJson::translateCircuitBreakers(const Json::Object& json_circuit_breakers void CdsJson::translateOutlierDetection( const Json::Object& json_outlier_detection, - envoy::api::v2::cluster::OutlierDetection& outlier_detection) { + envoy::api::v2::Cluster::OutlierDetection& outlier_detection) { JSON_UTIL_SET_DURATION(json_outlier_detection, outlier_detection, interval); JSON_UTIL_SET_DURATION(json_outlier_detection, outlier_detection, base_ejection_time); JSON_UTIL_SET_INTEGER(json_outlier_detection, outlier_detection, consecutive_5xx); @@ -96,7 +96,7 @@ void CdsJson::translateOutlierDetection( void CdsJson::translateCluster(const Json::Object& json_cluster, const Optional& eds_config, - envoy::api::v2::cluster::Cluster& cluster) { + envoy::api::v2::Cluster& cluster) { json_cluster.validateSchema(Json::Schema::CLUSTER_SCHEMA); const std::string name = json_cluster.getString("name"); @@ -115,7 +115,7 @@ void CdsJson::translateCluster(const Json::Object& json_cluster, }); }; if (string_type == "static") { - cluster.set_type(envoy::api::v2::cluster::Cluster::STATIC); + cluster.set_type(envoy::api::v2::Cluster::STATIC); const auto hosts = json_cluster.getObjectArray("hosts"); std::transform(hosts.cbegin(), hosts.cend(), Protobuf::RepeatedPtrFieldBackInserter(cluster.mutable_hosts()), @@ -125,19 +125,19 @@ void CdsJson::translateCluster(const Json::Object& json_cluster, return address; }); } else if (string_type == "strict_dns") { - cluster.set_type(envoy::api::v2::cluster::Cluster::STRICT_DNS); + cluster.set_type(envoy::api::v2::Cluster::STRICT_DNS); set_dns_hosts(); } else if (string_type == "logical_dns") { - cluster.set_type(envoy::api::v2::cluster::Cluster::LOGICAL_DNS); + cluster.set_type(envoy::api::v2::Cluster::LOGICAL_DNS); set_dns_hosts(); } else if (string_type == "original_dst") { if (json_cluster.hasObject("hosts")) { throw EnvoyException("original_dst clusters must have no hosts configured"); } - cluster.set_type(envoy::api::v2::cluster::Cluster::ORIGINAL_DST); + cluster.set_type(envoy::api::v2::Cluster::ORIGINAL_DST); } else { ASSERT(string_type == "sds"); - cluster.set_type(envoy::api::v2::cluster::Cluster::EDS); + cluster.set_type(envoy::api::v2::Cluster::EDS); cluster.mutable_eds_cluster_config()->mutable_eds_config()->CopyFrom(eds_config.value()); JSON_UTIL_SET_STRING(json_cluster, *cluster.mutable_eds_cluster_config(), service_name); } @@ -148,16 +148,16 @@ void CdsJson::translateCluster(const Json::Object& json_cluster, const std::string lb_type = json_cluster.getString("lb_type"); if (lb_type == "round_robin") { - cluster.set_lb_policy(envoy::api::v2::cluster::Cluster::ROUND_ROBIN); + cluster.set_lb_policy(envoy::api::v2::Cluster::ROUND_ROBIN); } else if (lb_type == "least_request") { - cluster.set_lb_policy(envoy::api::v2::cluster::Cluster::LEAST_REQUEST); + cluster.set_lb_policy(envoy::api::v2::Cluster::LEAST_REQUEST); } else if (lb_type == "random") { - cluster.set_lb_policy(envoy::api::v2::cluster::Cluster::RANDOM); + cluster.set_lb_policy(envoy::api::v2::Cluster::RANDOM); } else if (lb_type == "original_dst_lb") { - cluster.set_lb_policy(envoy::api::v2::cluster::Cluster::ORIGINAL_DST_LB); + cluster.set_lb_policy(envoy::api::v2::Cluster::ORIGINAL_DST_LB); } else { ASSERT(lb_type == "ring_hash"); - cluster.set_lb_policy(envoy::api::v2::cluster::Cluster::RING_HASH); + cluster.set_lb_policy(envoy::api::v2::Cluster::RING_HASH); } if (json_cluster.hasObject("ring_hash_lb_config")) { @@ -190,12 +190,12 @@ void CdsJson::translateCluster(const Json::Object& json_cluster, JSON_UTIL_SET_DURATION(json_cluster, cluster, dns_refresh_rate); const std::string dns_lookup_family = json_cluster.getString("dns_lookup_family", "v4_only"); if (dns_lookup_family == "auto") { - cluster.set_dns_lookup_family(envoy::api::v2::cluster::Cluster::AUTO); + cluster.set_dns_lookup_family(envoy::api::v2::Cluster::AUTO); } else if (dns_lookup_family == "v6_only") { - cluster.set_dns_lookup_family(envoy::api::v2::cluster::Cluster::V6_ONLY); + cluster.set_dns_lookup_family(envoy::api::v2::Cluster::V6_ONLY); } else { ASSERT(dns_lookup_family == "v4_only"); - cluster.set_dns_lookup_family(envoy::api::v2::cluster::Cluster::V4_ONLY); + cluster.set_dns_lookup_family(envoy::api::v2::Cluster::V4_ONLY); } if (json_cluster.hasObject("dns_resolvers")) { const auto dns_resolvers = json_cluster.getStringArray("dns_resolvers"); diff --git a/source/common/config/cds_json.h b/source/common/config/cds_json.h index 7c464eb47b8cf..448d6a501ac0f 100644 --- a/source/common/config/cds_json.h +++ b/source/common/config/cds_json.h @@ -1,24 +1,24 @@ #pragma once -#include "envoy/api/v2/cluster/circuit_breaker.pb.h" -#include "envoy/api/v2/cluster/cluster.pb.h" #include "envoy/common/optional.h" #include "envoy/json/json_object.h" #include "envoy/upstream/cluster_manager.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Config { class CdsJson { public: /** - * Translate a v1 JSON ring hash config to envoy::api::v2::cluster::Cluster::RingHashLbConfig. + * Translate a v1 JSON ring hash config to envoy::api::v2::Cluster::RingHashLbConfig. * @param json_ring_hash_lb_config source v1 JSON ring hash config object. - * @param ring_hash_lb_config destination v2 envoy::api::v2::cluster::Cluster::RingHashLbConfig. + * @param ring_hash_lb_config destination v2 envoy::api::v2::Cluster::RingHashLbConfig. */ - static void translateRingHashLbConfig( - const Json::Object& json_ring_hash_lb_config, - envoy::api::v2::cluster::Cluster::RingHashLbConfig& ring_hash_lb_config); + static void + translateRingHashLbConfig(const Json::Object& json_ring_hash_lb_config, + envoy::api::v2::Cluster::RingHashLbConfig& ring_hash_lb_config); /** * Translate a v1 JSON health check object to v2 envoy::api::v2::HealthCheck. @@ -36,15 +36,15 @@ class CdsJson { */ static void translateThresholds(const Json::Object& json_thresholds, const envoy::api::v2::RoutingPriority& priority, - envoy::api::v2::cluster::CircuitBreakers::Thresholds& thresholds); + envoy::api::v2::CircuitBreakers::Thresholds& thresholds); /** - * Translate a v1 JSON circuit breakers object to v2 envoy::api::v2::cluster::CircuitBreakers. + * Translate a v1 JSON circuit breakers object to v2 envoy::api::v2::CircuitBreakers. * @param json_circuit_breakers source v1 JSON circuit breakers object. - * @param circuit_breakers destination v2 envoy::api::v2::cluster::CircuitBreakers. + * @param circuit_breakers destination v2 envoy::api::v2::CircuitBreakers. */ static void translateCircuitBreakers(const Json::Object& json_circuit_breakers, - envoy::api::v2::cluster::CircuitBreakers& circuit_breakers); + envoy::api::v2::CircuitBreakers& circuit_breakers); /** * Translate a v1 JSON outlier detection object to v2 envoy::api::v2::OutlierDetection. @@ -53,17 +53,17 @@ class CdsJson { */ static void translateOutlierDetection(const Json::Object& json_outlier_detection, - envoy::api::v2::cluster::OutlierDetection& outlier_detection); + envoy::api::v2::Cluster::OutlierDetection& outlier_detection); /** - * Translate a v1 JSON Cluster to v2 envoy::api::v2::cluster::Cluster. + * Translate a v1 JSON Cluster to v2 envoy::api::v2::Cluster. * @param json_cluster source v1 JSON Cluster object. * @param eds_config SDS config if 'sds' discovery type. - * @param cluster destination v2 envoy::api::v2::cluster::Cluster. + * @param cluster destination v2 envoy::api::v2::Cluster. */ static void translateCluster(const Json::Object& json_cluster, const Optional& eds_config, - envoy::api::v2::cluster::Cluster& cluster); + envoy::api::v2::Cluster& cluster); }; } // namespace Config diff --git a/source/common/config/filesystem_subscription_impl.h b/source/common/config/filesystem_subscription_impl.h index 88801f0dfe4f3..1bf5bd22e8fd6 100644 --- a/source/common/config/filesystem_subscription_impl.h +++ b/source/common/config/filesystem_subscription_impl.h @@ -1,6 +1,5 @@ #pragma once -#include "envoy/api/v2/base.pb.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" #include "envoy/filesystem/filesystem.h" @@ -11,6 +10,8 @@ #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" +#include "api/base.pb.h" + namespace Envoy { namespace Config { @@ -56,7 +57,7 @@ class FilesystemSubscriptionImpl : public Config::Subscription, stats_.update_attempt_.inc(); bool config_update_available = false; try { - envoy::service::discovery::v2::DiscoveryResponse message; + envoy::api::v2::DiscoveryResponse message; MessageUtil::loadFromFile(path_, message); const auto typed_resources = Config::Utility::getTypedResources(message); config_update_available = true; diff --git a/source/common/config/filter_json.h b/source/common/config/filter_json.h index aca853baadf77..6775371d29c68 100644 --- a/source/common/config/filter_json.h +++ b/source/common/config/filter_json.h @@ -1,20 +1,21 @@ #pragma once -#include "envoy/api/v2/filter/http/buffer.pb.h" -#include "envoy/api/v2/filter/http/fault.pb.h" -#include "envoy/api/v2/filter/http/health_check.pb.h" -#include "envoy/api/v2/filter/http/lua.pb.h" -#include "envoy/api/v2/filter/http/rate_limit.pb.h" -#include "envoy/api/v2/filter/http/router.pb.h" -#include "envoy/api/v2/filter/http/transcoder.pb.h" -#include "envoy/api/v2/filter/network/client_ssl_auth.pb.h" -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" -#include "envoy/api/v2/filter/network/mongo_proxy.pb.h" -#include "envoy/api/v2/filter/network/rate_limit.pb.h" -#include "envoy/api/v2/filter/network/redis_proxy.pb.h" -#include "envoy/api/v2/filter/network/tcp_proxy.pb.h" #include "envoy/json/json_object.h" +#include "api/filter/http/buffer.pb.h" +#include "api/filter/http/fault.pb.h" +#include "api/filter/http/health_check.pb.h" +#include "api/filter/http/lua.pb.h" +#include "api/filter/http/rate_limit.pb.h" +#include "api/filter/http/router.pb.h" +#include "api/filter/http/transcoder.pb.h" +#include "api/filter/network/client_ssl_auth.pb.h" +#include "api/filter/network/http_connection_manager.pb.h" +#include "api/filter/network/mongo_proxy.pb.h" +#include "api/filter/network/rate_limit.pb.h" +#include "api/filter/network/redis_proxy.pb.h" +#include "api/filter/network/tcp_proxy.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/grpc_mux_impl.cc b/source/common/config/grpc_mux_impl.cc index ae9312c82075c..9549d67cf8edf 100644 --- a/source/common/config/grpc_mux_impl.cc +++ b/source/common/config/grpc_mux_impl.cc @@ -138,8 +138,7 @@ void GrpcMuxImpl::onReceiveInitialMetadata(Http::HeaderMapPtr&& metadata) { UNREFERENCED_PARAMETER(metadata); } -void GrpcMuxImpl::onReceiveMessage( - std::unique_ptr&& message) { +void GrpcMuxImpl::onReceiveMessage(std::unique_ptr&& message) { const std::string& type_url = message->type_url(); ENVOY_LOG(debug, "Received gRPC message for {} at version {}", type_url, message->version_info()); if (api_state_.count(type_url) == 0) { diff --git a/source/common/config/grpc_mux_impl.h b/source/common/config/grpc_mux_impl.h index dc65b205bc108..0f49244ba1aca 100644 --- a/source/common/config/grpc_mux_impl.h +++ b/source/common/config/grpc_mux_impl.h @@ -6,22 +6,21 @@ #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" #include "envoy/grpc/async_client.h" -#include "envoy/service/discovery/v2/ads.pb.h" -#include "envoy/service/discovery/v2/common.pb.h" #include "envoy/upstream/cluster_manager.h" #include "common/common/logger.h" +#include "api/discovery.pb.h" + namespace Envoy { namespace Config { /** * ADS API implementation that fetches via gRPC. */ -class GrpcMuxImpl - : public GrpcMux, - Grpc::TypedAsyncStreamCallbacks, - Logger::Loggable { +class GrpcMuxImpl : public GrpcMux, + Grpc::TypedAsyncStreamCallbacks, + Logger::Loggable { public: GrpcMuxImpl(const envoy::api::v2::Node& node, Grpc::AsyncClientPtr async_client, Event::Dispatcher& dispatcher, const Protobuf::MethodDescriptor& service_method); @@ -36,8 +35,7 @@ class GrpcMuxImpl // Grpc::AsyncStreamCallbacks void onCreateInitialMetadata(Http::HeaderMap& metadata) override; void onReceiveInitialMetadata(Http::HeaderMapPtr&& metadata) override; - void onReceiveMessage( - std::unique_ptr&& message) override; + void onReceiveMessage(std::unique_ptr&& message) override; void onReceiveTrailingMetadata(Http::HeaderMapPtr&& metadata) override; void onRemoteClose(Grpc::Status::GrpcStatus status, const std::string& message) override; @@ -79,7 +77,7 @@ class GrpcMuxImpl // Watches on the returned resources for the API; std::list watches_; // Current DiscoveryRequest for API. - envoy::service::discovery::v2::DiscoveryRequest request_; + envoy::api::v2::DiscoveryRequest request_; // Paused via pause()? bool paused_{}; // Was a DiscoveryRequest elided during a pause? diff --git a/source/common/config/grpc_mux_subscription_impl.h b/source/common/config/grpc_mux_subscription_impl.h index 9b33a7fbf40d1..caecccd9f5c6c 100644 --- a/source/common/config/grpc_mux_subscription_impl.h +++ b/source/common/config/grpc_mux_subscription_impl.h @@ -2,7 +2,6 @@ #include "envoy/config/grpc_mux.h" #include "envoy/config/subscription.h" -#include "envoy/service/discovery/v2/common.pb.h" #include "common/common/assert.h" #include "common/common/logger.h" @@ -10,6 +9,8 @@ #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" +#include "api/discovery.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/grpc_subscription_impl.h b/source/common/config/grpc_subscription_impl.h index b9c5d0ed2afe6..13ee5cc5e6ff2 100644 --- a/source/common/config/grpc_subscription_impl.h +++ b/source/common/config/grpc_subscription_impl.h @@ -1,6 +1,5 @@ #pragma once -#include "envoy/api/v2/base.pb.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" #include "envoy/grpc/async_client.h" @@ -8,6 +7,8 @@ #include "common/config/grpc_mux_impl.h" #include "common/config/grpc_mux_subscription_impl.h" +#include "api/base.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/http_subscription_impl.h b/source/common/config/http_subscription_impl.h index 86fc3bcb66c54..8da4312e05d0d 100644 --- a/source/common/config/http_subscription_impl.h +++ b/source/common/config/http_subscription_impl.h @@ -1,6 +1,5 @@ #pragma once -#include "envoy/api/v2/base.pb.h" #include "envoy/config/subscription.h" #include "common/buffer/buffer_impl.h" @@ -13,6 +12,7 @@ #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" +#include "api/base.pb.h" #include "google/api/annotations.pb.h" namespace Envoy { @@ -72,7 +72,7 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher, } void parseResponse(const Http::Message& response) override { - envoy::service::discovery::v2::DiscoveryResponse message; + envoy::api::v2::DiscoveryResponse message; const auto status = Protobuf::util::JsonStringToMessage(response.bodyAsString(), &message); if (!status.ok()) { ENVOY_LOG(warn, "REST config JSON conversion error: {}", status.ToString()); @@ -108,7 +108,7 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher, std::string path_; Protobuf::RepeatedPtrField resources_; Config::SubscriptionCallbacks* callbacks_{}; - envoy::service::discovery::v2::DiscoveryRequest request_; + envoy::api::v2::DiscoveryRequest request_; SubscriptionStats stats_; }; diff --git a/source/common/config/lds_json.cc b/source/common/config/lds_json.cc index 7ac721ecdaaa5..76860398bbeae 100644 --- a/source/common/config/lds_json.cc +++ b/source/common/config/lds_json.cc @@ -13,7 +13,7 @@ namespace Envoy { namespace Config { void LdsJson::translateListener(const Json::Object& json_listener, - envoy::api::v2::listener::Listener& listener) { + envoy::api::v2::Listener& listener) { json_listener.validateSchema(Json::Schema::LISTENER_SCHEMA); const std::string name = json_listener.getString("name", ""); @@ -48,7 +48,7 @@ void LdsJson::translateListener(const Json::Object& json_listener, const std::string drain_type = json_listener.getString("drain_type", "default"); if (drain_type == "modify_only") { - listener.set_drain_type(envoy::api::v2::listener::Listener_DrainType_MODIFY_ONLY); + listener.set_drain_type(envoy::api::v2::Listener_DrainType_MODIFY_ONLY); } else { ASSERT(drain_type == "default"); } diff --git a/source/common/config/lds_json.h b/source/common/config/lds_json.h index 175a6d77b9504..04716ce7c5f1d 100644 --- a/source/common/config/lds_json.h +++ b/source/common/config/lds_json.h @@ -1,20 +1,21 @@ #pragma once -#include "envoy/api/v2/listener/listener.pb.h" #include "envoy/json/json_object.h" +#include "api/lds.pb.h" + namespace Envoy { namespace Config { class LdsJson { public: /** - * Translate a v1 JSON Listener to v2 envoy::api::v2::listener::Listener. + * Translate a v1 JSON Listener to v2 envoy::api::v2::Listener. * @param json_listener source v1 JSON Listener object. - * @param listener destination v2 envoy::api::v2::listener::Listener. + * @param listener destination v2 envoy::api::v2::Listener. */ static void translateListener(const Json::Object& json_listener, - envoy::api::v2::listener::Listener& listener); + envoy::api::v2::Listener& listener); }; } // namespace Config diff --git a/source/common/config/metadata.h b/source/common/config/metadata.h index d9140526f5567..b77ffb7f2cc71 100644 --- a/source/common/config/metadata.h +++ b/source/common/config/metadata.h @@ -2,11 +2,11 @@ #include -#include "envoy/api/v2/base.pb.h" - #include "common/protobuf/protobuf.h" #include "common/singleton/const_singleton.h" +#include "api/base.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/protocol_json.h b/source/common/config/protocol_json.h index 39d61d5104a2a..83b69fb2a81d6 100644 --- a/source/common/config/protocol_json.h +++ b/source/common/config/protocol_json.h @@ -1,8 +1,9 @@ #pragma once -#include "envoy/api/v2/protocol.pb.h" #include "envoy/json/json_object.h" +#include "api/protocol.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/rds_json.cc b/source/common/config/rds_json.cc index 9c35bf9525a04..eeb45e000b5df 100644 --- a/source/common/config/rds_json.cc +++ b/source/common/config/rds_json.cc @@ -13,13 +13,13 @@ namespace Envoy { namespace Config { void RdsJson::translateWeightedCluster(const Json::Object& json_weighted_clusters, - envoy::api::v2::route::WeightedCluster& weighted_cluster) { + envoy::api::v2::WeightedCluster& weighted_cluster) { JSON_UTIL_SET_STRING(json_weighted_clusters, weighted_cluster, runtime_key_prefix); const auto clusters = json_weighted_clusters.getObjectArray("clusters"); std::transform(clusters.cbegin(), clusters.cend(), Protobuf::RepeatedPtrFieldBackInserter(weighted_cluster.mutable_clusters()), [](const Json::ObjectSharedPtr& json_cluster_weight) { - envoy::api::v2::route::WeightedCluster::ClusterWeight cluster_weight; + envoy::api::v2::WeightedCluster::ClusterWeight cluster_weight; JSON_UTIL_SET_STRING(*json_cluster_weight, cluster_weight, name); JSON_UTIL_SET_INTEGER(*json_cluster_weight, cluster_weight, weight); return cluster_weight; @@ -27,7 +27,7 @@ void RdsJson::translateWeightedCluster(const Json::Object& json_weighted_cluster } void RdsJson::translateVirtualCluster(const Json::Object& json_virtual_cluster, - envoy::api::v2::route::VirtualCluster& virtual_cluster) { + envoy::api::v2::VirtualCluster& virtual_cluster) { JSON_UTIL_SET_STRING(json_virtual_cluster, virtual_cluster, name); JSON_UTIL_SET_STRING(json_virtual_cluster, virtual_cluster, pattern); @@ -36,8 +36,7 @@ void RdsJson::translateVirtualCluster(const Json::Object& json_virtual_cluster, virtual_cluster.set_method(method); } -void RdsJson::translateCors(const Json::Object& json_cors, - envoy::api::v2::route::CorsPolicy& cors) { +void RdsJson::translateCors(const Json::Object& json_cors, envoy::api::v2::CorsPolicy& cors) { for (const std::string& origin : json_cors.getStringArray("allow_origin", true)) { cors.add_allow_origin(origin); } @@ -50,7 +49,7 @@ void RdsJson::translateCors(const Json::Object& json_cors, } void RdsJson::translateRateLimit(const Json::Object& json_rate_limit, - envoy::api::v2::route::RateLimit& rate_limit) { + envoy::api::v2::RateLimit& rate_limit) { json_rate_limit.validateSchema(Json::Schema::HTTP_RATE_LIMITS_CONFIGURATION_SCHEMA); JSON_UTIL_SET_INTEGER(json_rate_limit, rate_limit, stage); JSON_UTIL_SET_STRING(json_rate_limit, rate_limit, disable_key); @@ -80,7 +79,7 @@ void RdsJson::translateRateLimit(const Json::Object& json_rate_limit, std::transform(headers.cbegin(), headers.cend(), Protobuf::RepeatedPtrFieldBackInserter(header_value_match->mutable_headers()), [](const Json::ObjectSharedPtr& json_header_matcher) { - envoy::api::v2::route::HeaderMatcher header_matcher; + envoy::api::v2::HeaderMatcher header_matcher; translateHeaderMatcher(*json_header_matcher, header_matcher); return header_matcher; }); @@ -89,7 +88,7 @@ void RdsJson::translateRateLimit(const Json::Object& json_rate_limit, } void RdsJson::translateHeaderMatcher(const Json::Object& json_header_matcher, - envoy::api::v2::route::HeaderMatcher& header_matcher) { + envoy::api::v2::HeaderMatcher& header_matcher) { json_header_matcher.validateSchema(Json::Schema::HEADER_DATA_CONFIGURATION_SCHEMA); JSON_UTIL_SET_STRING(json_header_matcher, header_matcher, name); JSON_UTIL_SET_STRING(json_header_matcher, header_matcher, value); @@ -98,7 +97,7 @@ void RdsJson::translateHeaderMatcher(const Json::Object& json_header_matcher, void RdsJson::translateQueryParameterMatcher( const Json::Object& json_query_parameter_matcher, - envoy::api::v2::route::QueryParameterMatcher& query_parameter_matcher) { + envoy::api::v2::QueryParameterMatcher& query_parameter_matcher) { json_query_parameter_matcher.validateSchema(Json::Schema::QUERY_PARAMETER_CONFIGURATION_SCHEMA); JSON_UTIL_SET_STRING(json_query_parameter_matcher, query_parameter_matcher, name); JSON_UTIL_SET_STRING(json_query_parameter_matcher, query_parameter_matcher, value); @@ -106,7 +105,7 @@ void RdsJson::translateQueryParameterMatcher( } void RdsJson::translateRouteConfiguration(const Json::Object& json_route_config, - envoy::api::v2::route::RouteConfiguration& route_config) { + envoy::api::v2::RouteConfiguration& route_config) { json_route_config.validateSchema(Json::Schema::ROUTE_CONFIGURATION_SCHEMA); for (const auto json_virtual_host : json_route_config.getObjectArray("virtual_hosts", true)) { @@ -139,7 +138,7 @@ void RdsJson::translateRouteConfiguration(const Json::Object& json_route_config, } void RdsJson::translateVirtualHost(const Json::Object& json_virtual_host, - envoy::api::v2::route::VirtualHost& virtual_host) { + envoy::api::v2::VirtualHost& virtual_host) { json_virtual_host.validateSchema(Json::Schema::VIRTUAL_HOST_CONFIGURATION_SCHEMA); const std::string name = json_virtual_host.getString("name", ""); @@ -155,8 +154,8 @@ void RdsJson::translateVirtualHost(const Json::Object& json_virtual_host, translateRoute(*json_route, *route); } - envoy::api::v2::route::VirtualHost::TlsRequirementType tls_requirement{}; - envoy::api::v2::route::VirtualHost::TlsRequirementType_Parse( + envoy::api::v2::VirtualHost::TlsRequirementType tls_requirement{}; + envoy::api::v2::VirtualHost::TlsRequirementType_Parse( StringUtil::toUpper(json_virtual_host.getString("require_ssl", "")), &tls_requirement); virtual_host.set_require_tls(tls_requirement); @@ -184,13 +183,13 @@ void RdsJson::translateVirtualHost(const Json::Object& json_virtual_host, } void RdsJson::translateDecorator(const Json::Object& json_decorator, - envoy::api::v2::route::Decorator& decorator) { + envoy::api::v2::Decorator& decorator) { if (json_decorator.hasObject("operation")) { decorator.set_operation(json_decorator.getString("operation")); } } -void RdsJson::translateRoute(const Json::Object& json_route, envoy::api::v2::route::Route& route) { +void RdsJson::translateRoute(const Json::Object& json_route, envoy::api::v2::Route& route) { json_route.validateSchema(Json::Schema::ROUTE_ENTRY_CONFIGURATION_SCHEMA); auto* match = route.mutable_match(); diff --git a/source/common/config/rds_json.h b/source/common/config/rds_json.h index e1ce8c0bd16db..60ba7f6d98de3 100644 --- a/source/common/config/rds_json.h +++ b/source/common/config/rds_json.h @@ -1,92 +1,92 @@ #pragma once -#include "envoy/api/v2/route/route.pb.h" #include "envoy/json/json_object.h" +#include "api/rds.pb.h" + namespace Envoy { namespace Config { class RdsJson { public: /** - * Translate a v1 JSON weighted clusters object to v2 envoy::api::v2::route::WeightedCluster. + * Translate a v1 JSON weighted clusters object to v2 envoy::api::v2::WeightedCluster. * @param json_weighted_clusters source v1 JSON weighted clusters object. - * @param weighted_cluster destination v2 envoy::api::v2::route::WeightedCluster. + * @param weighted_cluster destination v2 envoy::api::v2::WeightedCluster. */ static void translateWeightedCluster(const Json::Object& json_weighted_clusters, - envoy::api::v2::route::WeightedCluster& weighted_cluster); + envoy::api::v2::WeightedCluster& weighted_cluster); /** - * Translate a v1 JSON virtual cluster object to v2 envoy::api::v2::route::VirtualCluster. + * Translate a v1 JSON virtual cluster object to v2 envoy::api::v2::VirtualCluster. * @param json_virtual_cluster source v1 JSON virtual cluster object. - * @param virtual_cluster destination v2 envoy::api::v2::route::VirtualCluster. + * @param virtual_cluster destination v2 envoy::api::v2::VirtualCluster. */ static void translateVirtualCluster(const Json::Object& json_virtual_cluster, - envoy::api::v2::route::VirtualCluster& virtual_cluster); + envoy::api::v2::VirtualCluster& virtual_cluster); /** - * Translate a v1 JSON cors object to v2 envoy::api::v2::route::CorsPolicy. + * Translate a v1 JSON cors object to v2 envoy::api::v2::CorsPolicy. * @param json_cors source v1 JSON cors object. - * @param cors destination v2 envoy::api::v2::route::CorsPolicy. + * @param cors destination v2 envoy::api::v2::CorsPolicy. */ - static void translateCors(const Json::Object& json_cors, envoy::api::v2::route::CorsPolicy& cors); + static void translateCors(const Json::Object& json_cors, envoy::api::v2::CorsPolicy& cors); /** - * Translate a v1 JSON rate limit object to v2 envoy::api::v2::route::RateLimit. + * Translate a v1 JSON rate limit object to v2 envoy::api::v2::RateLimit. * @param json_rate_limit source v1 JSON rate limit object. - * @param rate_limit destination v2 envoy::api::v2::route::RateLimit. + * @param rate_limit destination v2 envoy::api::v2::RateLimit. */ static void translateRateLimit(const Json::Object& json_rate_limit, - envoy::api::v2::route::RateLimit& rate_limit); + envoy::api::v2::RateLimit& rate_limit); /** - * Translate a v1 JSON header matcher object to v2 envoy::api::v2::route::HeaderMatcher. + * Translate a v1 JSON header matcher object to v2 envoy::api::v2::HeaderMatcher. * @param json_header_matcher source v1 JSON header matcher object. - * @param header_matcher destination v2 envoy::api::v2::route::HeaderMatcher. + * @param header_matcher destination v2 envoy::api::v2::HeaderMatcher. */ static void translateHeaderMatcher(const Json::Object& json_header_matcher, - envoy::api::v2::route::HeaderMatcher& header_matcher); + envoy::api::v2::HeaderMatcher& header_matcher); /** - * Translate a v1 JSON query parameter matcher object to v2 - * envoy::api::v2::route::QueryParameterMatcher. + * Translate a v1 JSON query parameter matcher object to v2 envoy::api::v2::QueryParameterMatcher. * @param json_query_parameter_matcher source v1 JSON query parameter matcher object. - * @param query_parameter_matcher destination v2 envoy::api::v2::route::QueryParameterMatcher. + * @param query_parameter_matcher destination v2 envoy::api::v2::QueryParameterMatcher. */ - static void translateQueryParameterMatcher( - const Json::Object& json_query_parameter_matcher, - envoy::api::v2::route::QueryParameterMatcher& query_parameter_matcher); + static void + translateQueryParameterMatcher(const Json::Object& json_query_parameter_matcher, + envoy::api::v2::QueryParameterMatcher& query_parameter_matcher); /** - * Translate a v1 JSON route configuration object to v2 envoy::api::v2::route::RouteConfiguration. + * Translate a v1 JSON route configuration object to v2 envoy::api::v2::RouteConfiguration. * @param json_route_config source v1 JSON route configuration object. - * @param route_config destination v2 envoy::api::v2::route::RouteConfiguration. + * @param route_config destination v2 envoy::api::v2::RouteConfiguration. */ static void translateRouteConfiguration(const Json::Object& json_route_config, - envoy::api::v2::route::RouteConfiguration& route_config); + envoy::api::v2::RouteConfiguration& route_config); /** - * Translate a v1 JSON virtual host object to v2 envoy::api::v2::route::VirtualHost. + * Translate a v1 JSON virtual host object to v2 envoy::api::v2::VirtualHost. * @param json_virtual_host source v1 JSON virtual host object. - * @param virtual_host destination v2 envoy::api::v2::route::VirtualHost. + * @param virtual_host destination v2 envoy::api::v2::VirtualHost. */ static void translateVirtualHost(const Json::Object& json_virtual_host, - envoy::api::v2::route::VirtualHost& virtual_host); + envoy::api::v2::VirtualHost& virtual_host); /** - * Translate a v1 JSON decorator object to v2 envoy::api::v2::route::Decorator. + * Translate a v1 JSON decorator object to v2 envoy::api::v2::Decorator. * @param json_decorator source v1 JSON decorator object. - * @param decorator destination v2 envoy::api::v2::route::Decorator. + * @param decorator destination v2 envoy::api::v2::Decorator. */ static void translateDecorator(const Json::Object& json_decorator, - envoy::api::v2::route::Decorator& decorator); + envoy::api::v2::Decorator& decorator); /** - * Translate a v1 JSON route object to v2 envoy::api::v2::route::Route. + * Translate a v1 JSON route object to v2 envoy::api::v2::Route. * @param json_route source v1 JSON route object. - * @param route destination v2 envoy::api::v2::route::Route. + * @param route destination v2 envoy::api::v2::Route. */ - static void translateRoute(const Json::Object& json_route, envoy::api::v2::route::Route& route); + static void translateRoute(const Json::Object& json_route, envoy::api::v2::Route& route); }; } // namespace Config diff --git a/source/common/config/resources.h b/source/common/config/resources.h index 1be067191bc01..03f0c9a2efd8b 100644 --- a/source/common/config/resources.h +++ b/source/common/config/resources.h @@ -12,11 +12,10 @@ namespace Config { */ class TypeUrlValues { public: - const std::string Listener{"type.googleapis.com/envoy.api.v2.listener.Listener"}; - const std::string Cluster{"type.googleapis.com/envoy.api.v2.cluster.Cluster"}; - const std::string ClusterLoadAssignment{ - "type.googleapis.com/envoy.service.discovery.v2.ClusterLoadAssignment"}; - const std::string RouteConfiguration{"type.googleapis.com/envoy.api.v2.route.RouteConfiguration"}; + const std::string Listener{"type.googleapis.com/envoy.api.v2.Listener"}; + const std::string Cluster{"type.googleapis.com/envoy.api.v2.Cluster"}; + const std::string ClusterLoadAssignment{"type.googleapis.com/envoy.api.v2.ClusterLoadAssignment"}; + const std::string RouteConfiguration{"type.googleapis.com/envoy.api.v2.RouteConfiguration"}; }; typedef ConstSingleton TypeUrl; diff --git a/source/common/config/subscription_factory.h b/source/common/config/subscription_factory.h index a376f1e13cea8..7b7d2d05cd916 100644 --- a/source/common/config/subscription_factory.h +++ b/source/common/config/subscription_factory.h @@ -2,7 +2,6 @@ #include -#include "envoy/api/v2/base.pb.h" #include "envoy/config/subscription.h" #include "envoy/upstream/cluster_manager.h" @@ -14,6 +13,8 @@ #include "common/filesystem/filesystem_impl.h" #include "common/protobuf/protobuf.h" +#include "api/base.pb.h" + namespace Envoy { namespace Config { diff --git a/source/common/config/tls_context_json.cc b/source/common/config/tls_context_json.cc index ac64997e74f55..1c106056a93cc 100644 --- a/source/common/config/tls_context_json.cc +++ b/source/common/config/tls_context_json.cc @@ -1,17 +1,17 @@ #include "common/config/tls_context_json.h" -#include "envoy/api/v2/auth/cert.pb.validate.h" - #include "common/common/utility.h" #include "common/config/json_utility.h" #include "common/protobuf/utility.h" +#include "api/sds.pb.validate.h" + namespace Envoy { namespace Config { void TlsContextJson::translateDownstreamTlsContext( const Json::Object& json_tls_context, - envoy::api::v2::auth::DownstreamTlsContext& downstream_tls_context) { + envoy::api::v2::DownstreamTlsContext& downstream_tls_context) { translateCommonTlsContext(json_tls_context, *downstream_tls_context.mutable_common_tls_context()); JSON_UTIL_SET_BOOL(json_tls_context, downstream_tls_context, require_client_certificate); @@ -25,15 +25,14 @@ void TlsContextJson::translateDownstreamTlsContext( void TlsContextJson::translateUpstreamTlsContext( const Json::Object& json_tls_context, - envoy::api::v2::auth::UpstreamTlsContext& upstream_tls_context) { + envoy::api::v2::UpstreamTlsContext& upstream_tls_context) { translateCommonTlsContext(json_tls_context, *upstream_tls_context.mutable_common_tls_context()); upstream_tls_context.set_sni(json_tls_context.getString("sni", "")); MessageUtil::validate(upstream_tls_context); } void TlsContextJson::translateCommonTlsContext( - const Json::Object& json_tls_context, - envoy::api::v2::auth::CommonTlsContext& common_tls_context) { + const Json::Object& json_tls_context, envoy::api::v2::CommonTlsContext& common_tls_context) { const std::string alpn_protocols_str{json_tls_context.getString("alpn_protocols", "")}; for (auto alpn_protocol : StringUtil::splitToken(alpn_protocols_str, ",")) { common_tls_context.add_alpn_protocols(std::string{alpn_protocol}); @@ -71,8 +70,8 @@ void TlsContextJson::translateCommonTlsContext( } } -void TlsContextJson::translateTlsCertificate( - const Json::Object& json_tls_context, envoy::api::v2::auth::TlsCertificate& tls_certificate) { +void TlsContextJson::translateTlsCertificate(const Json::Object& json_tls_context, + envoy::api::v2::TlsCertificate& tls_certificate) { if (json_tls_context.hasObject("cert_chain_file")) { tls_certificate.mutable_certificate_chain()->set_filename( json_tls_context.getString("cert_chain_file", "")); diff --git a/source/common/config/tls_context_json.h b/source/common/config/tls_context_json.h index 49bf508bf7402..0b7a90d42098d 100644 --- a/source/common/config/tls_context_json.h +++ b/source/common/config/tls_context_json.h @@ -1,45 +1,45 @@ #pragma once -#include "envoy/api/v2/auth/cert.pb.h" #include "envoy/json/json_object.h" +#include "api/sds.pb.h" + namespace Envoy { namespace Config { class TlsContextJson { public: /** - * Translate a v1 JSON TLS context to v2 envoy::api::v2::auth::DownstreamTlsContext. + * Translate a v1 JSON TLS context to v2 envoy::api::v2::DownstreamTlsContext. * @param json_tls_context source v1 JSON TLS context object. - * @param downstream_tls_context destination v2 envoy::api::v2::cluster::Cluster. + * @param downstream_tls_context destination v2 envoy::api::v2::Cluster. */ static void translateDownstreamTlsContext(const Json::Object& json_tls_context, - envoy::api::v2::auth::DownstreamTlsContext& downstream_tls_context); + envoy::api::v2::DownstreamTlsContext& downstream_tls_context); /** - * Translate a v1 JSON TLS context to v2 envoy::api::v2::auth::UpstreamTlsContext. + * Translate a v1 JSON TLS context to v2 envoy::api::v2::UpstreamTlsContext. * @param json_tls_context source v1 JSON TLS context object. - * @param upstream_tls_context destination v2 envoy::api::v2::cluster::Cluster. + * @param upstream_tls_context destination v2 envoy::api::v2::Cluster. */ - static void - translateUpstreamTlsContext(const Json::Object& json_tls_context, - envoy::api::v2::auth::UpstreamTlsContext& upstream_tls_context); + static void translateUpstreamTlsContext(const Json::Object& json_tls_context, + envoy::api::v2::UpstreamTlsContext& upstream_tls_context); /** - * Translate a v1 JSON TLS context to v2 envoy::api::v2::auth::CommonTlsContext. + * Translate a v1 JSON TLS context to v2 envoy::api::v2::CommonTlsContext. * @param json_tls_context source v1 JSON TLS context object. - * @param common_tls_context destination v2 envoy::api::v2::cluster::Cluster. + * @param common_tls_context destination v2 envoy::api::v2::Cluster. */ static void translateCommonTlsContext(const Json::Object& json_tls_context, - envoy::api::v2::auth::CommonTlsContext& common_tls_context); + envoy::api::v2::CommonTlsContext& common_tls_context); /** - * Translate a v1 JSON TLS context to v2 envoy::api::v2::auth::TlsCertificate. + * Translate a v1 JSON TLS context to v2 envoy::api::v2::TlsCertificate. * @param json_tls_context source v1 JSON TLS context object. - * @param common_tls_context destination v2 envoy::api::v2::auth::TlsCertificate. + * @param common_tls_context destination v2 envoy::api::v2::TlsCertificate. */ static void translateTlsCertificate(const Json::Object& json_tls_context, - envoy::api::v2::auth::TlsCertificate& tls_certificate); + envoy::api::v2::TlsCertificate& tls_certificate); }; } // namespace Config diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index 2c971029fa477..06a9e9102bf8f 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -2,8 +2,6 @@ #include -#include "envoy/config/metrics/v2/stats.pb.h" - #include "common/common/assert.h" #include "common/common/hex.h" #include "common/common/utility.h" @@ -16,6 +14,7 @@ #include "common/protobuf/utility.h" #include "common/stats/stats_impl.h" +#include "api/stats.pb.h" #include "fmt/format.h" namespace Envoy { @@ -91,7 +90,7 @@ void Utility::checkApiConfigSourceSubscriptionBackingCluster( const auto& cluster_name = api_config_source.cluster_names()[0]; const auto& it = clusters.find(cluster_name); if (it == clusters.end() || it->second.get().info()->addedViaApi() || - it->second.get().info()->type() == envoy::api::v2::cluster::Cluster::EDS) { + it->second.get().info()->type() == envoy::api::v2::Cluster::EDS) { throw EnvoyException(fmt::format( "envoy::api::v2::ConfigSource must have a statically " "defined non-EDS cluster: '{}' does not exist, was added via api, or is an EDS cluster", @@ -150,24 +149,22 @@ void Utility::translateLdsConfig(const Json::Object& json_lds, std::string Utility::resourceName(const ProtobufWkt::Any& resource) { if (resource.type_url() == Config::TypeUrl::get().Listener) { - return MessageUtil::anyConvert(resource).name(); + return MessageUtil::anyConvert(resource).name(); } if (resource.type_url() == Config::TypeUrl::get().RouteConfiguration) { - return MessageUtil::anyConvert(resource).name(); + return MessageUtil::anyConvert(resource).name(); } if (resource.type_url() == Config::TypeUrl::get().Cluster) { - return MessageUtil::anyConvert(resource).name(); + return MessageUtil::anyConvert(resource).name(); } if (resource.type_url() == Config::TypeUrl::get().ClusterLoadAssignment) { - return MessageUtil::anyConvert(resource) - .cluster_name(); + return MessageUtil::anyConvert(resource).cluster_name(); } throw EnvoyException( fmt::format("Unknown type URL {} in DiscoveryResponse", resource.type_url())); } -Stats::TagProducerPtr -Utility::createTagProducer(const envoy::config::bootstrap::v2::Bootstrap& bootstrap) { +Stats::TagProducerPtr Utility::createTagProducer(const envoy::api::v2::Bootstrap& bootstrap) { return std::make_unique(bootstrap.stats_config()); } diff --git a/source/common/config/utility.h b/source/common/config/utility.h index 7beac9088161d..a8e3c843cf152 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -1,17 +1,10 @@ #pragma once -#include "envoy/api/v2/base.pb.h" -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" -#include "envoy/api/v2/route/route.pb.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/config/grpc_mux.h" #include "envoy/config/subscription.h" #include "envoy/json/json_object.h" #include "envoy/local_info/local_info.h" #include "envoy/registry/registry.h" -#include "envoy/service/discovery/v2/cds.pb.h" -#include "envoy/service/discovery/v2/eds.pb.h" -#include "envoy/service/discovery/v2/lds.pb.h" #include "envoy/stats/stats.h" #include "envoy/upstream/cluster_manager.h" @@ -23,6 +16,14 @@ #include "common/protobuf/utility.h" #include "common/singleton/const_singleton.h" +#include "api/base.pb.h" +#include "api/bootstrap.pb.h" +#include "api/cds.pb.h" +#include "api/eds.pb.h" +#include "api/filter/network/http_connection_manager.pb.h" +#include "api/lds.pb.h" +#include "api/rds.pb.h" + namespace Envoy { namespace Config { @@ -50,7 +51,7 @@ class Utility { */ template static Protobuf::RepeatedPtrField - getTypedResources(const envoy::service::discovery::v2::DiscoveryResponse& response) { + getTypedResources(const envoy::api::v2::DiscoveryResponse& response) { Protobuf::RepeatedPtrField typed_resources; for (const auto& resource : response.resources()) { auto* typed_resource = typed_resources.Add(); @@ -235,8 +236,7 @@ class Utility { * @param bootstrap bootstrap proto. * @throws EnvoyException when the conflict of tag names is found. */ - static Stats::TagProducerPtr - createTagProducer(const envoy::config::bootstrap::v2::Bootstrap& bootstrap); + static Stats::TagProducerPtr createTagProducer(const envoy::api::v2::Bootstrap& bootstrap); /** * Check user supplied name in RDS/CDS/LDS for sanity. diff --git a/source/common/filter/BUILD b/source/common/filter/BUILD index db6ca897aef4a..f1eddee693ad9 100644 --- a/source/common/filter/BUILD +++ b/source/common/filter/BUILD @@ -25,6 +25,7 @@ envoy_cc_library( name = "ratelimit_lib", srcs = ["ratelimit.cc"], hdrs = ["ratelimit.h"], + external_deps = ["envoy_filter_network_rate_limit"], deps = [ "//include/envoy/network:connection_interface", "//include/envoy/network:filter_interface", @@ -32,7 +33,6 @@ envoy_cc_library( "//include/envoy/runtime:runtime_interface", "//include/envoy/stats:stats_macros", "//source/common/tracing:http_tracer_lib", - "@envoy_api//envoy/api/v2/filter/network:rate_limit_cc", ], ) @@ -40,6 +40,9 @@ envoy_cc_library( name = "tcp_proxy_lib", srcs = ["tcp_proxy.cc"], hdrs = ["tcp_proxy.h"], + external_deps = [ + "envoy_filter_network_tcp_proxy", + ], deps = [ "//include/envoy/access_log:access_log_interface", "//include/envoy/buffer:buffer_interface", @@ -62,6 +65,5 @@ envoy_cc_library( "//source/common/network:filter_lib", "//source/common/network:utility_lib", "//source/common/request_info:request_info_lib", - "@envoy_api//envoy/api/v2/filter/network:tcp_proxy_cc", ], ) diff --git a/source/common/filter/auth/BUILD b/source/common/filter/auth/BUILD index a691c2ecd8f0f..efc1aa64c0736 100644 --- a/source/common/filter/auth/BUILD +++ b/source/common/filter/auth/BUILD @@ -12,6 +12,7 @@ envoy_cc_library( name = "client_ssl_lib", srcs = ["client_ssl.cc"], hdrs = ["client_ssl.h"], + external_deps = ["envoy_filter_network_client_ssl_auth"], deps = [ "//include/envoy/network:connection_interface", "//include/envoy/network:filter_interface", @@ -29,6 +30,5 @@ envoy_cc_library( "//source/common/json:json_loader_lib", "//source/common/network:cidr_range_lib", "//source/common/network:utility_lib", - "@envoy_api//envoy/api/v2/filter/network:client_ssl_auth_cc", ], ) diff --git a/source/common/filter/auth/client_ssl.h b/source/common/filter/auth/client_ssl.h index 870151682f913..4fe5ec5d5c8c7 100644 --- a/source/common/filter/auth/client_ssl.h +++ b/source/common/filter/auth/client_ssl.h @@ -5,7 +5,6 @@ #include #include -#include "envoy/api/v2/filter/network/client_ssl_auth.pb.h" #include "envoy/network/filter.h" #include "envoy/runtime/runtime.h" #include "envoy/stats/stats_macros.h" @@ -17,6 +16,8 @@ #include "common/network/utility.h" #include "common/protobuf/utility.h" +#include "api/filter/network/client_ssl_auth.pb.h" + namespace Envoy { namespace Filter { namespace Auth { diff --git a/source/common/filter/ratelimit.h b/source/common/filter/ratelimit.h index 61a12b161c37c..b94c0774ed284 100644 --- a/source/common/filter/ratelimit.h +++ b/source/common/filter/ratelimit.h @@ -5,13 +5,14 @@ #include #include -#include "envoy/api/v2/filter/network/rate_limit.pb.h" #include "envoy/network/connection.h" #include "envoy/network/filter.h" #include "envoy/ratelimit/ratelimit.h" #include "envoy/runtime/runtime.h" #include "envoy/stats/stats_macros.h" +#include "api/filter/network/rate_limit.pb.h" + namespace Envoy { namespace RateLimit { namespace TcpFilter { diff --git a/source/common/filter/tcp_proxy.cc b/source/common/filter/tcp_proxy.cc index 7237d5de61c22..6c0674bba976e 100644 --- a/source/common/filter/tcp_proxy.cc +++ b/source/common/filter/tcp_proxy.cc @@ -3,7 +3,6 @@ #include #include -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" #include "envoy/buffer/buffer.h" #include "envoy/event/dispatcher.h" #include "envoy/event/timer.h" @@ -15,6 +14,7 @@ #include "common/common/assert.h" #include "common/common/empty_string.h" +#include "api/filter/network/http_connection_manager.pb.h" #include "fmt/format.h" namespace Envoy { diff --git a/source/common/filter/tcp_proxy.h b/source/common/filter/tcp_proxy.h index 15452eaeee4cc..1c4cdc108107d 100644 --- a/source/common/filter/tcp_proxy.h +++ b/source/common/filter/tcp_proxy.h @@ -7,7 +7,6 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/filter/network/tcp_proxy.pb.h" #include "envoy/event/timer.h" #include "envoy/network/connection.h" #include "envoy/network/filter.h" @@ -23,6 +22,8 @@ #include "common/network/utility.h" #include "common/request_info/request_info_impl.h" +#include "api/filter/network/tcp_proxy.pb.h" + namespace Envoy { namespace Filter { diff --git a/source/common/grpc/BUILD b/source/common/grpc/BUILD index ff1455cacc5c4..bb0ccae947856 100644 --- a/source/common/grpc/BUILD +++ b/source/common/grpc/BUILD @@ -93,6 +93,8 @@ envoy_cc_library( external_deps = [ "path_matcher", "grpc_transcoding", + "http_api_protos", + "envoy_filter_http_transcoder", ], deps = [ ":codec_lib", @@ -102,8 +104,6 @@ envoy_cc_library( "//source/common/common:base64_lib", "//source/common/http:headers_lib", "//source/common/protobuf", - "@envoy_api//envoy/api/v2/filter/http:transcoder_cc", - "@googleapis//:http_api_protos", ], ) diff --git a/source/common/grpc/json_transcoder_filter.h b/source/common/grpc/json_transcoder_filter.h index 4f442bf800c13..f57319c218fe2 100644 --- a/source/common/grpc/json_transcoder_filter.h +++ b/source/common/grpc/json_transcoder_filter.h @@ -1,6 +1,5 @@ #pragma once -#include "envoy/api/v2/filter/http/transcoder.pb.h" #include "envoy/buffer/buffer.h" #include "envoy/http/filter.h" #include "envoy/http/header_map.h" @@ -10,6 +9,7 @@ #include "common/grpc/transcoder_input_stream_impl.h" #include "common/protobuf/protobuf.h" +#include "api/filter/http/transcoder.pb.h" #include "grpc_transcoding/path_matcher.h" #include "grpc_transcoding/request_message_translator.h" #include "grpc_transcoding/transcoder.h" diff --git a/source/common/http/BUILD b/source/common/http/BUILD index f31fa177f25ba..98099c2e7b5e8 100644 --- a/source/common/http/BUILD +++ b/source/common/http/BUILD @@ -227,6 +227,7 @@ envoy_cc_library( hdrs = ["utility.h"], external_deps = [ "abseil_strings", + "envoy_protocol", ], deps = [ ":exception_lib", @@ -243,7 +244,6 @@ envoy_cc_library( "//source/common/json:json_loader_lib", "//source/common/network:utility_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2:protocol_cc", ], ) diff --git a/source/common/http/filter/BUILD b/source/common/http/filter/BUILD index 618ee2bcf0108..5b381e8c4442e 100644 --- a/source/common/http/filter/BUILD +++ b/source/common/http/filter/BUILD @@ -48,6 +48,7 @@ envoy_cc_library( name = "fault_filter_lib", srcs = ["fault_filter.cc"], hdrs = ["fault_filter.h"], + external_deps = ["envoy_filter_http_fault"], deps = [ "//include/envoy/event:timer_interface", "//include/envoy/http:codes_interface", @@ -63,7 +64,6 @@ envoy_cc_library( "//source/common/http:headers_lib", "//source/common/protobuf:utility_lib", "//source/common/router:config_lib", - "@envoy_api//envoy/api/v2/filter/http:fault_cc", ], ) @@ -97,6 +97,7 @@ envoy_cc_library( envoy_cc_library( name = "ratelimit_includes", hdrs = ["ratelimit.h"], + external_deps = ["envoy_filter_http_rate_limit"], deps = [ "//include/envoy/http:filter_interface", "//include/envoy/local_info:local_info_interface", @@ -108,6 +109,5 @@ envoy_cc_library( "//source/common/json:config_schemas_lib", "//source/common/json:json_loader_lib", "//source/common/json:json_validator_lib", - "@envoy_api//envoy/api/v2/filter/http:rate_limit_cc", ], ) diff --git a/source/common/http/filter/fault_filter.h b/source/common/http/filter/fault_filter.h index 5f7841b628e5a..7ea43a9ed970d 100644 --- a/source/common/http/filter/fault_filter.h +++ b/source/common/http/filter/fault_filter.h @@ -6,14 +6,15 @@ #include #include -#include "envoy/api/v2/filter/http/fault.pb.h" -#include "envoy/api/v2/route/route.pb.h" #include "envoy/http/filter.h" #include "envoy/runtime/runtime.h" #include "envoy/stats/stats_macros.h" #include "common/router/config_impl.h" +#include "api/filter/http/fault.pb.h" +#include "api/rds.pb.h" + namespace Envoy { namespace Http { diff --git a/source/common/http/filter/ratelimit.h b/source/common/http/filter/ratelimit.h index 585219fca32c4..870209e007996 100644 --- a/source/common/http/filter/ratelimit.h +++ b/source/common/http/filter/ratelimit.h @@ -5,7 +5,6 @@ #include #include -#include "envoy/api/v2/filter/http/rate_limit.pb.h" #include "envoy/http/filter.h" #include "envoy/local_info/local_info.h" #include "envoy/ratelimit/ratelimit.h" @@ -15,6 +14,8 @@ #include "common/common/assert.h" #include "common/http/header_map_impl.h" +#include "api/filter/http/rate_limit.pb.h" + namespace Envoy { namespace Http { namespace RateLimit { diff --git a/source/common/http/utility.h b/source/common/http/utility.h index 323a37e61cd7b..7747e538cd0be 100644 --- a/source/common/http/utility.h +++ b/source/common/http/utility.h @@ -4,12 +4,13 @@ #include #include -#include "envoy/api/v2/protocol.pb.h" #include "envoy/http/codes.h" #include "envoy/http/filter.h" #include "common/json/json_loader.h" +#include "api/protocol.pb.h" + namespace Envoy { namespace Http { diff --git a/source/common/mongo/BUILD b/source/common/mongo/BUILD index e8754e8c6f1a6..670461d571c9c 100644 --- a/source/common/mongo/BUILD +++ b/source/common/mongo/BUILD @@ -40,6 +40,7 @@ envoy_cc_library( name = "proxy_lib", srcs = ["proxy.cc"], hdrs = ["proxy.h"], + external_deps = ["envoy_filter_network_mongo_proxy"], deps = [ ":codec_lib", ":utility_lib", @@ -60,7 +61,6 @@ envoy_cc_library( "//source/common/network:filter_lib", "//source/common/protobuf:utility_lib", "//source/common/singleton:const_singleton", - "@envoy_api//envoy/api/v2/filter/network:mongo_proxy_cc", ], ) diff --git a/source/common/mongo/proxy.h b/source/common/mongo/proxy.h index b54f0f253376d..78103b71b5b2a 100644 --- a/source/common/mongo/proxy.h +++ b/source/common/mongo/proxy.h @@ -7,7 +7,6 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/filter/network/mongo_proxy.pb.h" #include "envoy/common/time.h" #include "envoy/event/timer.h" #include "envoy/mongo/codec.h" @@ -25,6 +24,8 @@ #include "common/protobuf/utility.h" #include "common/singleton/const_singleton.h" +#include "api/filter/network/mongo_proxy.pb.h" + namespace Envoy { namespace Mongo { diff --git a/source/common/network/BUILD b/source/common/network/BUILD index 542bb82022fab..607a3b248b255 100644 --- a/source/common/network/BUILD +++ b/source/common/network/BUILD @@ -23,6 +23,9 @@ envoy_cc_library( name = "cidr_range_lib", srcs = ["cidr_range.cc"], hdrs = ["cidr_range.h"], + external_deps = [ + "envoy_address", + ], deps = [ ":address_lib", ":utility_lib", @@ -30,7 +33,6 @@ envoy_cc_library( "//include/envoy/network:address_interface", "//source/common/common:assert_lib", "//source/common/common:utility_lib", - "@envoy_api//envoy/api/v2:address_cc", ], ) @@ -134,13 +136,13 @@ envoy_cc_library( name = "raw_buffer_socket_lib", srcs = ["raw_buffer_socket.cc"], hdrs = ["raw_buffer_socket.h"], + external_deps = ["envoy_base"], deps = [ ":utility_lib", "//include/envoy/network:transport_socket_interface", "//source/common/buffer:buffer_lib", "//source/common/common:empty_string", "//source/common/http:headers_lib", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -148,6 +150,7 @@ envoy_cc_library( name = "resolver_lib", srcs = ["resolver_impl.cc"], hdrs = ["resolver_impl.h"], + external_deps = ["envoy_base"], deps = [ ":utility_lib", "//include/envoy/network:address_interface", @@ -156,7 +159,6 @@ envoy_cc_library( "//source/common/config:well_known_names", "//source/common/network:address_lib", "//source/common/protobuf", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -166,6 +168,7 @@ envoy_cc_library( hdrs = ["utility.h"], external_deps = [ "abseil_strings", + "envoy_base", ], deps = [ ":address_lib", @@ -174,6 +177,5 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/common:utility_lib", "//source/common/protobuf", - "@envoy_api//envoy/api/v2:base_cc", ], ) diff --git a/source/common/network/cidr_range.h b/source/common/network/cidr_range.h index cbc425fd16add..eda1db444edff 100644 --- a/source/common/network/cidr_range.h +++ b/source/common/network/cidr_range.h @@ -3,12 +3,13 @@ #include #include -#include "envoy/api/v2/address.pb.h" #include "envoy/json/json_object.h" #include "envoy/network/address.h" #include "common/protobuf/protobuf.h" +#include "api/address.pb.h" + namespace Envoy { namespace Network { namespace Address { diff --git a/source/common/network/resolver_impl.cc b/source/common/network/resolver_impl.cc index 77b45c2d06ecb..eef0dc4ba3c0a 100644 --- a/source/common/network/resolver_impl.cc +++ b/source/common/network/resolver_impl.cc @@ -1,6 +1,5 @@ #include "common/network/resolver_impl.h" -#include "envoy/api/v2/address.pb.h" #include "envoy/common/exception.h" #include "envoy/network/address.h" #include "envoy/network/resolver.h" @@ -10,6 +9,8 @@ #include "common/network/address_impl.h" #include "common/network/utility.h" +#include "api/address.pb.h" + namespace Envoy { namespace Network { namespace Address { diff --git a/source/common/network/resolver_impl.h b/source/common/network/resolver_impl.h index 6f3fd0ff3b36f..30af33cb5a1c3 100644 --- a/source/common/network/resolver_impl.h +++ b/source/common/network/resolver_impl.h @@ -1,12 +1,13 @@ #pragma once -#include "envoy/api/v2/address.pb.h" #include "envoy/network/address.h" #include "envoy/network/connection.h" #include "envoy/network/resolver.h" #include "common/network/address_impl.h" +#include "api/address.pb.h" + namespace Envoy { namespace Network { namespace Address { diff --git a/source/common/network/utility.h b/source/common/network/utility.h index 3cb871c8ad1d2..9b9406c6b1609 100644 --- a/source/common/network/utility.h +++ b/source/common/network/utility.h @@ -4,11 +4,11 @@ #include #include -#include "envoy/api/v2/address.pb.h" #include "envoy/network/connection.h" #include "envoy/stats/stats.h" #include "absl/strings/string_view.h" +#include "api/address.pb.h" namespace Envoy { namespace Network { diff --git a/source/common/ratelimit/BUILD b/source/common/ratelimit/BUILD index df6c04c90c277..fcc70e9fd3bf3 100644 --- a/source/common/ratelimit/BUILD +++ b/source/common/ratelimit/BUILD @@ -13,6 +13,7 @@ envoy_cc_library( name = "ratelimit_lib", srcs = ["ratelimit_impl.cc"], hdrs = ["ratelimit_impl.h"], + external_deps = ["envoy_bootstrap"], deps = [ ":ratelimit_proto", "//include/envoy/grpc:async_client_interface", @@ -22,7 +23,6 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/http:headers_lib", "//source/common/tracing:http_tracer_lib", - "@envoy_api//envoy/config/ratelimit/v2:rls_cc", ], ) diff --git a/source/common/ratelimit/ratelimit_impl.cc b/source/common/ratelimit/ratelimit_impl.cc index ae31ab9bae1c7..70070d373143b 100644 --- a/source/common/ratelimit/ratelimit_impl.cc +++ b/source/common/ratelimit/ratelimit_impl.cc @@ -75,14 +75,13 @@ void GrpcClientImpl::onFailure(Grpc::Status::GrpcStatus status, const std::strin callbacks_ = nullptr; } -GrpcFactoryImpl::GrpcFactoryImpl(const envoy::config::ratelimit::v2::RateLimitServiceConfig& config, +GrpcFactoryImpl::GrpcFactoryImpl(const envoy::api::v2::RateLimitServiceConfig& config, Grpc::AsyncClientManager& async_client_manager, Stats::Scope& scope) { envoy::api::v2::GrpcService grpc_service; grpc_service.MergeFrom(config.grpc_service()); // TODO(htuch): cluster_name is deprecated, remove after 1.6.0. - if (config.service_specifier_case() == - envoy::config::ratelimit::v2::RateLimitServiceConfig::kClusterName) { + if (config.service_specifier_case() == envoy::api::v2::RateLimitServiceConfig::kClusterName) { grpc_service.mutable_envoy_grpc()->set_cluster_name(config.cluster_name()); } async_client_factory_ = async_client_manager.factoryForGrpcService(grpc_service, scope); diff --git a/source/common/ratelimit/ratelimit_impl.h b/source/common/ratelimit/ratelimit_impl.h index 7d000b6d3293b..97a6a36d37123 100644 --- a/source/common/ratelimit/ratelimit_impl.h +++ b/source/common/ratelimit/ratelimit_impl.h @@ -5,7 +5,6 @@ #include #include -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/grpc/async_client.h" #include "envoy/grpc/async_client_manager.h" #include "envoy/ratelimit/ratelimit.h" @@ -16,6 +15,8 @@ #include "source/common/ratelimit/ratelimit.pb.h" +#include "api/bootstrap.pb.h" + namespace Envoy { namespace RateLimit { @@ -64,7 +65,7 @@ class GrpcClientImpl : public Client, public RateLimitAsyncCallbacks { class GrpcFactoryImpl : public ClientFactory { public: - GrpcFactoryImpl(const envoy::config::ratelimit::v2::RateLimitServiceConfig& config, + GrpcFactoryImpl(const envoy::api::v2::RateLimitServiceConfig& config, Grpc::AsyncClientManager& async_client_manager, Stats::Scope& scope); // RateLimit::ClientFactory diff --git a/source/common/redis/BUILD b/source/common/redis/BUILD index 229efcb7763de..8d9ad98ad9525 100644 --- a/source/common/redis/BUILD +++ b/source/common/redis/BUILD @@ -38,6 +38,7 @@ envoy_cc_library( name = "conn_pool_lib", srcs = ["conn_pool_impl.cc"], hdrs = ["conn_pool_impl.h"], + external_deps = ["envoy_filter_network_redis_proxy"], deps = [ ":codec_lib", "//include/envoy/redis:conn_pool_interface", @@ -48,7 +49,6 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/network:filter_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2/filter/network:redis_proxy_cc", ], ) @@ -56,6 +56,7 @@ envoy_cc_library( name = "proxy_filter_lib", srcs = ["proxy_filter.cc"], hdrs = ["proxy_filter.h"], + external_deps = ["envoy_filter_network_redis_proxy"], deps = [ "//include/envoy/network:drain_decision_interface", "//include/envoy/network:filter_interface", @@ -65,7 +66,6 @@ envoy_cc_library( "//source/common/buffer:buffer_lib", "//source/common/common:assert_lib", "//source/common/config:utility_lib", - "@envoy_api//envoy/api/v2/filter/network:redis_proxy_cc", ], ) diff --git a/source/common/redis/conn_pool_impl.h b/source/common/redis/conn_pool_impl.h index e6543da2701a2..6fbead0dd8834 100644 --- a/source/common/redis/conn_pool_impl.h +++ b/source/common/redis/conn_pool_impl.h @@ -8,7 +8,6 @@ #include #include -#include "envoy/api/v2/filter/network/redis_proxy.pb.h" #include "envoy/redis/conn_pool.h" #include "envoy/thread_local/thread_local.h" #include "envoy/upstream/cluster_manager.h" @@ -18,6 +17,8 @@ #include "common/protobuf/utility.h" #include "common/redis/codec_impl.h" +#include "api/filter/network/redis_proxy.pb.h" + namespace Envoy { namespace Redis { namespace ConnPool { diff --git a/source/common/redis/proxy_filter.h b/source/common/redis/proxy_filter.h index 7771fbad797fc..a9b3f9e9f876e 100644 --- a/source/common/redis/proxy_filter.h +++ b/source/common/redis/proxy_filter.h @@ -5,7 +5,6 @@ #include #include -#include "envoy/api/v2/filter/network/redis_proxy.pb.h" #include "envoy/network/drain_decision.h" #include "envoy/network/filter.h" #include "envoy/redis/codec.h" @@ -14,6 +13,8 @@ #include "common/buffer/buffer_impl.h" +#include "api/filter/network/redis_proxy.pb.h" + namespace Envoy { namespace Redis { diff --git a/source/common/router/BUILD b/source/common/router/BUILD index bffb0b6204f91..927a062e794b4 100644 --- a/source/common/router/BUILD +++ b/source/common/router/BUILD @@ -41,6 +41,7 @@ envoy_cc_library( name = "config_utility_lib", srcs = ["config_utility.cc"], hdrs = ["config_utility.h"], + external_deps = ["envoy_rds"], deps = [ "//include/envoy/http:codes_interface", "//include/envoy/upstream:resource_manager_interface", @@ -50,7 +51,6 @@ envoy_cc_library( "//source/common/filesystem:filesystem_lib", "//source/common/http:headers_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/service/discovery/v2:rds_cc", ], ) @@ -58,6 +58,10 @@ envoy_cc_library( name = "rds_lib", srcs = ["rds_impl.cc"], hdrs = ["rds_impl.h"], + external_deps = [ + "envoy_filter_network_http_connection_manager", + "envoy_rds", + ], deps = [ ":config_lib", ":rds_subscription_lib", @@ -76,8 +80,6 @@ envoy_cc_library( "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2/filter/network:http_connection_manager_cc", - "@envoy_api//envoy/service/discovery/v2:rds_cc", ], ) @@ -85,6 +87,9 @@ envoy_cc_library( name = "rds_subscription_lib", srcs = ["rds_subscription.cc"], hdrs = ["rds_subscription.h"], + external_deps = [ + "envoy_filter_network_http_connection_manager", + ], deps = [ "//include/envoy/config:subscription_interface", "//source/common/common:assert_lib", @@ -93,7 +98,6 @@ envoy_cc_library( "//source/common/http:headers_lib", "//source/common/http:rest_api_fetcher_lib", "//source/common/json:json_loader_lib", - "@envoy_api//envoy/api/v2/filter/network:http_connection_manager_cc", ], ) @@ -125,6 +129,7 @@ envoy_cc_library( name = "router_lib", srcs = ["router.cc"], hdrs = ["router.h"], + external_deps = ["envoy_filter_http_router"], deps = [ ":config_lib", ":header_parser_lib", @@ -162,7 +167,6 @@ envoy_cc_library( "//source/common/http:utility_lib", "//source/common/request_info:request_info_lib", "//source/common/tracing:http_tracer_lib", - "@envoy_api//envoy/api/v2/filter/http:router_cc", ], ) diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 75cf3d0d740a0..404bcf261738f 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -35,7 +35,7 @@ std::string SslRedirector::newPath(const Http::HeaderMap& headers) const { return Http::Utility::createSslRedirectPath(headers); } -RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RouteAction& config) { +RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::RouteAction& config) { if (!config.has_retry_policy()) { return; } @@ -47,7 +47,7 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RouteAction& confi retry_on_ |= RetryStateImpl::parseRetryGrpcOn(config.retry_policy().retry_on()); } -CorsPolicyImpl::CorsPolicyImpl(const envoy::api::v2::route::CorsPolicy& config) { +CorsPolicyImpl::CorsPolicyImpl(const envoy::api::v2::CorsPolicy& config) { for (const auto& origin : config.allow_origin()) { allow_origin_.push_back(origin); } @@ -61,7 +61,7 @@ CorsPolicyImpl::CorsPolicyImpl(const envoy::api::v2::route::CorsPolicy& config) enabled_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enabled, true); } -ShadowPolicyImpl::ShadowPolicyImpl(const envoy::api::v2::route::RouteAction& config) { +ShadowPolicyImpl::ShadowPolicyImpl(const envoy::api::v2::RouteAction& config) { if (!config.has_request_mirror_policy()) { return; } @@ -126,21 +126,20 @@ class IpHashMethod : public HashPolicyImpl::HashMethod { }; HashPolicyImpl::HashPolicyImpl( - const Protobuf::RepeatedPtrField& - hash_policies) { + const Protobuf::RepeatedPtrField& hash_policies) { // TODO(htuch): Add support for cookie hash policies, #1295 hash_impls_.reserve(hash_policies.size()); for (auto& hash_policy : hash_policies) { switch (hash_policy.policy_specifier_case()) { - case envoy::api::v2::route::RouteAction::HashPolicy::kHeader: + case envoy::api::v2::RouteAction::HashPolicy::kHeader: hash_impls_.emplace_back(new HeaderHashMethod(hash_policy.header().header_name())); break; - case envoy::api::v2::route::RouteAction::HashPolicy::kCookie: + case envoy::api::v2::RouteAction::HashPolicy::kCookie: hash_impls_.emplace_back( new CookieHashMethod(hash_policy.cookie().name(), hash_policy.cookie().ttl().seconds())); break; - case envoy::api::v2::route::RouteAction::HashPolicy::kConnectionProperties: + case envoy::api::v2::RouteAction::HashPolicy::kConnectionProperties: if (hash_policy.connection_properties().source_ip()) { hash_impls_.emplace_back(new IpHashMethod()); } @@ -205,7 +204,7 @@ MetadataMatchCriteriaImpl::extractMetadataMatchCriteria(const MetadataMatchCrite return v; } -DecoratorImpl::DecoratorImpl(const envoy::api::v2::route::Decorator& decorator) +DecoratorImpl::DecoratorImpl(const envoy::api::v2::Decorator& decorator) : operation_(decorator.operation()) {} void DecoratorImpl::apply(Tracing::Span& span) const { @@ -217,8 +216,7 @@ void DecoratorImpl::apply(Tracing::Span& span) const { const std::string& DecoratorImpl::getOperation() const { return operation_; } RouteEntryImplBase::RouteEntryImplBase(const VirtualHostImpl& vhost, - const envoy::api::v2::route::Route& route, - Runtime::Loader& loader) + const envoy::api::v2::Route& route, Runtime::Loader& loader) : case_sensitive_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(route.match(), case_sensitive, true)), prefix_rewrite_(route.route().prefix_rewrite()), host_rewrite_(route.route().host_rewrite()), vhost_(vhost), @@ -258,8 +256,7 @@ RouteEntryImplBase::RouteEntryImplBase(const VirtualHostImpl& vhost, // single cluster, pointing back to the parent. Metadata criteria // from the weighted cluster (if any) are merged with and override // the criteria from the route. - if (route.route().cluster_specifier_case() == - envoy::api::v2::route::RouteAction::kWeightedClusters) { + if (route.route().cluster_specifier_case() == envoy::api::v2::RouteAction::kWeightedClusters) { ASSERT(total_cluster_weight_ > 0); uint64_t total_weight = 0UL; @@ -360,7 +357,7 @@ void RouteEntryImplBase::finalizeResponseHeaders( } Optional -RouteEntryImplBase::loadRuntimeData(const envoy::api::v2::route::RouteMatch& route_match) { +RouteEntryImplBase::loadRuntimeData(const envoy::api::v2::RouteMatch& route_match) { Optional runtime; if (route_match.has_runtime()) { RuntimeData data; @@ -409,7 +406,7 @@ std::string RouteEntryImplBase::newPath(const Http::HeaderMap& headers) const { } std::multimap -RouteEntryImplBase::parseOpaqueConfig(const envoy::api::v2::route::Route& route) { +RouteEntryImplBase::parseOpaqueConfig(const envoy::api::v2::Route& route) { std::multimap ret; if (route.has_metadata()) { const auto filter_metadata = @@ -426,7 +423,7 @@ RouteEntryImplBase::parseOpaqueConfig(const envoy::api::v2::route::Route& route) return ret; } -DecoratorConstPtr RouteEntryImplBase::parseDecorator(const envoy::api::v2::route::Route& route) { +DecoratorConstPtr RouteEntryImplBase::parseDecorator(const envoy::api::v2::Route& route) { DecoratorConstPtr ret; if (route.has_decorator()) { ret = DecoratorConstPtr(new DecoratorImpl(route.decorator())); @@ -522,7 +519,7 @@ void RouteEntryImplBase::validateClusters(Upstream::ClusterManager& cm) const { } PrefixRouteEntryImpl::PrefixRouteEntryImpl(const VirtualHostImpl& vhost, - const envoy::api::v2::route::Route& route, + const envoy::api::v2::Route& route, Runtime::Loader& loader) : RouteEntryImplBase(vhost, route, loader), prefix_(route.match().prefix()) {} @@ -543,8 +540,7 @@ RouteConstSharedPtr PrefixRouteEntryImpl::matches(const Http::HeaderMap& headers } PathRouteEntryImpl::PathRouteEntryImpl(const VirtualHostImpl& vhost, - const envoy::api::v2::route::Route& route, - Runtime::Loader& loader) + const envoy::api::v2::Route& route, Runtime::Loader& loader) : RouteEntryImplBase(vhost, route, loader), path_(route.match().path()) {} void PathRouteEntryImpl::finalizeRequestHeaders( @@ -583,7 +579,7 @@ RouteConstSharedPtr PathRouteEntryImpl::matches(const Http::HeaderMap& headers, } RegexRouteEntryImpl::RegexRouteEntryImpl(const VirtualHostImpl& vhost, - const envoy::api::v2::route::Route& route, + const envoy::api::v2::Route& route, Runtime::Loader& loader) : RouteEntryImplBase(vhost, route, loader), regex_(RegexUtil::parseRegex(route.match().regex().c_str())) {} @@ -611,7 +607,7 @@ RouteConstSharedPtr RegexRouteEntryImpl::matches(const Http::HeaderMap& headers, return nullptr; } -VirtualHostImpl::VirtualHostImpl(const envoy::api::v2::route::VirtualHost& virtual_host, +VirtualHostImpl::VirtualHostImpl(const envoy::api::v2::VirtualHost& virtual_host, const ConfigImpl& global_route_config, Runtime::Loader& runtime, Upstream::ClusterManager& cm, bool validate_clusters) : name_(virtual_host.name()), rate_limit_policy_(virtual_host.rate_limits()), @@ -620,13 +616,13 @@ VirtualHostImpl::VirtualHostImpl(const envoy::api::v2::route::VirtualHost& virtu response_headers_parser_(HeaderParser::configure(virtual_host.response_headers_to_add(), virtual_host.response_headers_to_remove())) { switch (virtual_host.require_tls()) { - case envoy::api::v2::route::VirtualHost::NONE: + case envoy::api::v2::VirtualHost::NONE: ssl_requirements_ = SslRequirements::NONE; break; - case envoy::api::v2::route::VirtualHost::EXTERNAL_ONLY: + case envoy::api::v2::VirtualHost::EXTERNAL_ONLY: ssl_requirements_ = SslRequirements::EXTERNAL_ONLY; break; - case envoy::api::v2::route::VirtualHost::ALL: + case envoy::api::v2::VirtualHost::ALL: ssl_requirements_ = SslRequirements::ALL; break; default: @@ -635,11 +631,10 @@ VirtualHostImpl::VirtualHostImpl(const envoy::api::v2::route::VirtualHost& virtu for (const auto& route : virtual_host.routes()) { const bool has_prefix = - route.match().path_specifier_case() == envoy::api::v2::route::RouteMatch::kPrefix; - const bool has_path = - route.match().path_specifier_case() == envoy::api::v2::route::RouteMatch::kPath; + route.match().path_specifier_case() == envoy::api::v2::RouteMatch::kPrefix; + const bool has_path = route.match().path_specifier_case() == envoy::api::v2::RouteMatch::kPath; const bool has_regex = - route.match().path_specifier_case() == envoy::api::v2::route::RouteMatch::kRegex; + route.match().path_specifier_case() == envoy::api::v2::RouteMatch::kRegex; if (has_prefix) { routes_.emplace_back(new PrefixRouteEntryImpl(*this, route, runtime)); } else if (has_path) { @@ -671,7 +666,7 @@ VirtualHostImpl::VirtualHostImpl(const envoy::api::v2::route::VirtualHost& virtu } VirtualHostImpl::VirtualClusterEntry::VirtualClusterEntry( - const envoy::api::v2::route::VirtualCluster& virtual_cluster) { + const envoy::api::v2::VirtualCluster& virtual_cluster) { if (virtual_cluster.method() != envoy::api::v2::RequestMethod::METHOD_UNSPECIFIED) { method_ = envoy::api::v2::RequestMethod_Name(virtual_cluster.method()); } @@ -701,7 +696,7 @@ const VirtualHostImpl* RouteMatcher::findWildcardVirtualHost(const std::string& return nullptr; } -RouteMatcher::RouteMatcher(const envoy::api::v2::route::RouteConfiguration& route_config, +RouteMatcher::RouteMatcher(const envoy::api::v2::RouteConfiguration& route_config, const ConfigImpl& global_route_config, Runtime::Loader& runtime, Upstream::ClusterManager& cm, bool validate_clusters) { for (const auto& virtual_host_config : route_config.virtual_hosts()) { @@ -803,9 +798,8 @@ VirtualHostImpl::virtualClusterFromEntries(const Http::HeaderMap& headers) const return nullptr; } -ConfigImpl::ConfigImpl(const envoy::api::v2::route::RouteConfiguration& config, - Runtime::Loader& runtime, Upstream::ClusterManager& cm, - bool validate_clusters_default) { +ConfigImpl::ConfigImpl(const envoy::api::v2::RouteConfiguration& config, Runtime::Loader& runtime, + Upstream::ClusterManager& cm, bool validate_clusters_default) { route_matcher_.reset(new RouteMatcher( config, *this, runtime, cm, PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, validate_clusters, validate_clusters_default))); diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index 66fabeb3a5443..9f5d3a0283556 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -10,7 +10,6 @@ #include #include -#include "envoy/api/v2/route/route.pb.h" #include "envoy/common/optional.h" #include "envoy/router/router.h" #include "envoy/runtime/runtime.h" @@ -21,6 +20,8 @@ #include "common/router/header_parser.h" #include "common/router/router_ratelimit.h" +#include "api/rds.pb.h" + namespace Envoy { namespace Router { @@ -72,7 +73,7 @@ class SslRedirectRoute : public Route { */ class CorsPolicyImpl : public CorsPolicy { public: - CorsPolicyImpl(const envoy::api::v2::route::CorsPolicy& config); + CorsPolicyImpl(const envoy::api::v2::CorsPolicy& config); // Router::CorsPolicy const std::list& allowOrigins() const override { return allow_origin_; }; @@ -99,7 +100,7 @@ class ConfigImpl; */ class VirtualHostImpl : public VirtualHost { public: - VirtualHostImpl(const envoy::api::v2::route::VirtualHost& virtual_host, + VirtualHostImpl(const envoy::api::v2::VirtualHost& virtual_host, const ConfigImpl& global_route_config, Runtime::Loader& runtime, Upstream::ClusterManager& cm, bool validate_clusters); @@ -119,7 +120,7 @@ class VirtualHostImpl : public VirtualHost { enum class SslRequirements { NONE, EXTERNAL_ONLY, ALL }; struct VirtualClusterEntry : public VirtualCluster { - VirtualClusterEntry(const envoy::api::v2::route::VirtualCluster& virtual_cluster); + VirtualClusterEntry(const envoy::api::v2::VirtualCluster& virtual_cluster); // Router::VirtualCluster const std::string& name() const override { return name_; } @@ -158,7 +159,7 @@ typedef std::shared_ptr VirtualHostSharedPtr; */ class RetryPolicyImpl : public RetryPolicy { public: - RetryPolicyImpl(const envoy::api::v2::route::RouteAction& config); + RetryPolicyImpl(const envoy::api::v2::RouteAction& config); // Router::RetryPolicy std::chrono::milliseconds perTryTimeout() const override { return per_try_timeout_; } @@ -176,7 +177,7 @@ class RetryPolicyImpl : public RetryPolicy { */ class ShadowPolicyImpl : public ShadowPolicy { public: - ShadowPolicyImpl(const envoy::api::v2::route::RouteAction& config); + ShadowPolicyImpl(const envoy::api::v2::RouteAction& config); // Router::ShadowPolicy const std::string& cluster() const override { return cluster_; } @@ -193,8 +194,8 @@ class ShadowPolicyImpl : public ShadowPolicy { */ class HashPolicyImpl : public HashPolicy { public: - HashPolicyImpl(const Protobuf::RepeatedPtrField& - hash_policy); + HashPolicyImpl( + const Protobuf::RepeatedPtrField& hash_policy); // Router::HashPolicy Optional generateHash(const std::string& downstream_addr, @@ -269,7 +270,7 @@ class MetadataMatchCriteriaImpl : public MetadataMatchCriteria { */ class DecoratorImpl : public Decorator { public: - DecoratorImpl(const envoy::api::v2::route::Decorator& decorator); + DecoratorImpl(const envoy::api::v2::Decorator& decorator); // Decorator::apply void apply(Tracing::Span& span) const override; @@ -293,7 +294,7 @@ class RouteEntryImplBase : public RouteEntry, /** * @throw EnvoyException with reason if the route configuration contains any errors */ - RouteEntryImplBase(const VirtualHostImpl& vhost, const envoy::api::v2::route::Route& route, + RouteEntryImplBase(const VirtualHostImpl& vhost, const envoy::api::v2::Route& route, Runtime::Loader& loader); bool isRedirect() const { return !host_redirect_.empty() || !path_redirect_.empty(); } @@ -453,12 +454,12 @@ class RouteEntryImplBase : public RouteEntry, typedef std::shared_ptr WeightedClusterEntrySharedPtr; - static Optional loadRuntimeData(const envoy::api::v2::route::RouteMatch& route); + static Optional loadRuntimeData(const envoy::api::v2::RouteMatch& route); static std::multimap - parseOpaqueConfig(const envoy::api::v2::route::Route& route); + parseOpaqueConfig(const envoy::api::v2::Route& route); - static DecoratorConstPtr parseDecorator(const envoy::api::v2::route::Route& route); + static DecoratorConstPtr parseDecorator(const envoy::api::v2::Route& route); // Default timeout is 15s if nothing is specified in the route config. static const uint64_t DEFAULT_ROUTE_TIMEOUT_MS = 15000; @@ -503,7 +504,7 @@ class RouteEntryImplBase : public RouteEntry, */ class PrefixRouteEntryImpl : public RouteEntryImplBase { public: - PrefixRouteEntryImpl(const VirtualHostImpl& vhost, const envoy::api::v2::route::Route& route, + PrefixRouteEntryImpl(const VirtualHostImpl& vhost, const envoy::api::v2::Route& route, Runtime::Loader& loader); // Router::RouteEntry @@ -522,7 +523,7 @@ class PrefixRouteEntryImpl : public RouteEntryImplBase { */ class PathRouteEntryImpl : public RouteEntryImplBase { public: - PathRouteEntryImpl(const VirtualHostImpl& vhost, const envoy::api::v2::route::Route& route, + PathRouteEntryImpl(const VirtualHostImpl& vhost, const envoy::api::v2::Route& route, Runtime::Loader& loader); // Router::RouteEntry @@ -541,7 +542,7 @@ class PathRouteEntryImpl : public RouteEntryImplBase { */ class RegexRouteEntryImpl : public RouteEntryImplBase { public: - RegexRouteEntryImpl(const VirtualHostImpl& vhost, const envoy::api::v2::route::Route& route, + RegexRouteEntryImpl(const VirtualHostImpl& vhost, const envoy::api::v2::Route& route, Runtime::Loader& loader); // Router::RouteEntry @@ -561,7 +562,7 @@ class RegexRouteEntryImpl : public RouteEntryImplBase { */ class RouteMatcher { public: - RouteMatcher(const envoy::api::v2::route::RouteConfiguration& config, + RouteMatcher(const envoy::api::v2::RouteConfiguration& config, const ConfigImpl& global_http_config, Runtime::Loader& runtime, Upstream::ClusterManager& cm, bool validate_clusters); @@ -591,7 +592,7 @@ class RouteMatcher { */ class ConfigImpl : public Config { public: - ConfigImpl(const envoy::api::v2::route::RouteConfiguration& config, Runtime::Loader& runtime, + ConfigImpl(const envoy::api::v2::RouteConfiguration& config, Runtime::Loader& runtime, Upstream::ClusterManager& cm, bool validate_clusters_default); const HeaderParser& requestHeaderParser() const { return *request_headers_parser_; }; diff --git a/source/common/router/config_utility.cc b/source/common/router/config_utility.cc index b722faa5e907e..fb40ed27d9430 100644 --- a/source/common/router/config_utility.cc +++ b/source/common/router/config_utility.cc @@ -73,25 +73,24 @@ bool ConfigUtility::matchQueryParams( } Http::Code ConfigUtility::parseRedirectResponseCode( - const envoy::api::v2::route::RedirectAction::RedirectResponseCode& code) { + const envoy::api::v2::RedirectAction::RedirectResponseCode& code) { switch (code) { - case envoy::api::v2::route::RedirectAction::MOVED_PERMANENTLY: + case envoy::api::v2::RedirectAction::MOVED_PERMANENTLY: return Http::Code::MovedPermanently; - case envoy::api::v2::route::RedirectAction::FOUND: + case envoy::api::v2::RedirectAction::FOUND: return Http::Code::Found; - case envoy::api::v2::route::RedirectAction::SEE_OTHER: + case envoy::api::v2::RedirectAction::SEE_OTHER: return Http::Code::SeeOther; - case envoy::api::v2::route::RedirectAction::TEMPORARY_REDIRECT: + case envoy::api::v2::RedirectAction::TEMPORARY_REDIRECT: return Http::Code::TemporaryRedirect; - case envoy::api::v2::route::RedirectAction::PERMANENT_REDIRECT: + case envoy::api::v2::RedirectAction::PERMANENT_REDIRECT: return Http::Code::PermanentRedirect; default: NOT_IMPLEMENTED; } } -Optional -ConfigUtility::parseDirectResponseCode(const envoy::api::v2::route::Route& route) { +Optional ConfigUtility::parseDirectResponseCode(const envoy::api::v2::Route& route) { if (route.has_redirect()) { return parseRedirectResponseCode(route.redirect().response_code()); } else if (route.has_direct_response()) { @@ -100,7 +99,7 @@ ConfigUtility::parseDirectResponseCode(const envoy::api::v2::route::Route& route return Optional(); } -std::string ConfigUtility::parseDirectResponseBody(const envoy::api::v2::route::Route& route) { +std::string ConfigUtility::parseDirectResponseBody(const envoy::api::v2::Route& route) { if (!route.has_direct_response() || !route.direct_response().has_body()) { return EMPTY_STRING; } @@ -129,11 +128,11 @@ std::string ConfigUtility::parseDirectResponseBody(const envoy::api::v2::route:: } Http::Code ConfigUtility::parseClusterNotFoundResponseCode( - const envoy::api::v2::route::RouteAction::ClusterNotFoundResponseCode& code) { + const envoy::api::v2::RouteAction::ClusterNotFoundResponseCode& code) { switch (code) { - case envoy::api::v2::route::RouteAction::SERVICE_UNAVAILABLE: + case envoy::api::v2::RouteAction::SERVICE_UNAVAILABLE: return Http::Code::ServiceUnavailable; - case envoy::api::v2::route::RouteAction::NOT_FOUND: + case envoy::api::v2::RouteAction::NOT_FOUND: return Http::Code::NotFound; default: NOT_IMPLEMENTED; diff --git a/source/common/router/config_utility.h b/source/common/router/config_utility.h index f1f8f4b5c9658..e6cf9edd97f5c 100644 --- a/source/common/router/config_utility.h +++ b/source/common/router/config_utility.h @@ -4,7 +4,6 @@ #include #include -#include "envoy/api/v2/route/route.pb.h" #include "envoy/common/optional.h" #include "envoy/http/codes.h" #include "envoy/json/json_object.h" @@ -17,6 +16,8 @@ #include "common/http/utility.h" #include "common/protobuf/utility.h" +#include "api/rds.pb.h" + namespace Envoy { namespace Router { @@ -29,13 +30,13 @@ class ConfigUtility { // An empty header value allows for matching to be only based on header presence. // Regex is an opt-in. Unless explicitly mentioned, the header values will be used for // exact string matching. - HeaderData(const envoy::api::v2::route::HeaderMatcher& config) + HeaderData(const envoy::api::v2::HeaderMatcher& config) : name_(config.name()), value_(config.value()), is_regex_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, regex, false)), regex_pattern_(is_regex_ ? RegexUtil::parseRegex(value_) : std::regex()) {} HeaderData(const Json::Object& config) : HeaderData([&config] { - envoy::api::v2::route::HeaderMatcher header_matcher; + envoy::api::v2::HeaderMatcher header_matcher; Envoy::Config::RdsJson::translateHeaderMatcher(config, header_matcher); return header_matcher; }()) {} @@ -51,7 +52,7 @@ class ConfigUtility { // equivalent of the QueryParameterMatcher proto in the RDS v2 API. class QueryParameterMatcher { public: - QueryParameterMatcher(const envoy::api::v2::route::QueryParameterMatcher& config) + QueryParameterMatcher(const envoy::api::v2::QueryParameterMatcher& config) : name_(config.name()), value_(config.value()), is_regex_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, regex, false)), regex_pattern_(is_regex_ ? RegexUtil::parseRegex(value_) : std::regex()) {} @@ -101,8 +102,8 @@ class ConfigUtility { * @param code supplies the RedirectResponseCode enum. * @return Returns the Http::Code version of the RedirectResponseCode. */ - static Http::Code parseRedirectResponseCode( - const envoy::api::v2::route::RedirectAction::RedirectResponseCode& code); + static Http::Code + parseRedirectResponseCode(const envoy::api::v2::RedirectAction::RedirectResponseCode& code); /** * Returns the HTTP Status Code enum parsed from the route's redirect or direct_response. @@ -111,7 +112,7 @@ class ConfigUtility { * or the HTTP status code from the route's redirect if specified, * or an empty Option otherwise. */ - static Optional parseDirectResponseCode(const envoy::api::v2::route::Route& route); + static Optional parseDirectResponseCode(const envoy::api::v2::Route& route); /** * Returns the content of the response body to send with direct responses from a route. @@ -121,7 +122,7 @@ class ConfigUtility { * route's direct_response if specified, or an empty string otherwise. * @throw EnvoyException if the route configuration contains an error. */ - static std::string parseDirectResponseBody(const envoy::api::v2::route::Route& route); + static std::string parseDirectResponseBody(const envoy::api::v2::Route& route); /** * Returns the HTTP Status Code enum parsed from proto. @@ -129,7 +130,7 @@ class ConfigUtility { * @return Returns the Http::Code version of the ClusterNotFoundResponseCode enum. */ static Http::Code parseClusterNotFoundResponseCode( - const envoy::api::v2::route::RouteAction::ClusterNotFoundResponseCode& code); + const envoy::api::v2::RouteAction::ClusterNotFoundResponseCode& code); }; } // namespace Router diff --git a/source/common/router/header_parser.h b/source/common/router/header_parser.h index 90cbbbcb6bb56..3985696e2f40f 100644 --- a/source/common/router/header_parser.h +++ b/source/common/router/header_parser.h @@ -4,12 +4,13 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/base.pb.h" #include "envoy/http/header_map.h" #include "common/protobuf/protobuf.h" #include "common/router/header_formatter.h" +#include "api/base.pb.h" + namespace Envoy { namespace Router { diff --git a/source/common/router/rds_impl.cc b/source/common/router/rds_impl.cc index d6897bf5f2473..da2c99383de5e 100644 --- a/source/common/router/rds_impl.cc +++ b/source/common/router/rds_impl.cc @@ -5,8 +5,6 @@ #include #include -#include "envoy/api/v2/route/route.pb.validate.h" - #include "common/common/assert.h" #include "common/config/rds_json.h" #include "common/config/subscription_factory.h" @@ -15,6 +13,7 @@ #include "common/router/config_impl.h" #include "common/router/rds_subscription.h" +#include "api/rds.pb.validate.h" #include "fmt/format.h" namespace Envoy { @@ -37,7 +36,7 @@ RouteConfigProviderSharedPtr RouteConfigProviderUtil::create( } StaticRouteConfigProviderImpl::StaticRouteConfigProviderImpl( - const envoy::api::v2::route::RouteConfiguration& config, Runtime::Loader& runtime, + const envoy::api::v2::RouteConfiguration& config, Runtime::Loader& runtime, Upstream::ClusterManager& cm) : config_(new ConfigImpl(config, runtime, cm, true)) {} @@ -56,24 +55,20 @@ RdsRouteConfigProviderImpl::RdsRouteConfigProviderImpl( route_config_provider_manager_(route_config_provider_manager), manager_identifier_(manager_identifier) { ::Envoy::Config::Utility::checkLocalInfo("rds", local_info); - - // TODO: dummy to force linking the gRPC service proto - envoy::service::discovery::v2::RdsDummy dummy; - ConfigConstSharedPtr initial_config(new NullConfigImpl()); tls_->set([initial_config](Event::Dispatcher&) -> ThreadLocal::ThreadLocalObjectSharedPtr { return std::make_shared(initial_config); }); subscription_ = Envoy::Config::SubscriptionFactory::subscriptionFromConfigSource< - envoy::api::v2::route::RouteConfiguration>( + envoy::api::v2::RouteConfiguration>( rds.config_source(), local_info.node(), dispatcher, cm, random, *scope_, [this, &rds, &dispatcher, &random, - &local_info]() -> Envoy::Config::Subscription* { + &local_info]() -> Envoy::Config::Subscription* { return new RdsSubscription(Envoy::Config::Utility::generateStats(*scope_), rds, cm_, dispatcher, random, local_info); }, - "envoy.service.discovery.v2.RouteDiscoveryService.FetchRoutes", - "envoy.service.discovery.v2.RouteDiscoveryService.StreamRoutes"); + "envoy.api.v2.RouteDiscoveryService.FetchRoutes", + "envoy.api.v2.RouteDiscoveryService.StreamRoutes"); // In V2 we use a Subscription model where the fetch can happen via gRPC, REST, or // local filesystem. If the subscription happens via local filesystem (e.g xds_integration_test), diff --git a/source/common/router/rds_impl.h b/source/common/router/rds_impl.h index 2ae50d9310143..11143a2e75110 100644 --- a/source/common/router/rds_impl.h +++ b/source/common/router/rds_impl.h @@ -5,8 +5,6 @@ #include #include -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" -#include "envoy/api/v2/route/route.pb.h" #include "envoy/config/subscription.h" #include "envoy/http/codes.h" #include "envoy/init/init.h" @@ -14,13 +12,15 @@ #include "envoy/router/rds.h" #include "envoy/router/route_config_provider_manager.h" #include "envoy/server/admin.h" -#include "envoy/service/discovery/v2/rds.pb.h" #include "envoy/singleton/instance.h" #include "envoy/thread_local/thread_local.h" #include "common/common/logger.h" #include "common/protobuf/utility.h" +#include "api/filter/network/http_connection_manager.pb.h" +#include "api/rds.pb.h" + namespace Envoy { namespace Router { @@ -45,7 +45,7 @@ class RouteConfigProviderUtil { */ class StaticRouteConfigProviderImpl : public RouteConfigProvider { public: - StaticRouteConfigProviderImpl(const envoy::api::v2::route::RouteConfiguration& config, + StaticRouteConfigProviderImpl(const envoy::api::v2::RouteConfiguration& config, Runtime::Loader& runtime, Upstream::ClusterManager& cm); // Router::RouteConfigProvider @@ -82,7 +82,7 @@ class RouteConfigProviderManagerImpl; class RdsRouteConfigProviderImpl : public RdsRouteConfigProvider, public Init::Target, - Envoy::Config::SubscriptionCallbacks, + Envoy::Config::SubscriptionCallbacks, Logger::Loggable { public: ~RdsRouteConfigProviderImpl(); @@ -128,8 +128,7 @@ class RdsRouteConfigProviderImpl Runtime::Loader& runtime_; Upstream::ClusterManager& cm_; - std::unique_ptr> - subscription_; + std::unique_ptr> subscription_; ThreadLocal::SlotPtr tls_; std::string cluster_name_; const std::string route_config_name_; @@ -140,7 +139,7 @@ class RdsRouteConfigProviderImpl std::function initialize_callback_; RouteConfigProviderManagerImpl& route_config_provider_manager_; const std::string manager_identifier_; - envoy::api::v2::route::RouteConfiguration route_config_proto_; + envoy::api::v2::RouteConfiguration route_config_proto_; friend class RouteConfigProviderManagerImpl; }; diff --git a/source/common/router/rds_subscription.cc b/source/common/router/rds_subscription.cc index a189c50524336..5d248e94d672a 100644 --- a/source/common/router/rds_subscription.cc +++ b/source/common/router/rds_subscription.cc @@ -45,7 +45,7 @@ void RdsSubscription::parseResponse(const Http::Message& response) { ENVOY_LOG(debug, "rds: parsing response"); const std::string response_body = response.bodyAsString(); Json::ObjectSharedPtr response_json = Json::Factory::loadFromString(response_body); - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; Envoy::Config::RdsJson::translateRouteConfiguration(*response_json, *resources.Add()); resources[0].set_name(route_config_name_); callbacks_->onConfigUpdate(resources); diff --git a/source/common/router/rds_subscription.h b/source/common/router/rds_subscription.h index fa87678626c6c..531d0cec89461 100644 --- a/source/common/router/rds_subscription.h +++ b/source/common/router/rds_subscription.h @@ -3,12 +3,13 @@ #include #include -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" #include "envoy/config/subscription.h" #include "common/common/assert.h" #include "common/http/rest_api_fetcher.h" +#include "api/filter/network/http_connection_manager.pb.h" + namespace Envoy { namespace Router { @@ -16,10 +17,9 @@ namespace Router { * Subscription implementation that reads host information from the v1 REST Route Discovery * Service. */ -class RdsSubscription - : public Http::RestApiFetcher, - public Envoy::Config::Subscription, - Logger::Loggable { +class RdsSubscription : public Http::RestApiFetcher, + public Envoy::Config::Subscription, + Logger::Loggable { public: RdsSubscription(Envoy::Config::SubscriptionStats stats, const envoy::api::v2::filter::network::Rds& rds, Upstream::ClusterManager& cm, @@ -29,8 +29,8 @@ class RdsSubscription private: // Config::Subscription void start(const std::vector& resources, - Envoy::Config::SubscriptionCallbacks& - callbacks) override { + Envoy::Config::SubscriptionCallbacks& callbacks) + override { // We can only handle a single cluster route configuration, it's a design error to ever use this // type of Subscription with more than a single cluster. ASSERT(resources.size() == 1); @@ -57,8 +57,7 @@ class RdsSubscription std::string route_config_name_; std::string version_info_; const LocalInfo::LocalInfo& local_info_; - Envoy::Config::SubscriptionCallbacks* callbacks_ = - nullptr; + Envoy::Config::SubscriptionCallbacks* callbacks_ = nullptr; Envoy::Config::SubscriptionStats stats_; }; diff --git a/source/common/router/router.h b/source/common/router/router.h index 8a7baec703f76..bda04e9923c57 100644 --- a/source/common/router/router.h +++ b/source/common/router/router.h @@ -5,7 +5,6 @@ #include #include -#include "envoy/api/v2/filter/http/router.pb.h" #include "envoy/http/codec.h" #include "envoy/http/codes.h" #include "envoy/http/filter.h" @@ -24,6 +23,8 @@ #include "common/http/utility.h" #include "common/request_info/request_info_impl.h" +#include "api/filter/http/router.pb.h" + namespace Envoy { namespace Router { diff --git a/source/common/router/router_ratelimit.cc b/source/common/router/router_ratelimit.cc index 96810f5bf51d9..aa8cc23f72d0d 100644 --- a/source/common/router/router_ratelimit.cc +++ b/source/common/router/router_ratelimit.cc @@ -64,7 +64,7 @@ bool GenericKeyAction::populateDescriptor(const Router::RouteEntry&, } HeaderValueMatchAction::HeaderValueMatchAction( - const envoy::api::v2::route::RateLimit::Action::HeaderValueMatch& action) + const envoy::api::v2::RateLimit::Action::HeaderValueMatch& action) : descriptor_value_(action.descriptor_value()), expect_match_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(action, expect_match, true)) { for (const auto& header_matcher : action.headers()) { @@ -84,27 +84,27 @@ bool HeaderValueMatchAction::populateDescriptor(const Router::RouteEntry&, } } -RateLimitPolicyEntryImpl::RateLimitPolicyEntryImpl(const envoy::api::v2::route::RateLimit& config) +RateLimitPolicyEntryImpl::RateLimitPolicyEntryImpl(const envoy::api::v2::RateLimit& config) : disable_key_(config.disable_key()), stage_(static_cast(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, stage, 0))) { for (const auto& action : config.actions()) { switch (action.action_specifier_case()) { - case envoy::api::v2::route::RateLimit::Action::kSourceCluster: + case envoy::api::v2::RateLimit::Action::kSourceCluster: actions_.emplace_back(new SourceClusterAction()); break; - case envoy::api::v2::route::RateLimit::Action::kDestinationCluster: + case envoy::api::v2::RateLimit::Action::kDestinationCluster: actions_.emplace_back(new DestinationClusterAction()); break; - case envoy::api::v2::route::RateLimit::Action::kRequestHeaders: + case envoy::api::v2::RateLimit::Action::kRequestHeaders: actions_.emplace_back(new RequestHeadersAction(action.request_headers())); break; - case envoy::api::v2::route::RateLimit::Action::kRemoteAddress: + case envoy::api::v2::RateLimit::Action::kRemoteAddress: actions_.emplace_back(new RemoteAddressAction()); break; - case envoy::api::v2::route::RateLimit::Action::kGenericKey: + case envoy::api::v2::RateLimit::Action::kGenericKey: actions_.emplace_back(new GenericKeyAction(action.generic_key())); break; - case envoy::api::v2::route::RateLimit::Action::kHeaderValueMatch: + case envoy::api::v2::RateLimit::Action::kHeaderValueMatch: actions_.emplace_back(new HeaderValueMatchAction(action.header_value_match())); break; default: @@ -133,7 +133,7 @@ void RateLimitPolicyEntryImpl::populateDescriptors( } RateLimitPolicyImpl::RateLimitPolicyImpl( - const Protobuf::RepeatedPtrField& rate_limits) + const Protobuf::RepeatedPtrField& rate_limits) : rate_limit_entries_reference_(RateLimitPolicyImpl::MAX_STAGE_NUMBER + 1) { for (const auto& rate_limit : rate_limits) { std::unique_ptr rate_limit_policy_entry( diff --git a/source/common/router/router_ratelimit.h b/source/common/router/router_ratelimit.h index a14443dbbd8cb..6e70e81504618 100644 --- a/source/common/router/router_ratelimit.h +++ b/source/common/router/router_ratelimit.h @@ -42,7 +42,7 @@ class DestinationClusterAction : public RateLimitAction { */ class RequestHeadersAction : public RateLimitAction { public: - RequestHeadersAction(const envoy::api::v2::route::RateLimit::Action::RequestHeaders& action) + RequestHeadersAction(const envoy::api::v2::RateLimit::Action::RequestHeaders& action) : header_name_(action.header_name()), descriptor_key_(action.descriptor_key()) {} // Router::RateLimitAction @@ -71,7 +71,7 @@ class RemoteAddressAction : public RateLimitAction { */ class GenericKeyAction : public RateLimitAction { public: - GenericKeyAction(const envoy::api::v2::route::RateLimit::Action::GenericKey& action) + GenericKeyAction(const envoy::api::v2::RateLimit::Action::GenericKey& action) : descriptor_value_(action.descriptor_value()) {} // Router::RateLimitAction @@ -88,7 +88,7 @@ class GenericKeyAction : public RateLimitAction { */ class HeaderValueMatchAction : public RateLimitAction { public: - HeaderValueMatchAction(const envoy::api::v2::route::RateLimit::Action::HeaderValueMatch& action); + HeaderValueMatchAction(const envoy::api::v2::RateLimit::Action::HeaderValueMatch& action); // Router::RateLimitAction bool populateDescriptor(const Router::RouteEntry& route, RateLimit::Descriptor& descriptor, @@ -106,7 +106,7 @@ class HeaderValueMatchAction : public RateLimitAction { */ class RateLimitPolicyEntryImpl : public RateLimitPolicyEntry { public: - RateLimitPolicyEntryImpl(const envoy::api::v2::route::RateLimit& config); + RateLimitPolicyEntryImpl(const envoy::api::v2::RateLimit& config); // Router::RateLimitPolicyEntry uint64_t stage() const override { return stage_; } @@ -127,8 +127,7 @@ class RateLimitPolicyEntryImpl : public RateLimitPolicyEntry { */ class RateLimitPolicyImpl : public RateLimitPolicy { public: - RateLimitPolicyImpl( - const Protobuf::RepeatedPtrField& rate_limits); + RateLimitPolicyImpl(const Protobuf::RepeatedPtrField& rate_limits); // Router::RateLimitPolicy const std::vector>& diff --git a/source/common/ssl/BUILD b/source/common/ssl/BUILD index 6546bb6688b59..e86e5940eae2d 100644 --- a/source/common/ssl/BUILD +++ b/source/common/ssl/BUILD @@ -40,6 +40,7 @@ envoy_cc_library( srcs = ["context_config_impl.cc"], hdrs = ["context_config_impl.h"], external_deps = [ + "envoy_sds", "ssl", ], deps = [ @@ -48,7 +49,6 @@ envoy_cc_library( "//source/common/config:tls_context_json_lib", "//source/common/json:json_loader_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2/auth:cert_cc", ], ) diff --git a/source/common/ssl/context_config_impl.cc b/source/common/ssl/context_config_impl.cc index cc103341e24ca..666adc2771aa5 100644 --- a/source/common/ssl/context_config_impl.cc +++ b/source/common/ssl/context_config_impl.cc @@ -34,7 +34,7 @@ const std::string ContextConfigImpl::DEFAULT_CIPHER_SUITES = const std::string ContextConfigImpl::DEFAULT_ECDH_CURVES = "X25519:P-256"; -ContextConfigImpl::ContextConfigImpl(const envoy::api::v2::auth::CommonTlsContext& config) +ContextConfigImpl::ContextConfigImpl(const envoy::api::v2::CommonTlsContext& config) : alpn_protocols_(RepeatedPtrUtil::join(config.alpn_protocols(), ",")), alt_alpn_protocols_(config.deprecated_v1().alt_alpn_protocols()), cipher_suites_(StringUtil::nonEmptyStringOrDefault( @@ -96,18 +96,19 @@ const std::string ContextConfigImpl::getDataSourcePath(const envoy::api::v2::Dat return source.specifier_case() == envoy::api::v2::DataSource::kFilename ? source.filename() : ""; } -unsigned ContextConfigImpl::tlsVersionFromProto( - const envoy::api::v2::auth::TlsParameters_TlsProtocol& version, unsigned default_version) { +unsigned +ContextConfigImpl::tlsVersionFromProto(const envoy::api::v2::TlsParameters_TlsProtocol& version, + unsigned default_version) { switch (version) { - case envoy::api::v2::auth::TlsParameters::TLS_AUTO: + case envoy::api::v2::TlsParameters::TLS_AUTO: return default_version; - case envoy::api::v2::auth::TlsParameters::TLSv1_0: + case envoy::api::v2::TlsParameters::TLSv1_0: return TLS1_VERSION; - case envoy::api::v2::auth::TlsParameters::TLSv1_1: + case envoy::api::v2::TlsParameters::TLSv1_1: return TLS1_1_VERSION; - case envoy::api::v2::auth::TlsParameters::TLSv1_2: + case envoy::api::v2::TlsParameters::TLSv1_2: return TLS1_2_VERSION; - case envoy::api::v2::auth::TlsParameters::TLSv1_3: + case envoy::api::v2::TlsParameters::TLSv1_3: return TLS1_3_VERSION; default: NOT_IMPLEMENTED; @@ -116,8 +117,7 @@ unsigned ContextConfigImpl::tlsVersionFromProto( NOT_REACHED; } -ClientContextConfigImpl::ClientContextConfigImpl( - const envoy::api::v2::auth::UpstreamTlsContext& config) +ClientContextConfigImpl::ClientContextConfigImpl(const envoy::api::v2::UpstreamTlsContext& config) : ContextConfigImpl(config.common_tls_context()), server_name_indication_(config.sni()) { // TODO(PiotrSikora): Support multiple TLS certificates. ASSERT(config.common_tls_context().tls_certificates().size() <= 1); @@ -125,13 +125,12 @@ ClientContextConfigImpl::ClientContextConfigImpl( ClientContextConfigImpl::ClientContextConfigImpl(const Json::Object& config) : ClientContextConfigImpl([&config] { - envoy::api::v2::auth::UpstreamTlsContext upstream_tls_context; + envoy::api::v2::UpstreamTlsContext upstream_tls_context; Config::TlsContextJson::translateUpstreamTlsContext(config, upstream_tls_context); return upstream_tls_context; }()) {} -ServerContextConfigImpl::ServerContextConfigImpl( - const envoy::api::v2::auth::DownstreamTlsContext& config) +ServerContextConfigImpl::ServerContextConfigImpl(const envoy::api::v2::DownstreamTlsContext& config) : ContextConfigImpl(config.common_tls_context()), require_client_certificate_( PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, require_client_certificate, false)), @@ -139,15 +138,15 @@ ServerContextConfigImpl::ServerContextConfigImpl( std::vector ret; switch (config.session_ticket_keys_type_case()) { - case envoy::api::v2::auth::DownstreamTlsContext::kSessionTicketKeys: + case envoy::api::v2::DownstreamTlsContext::kSessionTicketKeys: for (const auto& datasource : config.session_ticket_keys().keys()) { validateAndAppendKey(ret, readDataSource(datasource, false)); } break; - case envoy::api::v2::auth::DownstreamTlsContext::kSessionTicketKeysSdsSecretConfig: + case envoy::api::v2::DownstreamTlsContext::kSessionTicketKeysSdsSecretConfig: NOT_IMPLEMENTED; break; - case envoy::api::v2::auth::DownstreamTlsContext::SESSION_TICKET_KEYS_TYPE_NOT_SET: + case envoy::api::v2::DownstreamTlsContext::SESSION_TICKET_KEYS_TYPE_NOT_SET: break; default: throw EnvoyException(fmt::format("Unexpected case for oneof session_ticket_keys: {}", @@ -164,7 +163,7 @@ ServerContextConfigImpl::ServerContextConfigImpl( ServerContextConfigImpl::ServerContextConfigImpl(const Json::Object& config) : ServerContextConfigImpl([&config] { - envoy::api::v2::auth::DownstreamTlsContext downstream_tls_context; + envoy::api::v2::DownstreamTlsContext downstream_tls_context; Config::TlsContextJson::translateDownstreamTlsContext(config, downstream_tls_context); return downstream_tls_context; }()) {} diff --git a/source/common/ssl/context_config_impl.h b/source/common/ssl/context_config_impl.h index b0b8308ecbed7..f213b387503bc 100644 --- a/source/common/ssl/context_config_impl.h +++ b/source/common/ssl/context_config_impl.h @@ -3,11 +3,12 @@ #include #include -#include "envoy/api/v2/auth/cert.pb.h" #include "envoy/ssl/context_config.h" #include "common/json/json_loader.h" +#include "api/sds.pb.h" + namespace Envoy { namespace Ssl { @@ -48,16 +49,15 @@ class ContextConfigImpl : public virtual Ssl::ContextConfig { unsigned maxProtocolVersion() const override { return max_protocol_version_; }; protected: - ContextConfigImpl(const envoy::api::v2::auth::CommonTlsContext& config); + ContextConfigImpl(const envoy::api::v2::CommonTlsContext& config); static const std::string readDataSource(const envoy::api::v2::DataSource& source, bool allow_empty); static const std::string getDataSourcePath(const envoy::api::v2::DataSource& source); private: - static unsigned - tlsVersionFromProto(const envoy::api::v2::auth::TlsParameters_TlsProtocol& version, - unsigned default_version); + static unsigned tlsVersionFromProto(const envoy::api::v2::TlsParameters_TlsProtocol& version, + unsigned default_version); static const std::string DEFAULT_CIPHER_SUITES; static const std::string DEFAULT_ECDH_CURVES; @@ -82,7 +82,7 @@ class ContextConfigImpl : public virtual Ssl::ContextConfig { class ClientContextConfigImpl : public ContextConfigImpl, public ClientContextConfig { public: - explicit ClientContextConfigImpl(const envoy::api::v2::auth::UpstreamTlsContext& config); + explicit ClientContextConfigImpl(const envoy::api::v2::UpstreamTlsContext& config); explicit ClientContextConfigImpl(const Json::Object& config); // Ssl::ClientContextConfig @@ -94,7 +94,7 @@ class ClientContextConfigImpl : public ContextConfigImpl, public ClientContextCo class ServerContextConfigImpl : public ContextConfigImpl, public ServerContextConfig { public: - explicit ServerContextConfigImpl(const envoy::api::v2::auth::DownstreamTlsContext& config); + explicit ServerContextConfigImpl(const envoy::api::v2::DownstreamTlsContext& config); explicit ServerContextConfigImpl(const Json::Object& config); // Ssl::ServerContextConfig diff --git a/source/common/stats/BUILD b/source/common/stats/BUILD index 5b1ad32e6fe58..3a9511b4e77e8 100644 --- a/source/common/stats/BUILD +++ b/source/common/stats/BUILD @@ -14,6 +14,7 @@ envoy_cc_library( hdrs = ["stats_impl.h"], external_deps = [ "abseil_strings", + "envoy_stats", ], deps = [ "//include/envoy/common:time_interface", @@ -25,7 +26,6 @@ envoy_cc_library( "//source/common/config:well_known_names", "//source/common/protobuf", "//source/common/singleton:const_singleton", - "@envoy_api//envoy/config/metrics/v2:stats_cc", ], ) @@ -51,6 +51,7 @@ envoy_cc_library( name = "metrics_service_grpc_lib", srcs = ["grpc_metrics_service_impl.cc"], hdrs = ["grpc_metrics_service_impl.h"], + external_deps = ["envoy_metrics"], deps = [ "//include/envoy/grpc:async_client_interface", "//include/envoy/local_info:local_info_interface", @@ -59,7 +60,6 @@ envoy_cc_library( "//include/envoy/upstream:cluster_manager_interface", "//source/common/common:assert_lib", "//source/common/grpc:async_client_lib", - "@envoy_api//envoy/service/metrics/v2:metrics_service_cc", ], ) diff --git a/source/common/stats/grpc_metrics_service_impl.cc b/source/common/stats/grpc_metrics_service_impl.cc index b408a85f9708a..e8f0bc86f5447 100644 --- a/source/common/stats/grpc_metrics_service_impl.cc +++ b/source/common/stats/grpc_metrics_service_impl.cc @@ -42,7 +42,7 @@ GrpcMetricsStreamerImpl::ThreadLocalStreamer::ThreadLocalStreamer( : client_(shared_state->factory_->create()), shared_state_(shared_state) {} void GrpcMetricsStreamerImpl::ThreadLocalStreamer::send( - envoy::service::metrics::v2::StreamMetricsMessage& message) { + envoy::api::v2::StreamMetricsMessage& message) { if (thread_local_stream_ == nullptr) { thread_local_stream_ = std::make_shared(*this); } @@ -50,7 +50,7 @@ void GrpcMetricsStreamerImpl::ThreadLocalStreamer::send( if (thread_local_stream_->stream_ == nullptr) { thread_local_stream_->stream_ = client_->start(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.metrics.v2.MetricsService.StreamMetrics"), + "envoy.api.v2.MetricsService.StreamMetrics"), *thread_local_stream_); auto* identifier = message.mutable_identifier(); *identifier->mutable_node() = shared_state_->local_info_.node(); diff --git a/source/common/stats/grpc_metrics_service_impl.h b/source/common/stats/grpc_metrics_service_impl.h index 47c1b524559f6..4cf823030933e 100644 --- a/source/common/stats/grpc_metrics_service_impl.h +++ b/source/common/stats/grpc_metrics_service_impl.h @@ -7,8 +7,6 @@ #include "envoy/grpc/async_client.h" #include "envoy/local_info/local_info.h" #include "envoy/network/connection.h" -#include "envoy/service/metrics/v2/metrics_service.pb.h" -#include "envoy/service/metrics/v2/metrics_service.pb.validate.h" #include "envoy/singleton/instance.h" #include "envoy/stats/stats.h" #include "envoy/thread_local/thread_local.h" @@ -16,6 +14,9 @@ #include "common/buffer/buffer_impl.h" +#include "api/metrics_service.pb.h" +#include "api/metrics_service.pb.validate.h" + namespace Envoy { namespace Stats { namespace Metrics { @@ -34,7 +35,7 @@ class GrpcMetricsStreamer { * Send Metrics Message. * @param message supplies the metrics to send. */ - virtual void send(envoy::service::metrics::v2::StreamMetricsMessage& message) PURE; + virtual void send(envoy::api::v2::StreamMetricsMessage& message) PURE; }; typedef std::shared_ptr GrpcMetricsStreamerSharedPtr; @@ -49,7 +50,7 @@ class GrpcMetricsStreamerImpl : public Singleton::Instance, public GrpcMetricsSt const LocalInfo::LocalInfo& local_info); // GrpcMetricsStreamer - void send(envoy::service::metrics::v2::StreamMetricsMessage& message) override { + void send(envoy::api::v2::StreamMetricsMessage& message) override { tls_slot_->getTyped().send(message); } @@ -74,14 +75,13 @@ class GrpcMetricsStreamerImpl : public Singleton::Instance, public GrpcMetricsSt * Per-thread stream state. */ struct ThreadLocalStream - : public Grpc::TypedAsyncStreamCallbacks { + : public Grpc::TypedAsyncStreamCallbacks { ThreadLocalStream(ThreadLocalStreamer& parent) : parent_(parent) {} // Grpc::TypedAsyncStreamCallbacks void onCreateInitialMetadata(Http::HeaderMap&) override {} void onReceiveInitialMetadata(Http::HeaderMapPtr&&) override {} - void onReceiveMessage( - std::unique_ptr&&) override {} + void onReceiveMessage(std::unique_ptr&&) override {} void onReceiveTrailingMetadata(Http::HeaderMapPtr&&) override {} void onRemoteClose(Grpc::Status::GrpcStatus status, const std::string& message) override; @@ -96,7 +96,7 @@ class GrpcMetricsStreamerImpl : public Singleton::Instance, public GrpcMetricsSt */ struct ThreadLocalStreamer : public ThreadLocal::ThreadLocalObject { ThreadLocalStreamer(const SharedStateSharedPtr& shared_state); - void send(envoy::service::metrics::v2::StreamMetricsMessage& message); + void send(envoy::api::v2::StreamMetricsMessage& message); Grpc::AsyncClientPtr client_; ThreadLocalStreamSharedPtr thread_local_stream_ = nullptr; @@ -145,7 +145,7 @@ class MetricsServiceSink : public Sink { private: GrpcMetricsStreamerSharedPtr grpc_metrics_streamer_; - envoy::service::metrics::v2::StreamMetricsMessage message_; + envoy::api::v2::StreamMetricsMessage message_; }; } // namespace Metrics diff --git a/source/common/stats/stats_impl.cc b/source/common/stats/stats_impl.cc index 59a56084b7857..fa2a4de0b80f4 100644 --- a/source/common/stats/stats_impl.cc +++ b/source/common/stats/stats_impl.cc @@ -122,8 +122,7 @@ RawStatData* HeapRawStatDataAllocator::alloc(const std::string& name) { return data; } -TagProducerImpl::TagProducerImpl(const envoy::config::metrics::v2::StatsConfig& config) - : TagProducerImpl() { +TagProducerImpl::TagProducerImpl(const envoy::api::v2::StatsConfig& config) : TagProducerImpl() { // To check name conflict. std::unordered_set names; reserveResources(config); @@ -135,14 +134,12 @@ TagProducerImpl::TagProducerImpl(const envoy::config::metrics::v2::StatsConfig& } // If no tag value is found, fallback to default regex to keep backward compatibility. - if (tag_specifier.tag_value_case() == - envoy::config::metrics::v2::TagSpecifier::TAG_VALUE_NOT_SET || - tag_specifier.tag_value_case() == envoy::config::metrics::v2::TagSpecifier::kRegex) { + if (tag_specifier.tag_value_case() == envoy::api::v2::TagSpecifier::TAG_VALUE_NOT_SET || + tag_specifier.tag_value_case() == envoy::api::v2::TagSpecifier::kRegex) { tag_extractors_.emplace_back(Stats::TagExtractorImpl::createTagExtractor( tag_specifier.tag_name(), tag_specifier.regex())); - } else if (tag_specifier.tag_value_case() == - envoy::config::metrics::v2::TagSpecifier::kFixedValue) { + } else if (tag_specifier.tag_value_case() == envoy::api::v2::TagSpecifier::kFixedValue) { default_tags_.emplace_back( Stats::Tag{.name_ = tag_specifier.tag_name(), .value_ = tag_specifier.fixed_value()}); } @@ -160,7 +157,7 @@ std::string TagProducerImpl::produceTags(const std::string& name, std::vector& names) { if (!config.has_use_all_default_tags() || config.use_all_default_tags().value()) { for (const auto& extractor : Config::TagNames::get().name_regex_pairs_) { diff --git a/source/common/stats/stats_impl.h b/source/common/stats/stats_impl.h index f4a7b01145256..905affdc32252 100644 --- a/source/common/stats/stats_impl.h +++ b/source/common/stats/stats_impl.h @@ -12,7 +12,6 @@ #include #include "envoy/common/time.h" -#include "envoy/config/metrics/v2/stats.pb.h" #include "envoy/server/options.h" #include "envoy/stats/stats.h" @@ -21,6 +20,7 @@ #include "common/protobuf/protobuf.h" #include "absl/strings/string_view.h" +#include "api/stats.pb.h" namespace Envoy { namespace Stats { @@ -48,7 +48,7 @@ class TagExtractorImpl : public TagExtractor { class TagProducerImpl : public TagProducer { public: - TagProducerImpl(const envoy::config::metrics::v2::StatsConfig& config); + TagProducerImpl(const envoy::api::v2::StatsConfig& config); TagProducerImpl() {} /** @@ -60,8 +60,8 @@ class TagProducerImpl : public TagProducer { std::string produceTags(const std::string& metric_name, std::vector& tags) const override; private: - void reserveResources(const envoy::config::metrics::v2::StatsConfig& config); - void addDefaultExtractors(const envoy::config::metrics::v2::StatsConfig& config, + void reserveResources(const envoy::api::v2::StatsConfig& config); + void addDefaultExtractors(const envoy::api::v2::StatsConfig& config, std::unordered_set& names); std::vector tag_extractors_; diff --git a/source/common/upstream/BUILD b/source/common/upstream/BUILD index 7d5370da1f8f0..2b9921d3d7518 100644 --- a/source/common/upstream/BUILD +++ b/source/common/upstream/BUILD @@ -13,6 +13,7 @@ envoy_cc_library( name = "cds_api_lib", srcs = ["cds_api_impl.cc"], hdrs = ["cds_api_impl.h"], + external_deps = ["envoy_cds"], deps = [ ":cds_subscription_lib", "//include/envoy/config:subscription_interface", @@ -24,7 +25,6 @@ envoy_cc_library( "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/service/discovery/v2:cds_cc", ], ) @@ -32,6 +32,7 @@ envoy_cc_library( name = "cds_subscription_lib", srcs = ["cds_subscription.cc"], hdrs = ["cds_subscription.h"], + external_deps = ["envoy_cds"], deps = [ "//include/envoy/config:subscription_interface", "//include/envoy/event:dispatcher_interface", @@ -45,7 +46,6 @@ envoy_cc_library( "//source/common/http:rest_api_fetcher_lib", "//source/common/json:config_schemas_lib", "//source/common/json:json_loader_lib", - "@envoy_api//envoy/service/discovery/v2:cds_cc", ], ) @@ -53,6 +53,7 @@ envoy_cc_library( name = "cluster_manager_lib", srcs = ["cluster_manager_impl.cc"], hdrs = ["cluster_manager_impl.h"], + external_deps = ["envoy_base"], deps = [ ":cds_api_lib", ":load_balancer_lib", @@ -82,7 +83,6 @@ envoy_cc_library( "//source/common/protobuf:utility_lib", "//source/common/router:shadow_writer_lib", "//source/common/upstream:upstream_lib", - "@envoy_api//envoy/api/v2:base_cc", ], ) @@ -91,6 +91,7 @@ envoy_cc_library( srcs = ["health_checker_impl.cc"], hdrs = ["health_checker_impl.h"], external_deps = [ + "envoy_health_check", "grpc_health_proto", ], deps = [ @@ -121,7 +122,6 @@ envoy_cc_library( "//source/common/network:filter_lib", "//source/common/protobuf:utility_lib", "//source/common/redis:conn_pool_lib", - "@envoy_api//envoy/api/v2:health_check_cc", ], ) @@ -149,13 +149,13 @@ envoy_cc_library( name = "load_stats_reporter_lib", srcs = ["load_stats_reporter.cc"], hdrs = ["load_stats_reporter.h"], + external_deps = ["envoy_eds"], deps = [ "//include/envoy/event:dispatcher_interface", "//include/envoy/stats:stats_macros", "//include/envoy/upstream:cluster_manager_interface", "//source/common/common:logger_lib", "//source/common/grpc:async_client_lib", - "@envoy_api//envoy/service/load_stats/v2:lrs_cc", ], ) @@ -191,6 +191,7 @@ envoy_cc_library( name = "outlier_detection_lib", srcs = ["outlier_detection_impl.cc"], hdrs = ["outlier_detection_impl.h"], + external_deps = ["envoy_cds"], deps = [ "//include/envoy/access_log:access_log_interface", "//include/envoy/event:dispatcher_interface", @@ -202,7 +203,6 @@ envoy_cc_library( "//source/common/common:utility_lib", "//source/common/http:codes_lib", "//source/common/protobuf", - "@envoy_api//envoy/service/discovery/v2:cds_cc", ], ) @@ -236,6 +236,10 @@ envoy_cc_library( name = "eds_lib", srcs = ["eds.cc"], hdrs = ["eds.h"], + external_deps = [ + "envoy_base", + "envoy_eds", + ], deps = [ ":sds_subscription_lib", ":upstream_includes", @@ -250,9 +254,6 @@ envoy_cc_library( "//source/common/network:resolver_lib", "//source/common/network:utility_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/api/v2:base_cc", - "@envoy_api//envoy/api/v2/endpoint:endpoint_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -260,6 +261,10 @@ envoy_cc_library( name = "sds_subscription_lib", srcs = ["sds_subscription.cc"], hdrs = ["sds_subscription.h"], + external_deps = [ + "envoy_base", + "envoy_eds", + ], deps = [ "//include/envoy/config:subscription_interface", "//source/common/common:assert_lib", @@ -272,9 +277,6 @@ envoy_cc_library( "//source/common/json:json_loader_lib", "//source/common/protobuf", "//source/common/router:router_lib", - "@envoy_api//envoy/api/v2:base_cc", - "@envoy_api//envoy/api/v2/endpoint:endpoint_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -300,6 +302,7 @@ envoy_cc_library( envoy_cc_library( name = "upstream_lib", srcs = ["upstream_impl.cc"], + external_deps = ["envoy_base"], deps = [ ":eds_lib", ":health_checker_lib", @@ -323,13 +326,13 @@ envoy_cc_library( "//source/common/protobuf:utility_lib", "//source/common/ssl:connection_lib", "//source/common/ssl:context_config_lib", - "@envoy_api//envoy/api/v2:base_cc", ], ) envoy_cc_library( name = "upstream_includes", hdrs = ["upstream_impl.h"], + external_deps = ["envoy_base"], deps = [ ":load_balancer_lib", ":outlier_detection_lib", @@ -351,6 +354,5 @@ envoy_cc_library( "//source/common/config:metadata_lib", "//source/common/config:well_known_names", "//source/common/stats:stats_lib", - "@envoy_api//envoy/api/v2:base_cc", ], ) diff --git a/source/common/upstream/cds_api_impl.cc b/source/common/upstream/cds_api_impl.cc index f99516dab94b1..40d17beab257c 100644 --- a/source/common/upstream/cds_api_impl.cc +++ b/source/common/upstream/cds_api_impl.cc @@ -2,8 +2,6 @@ #include -#include "envoy/api/v2/cluster/cluster.pb.validate.h" - #include "common/common/cleanup.h" #include "common/config/resources.h" #include "common/config/subscription_factory.h" @@ -11,6 +9,8 @@ #include "common/protobuf/utility.h" #include "common/upstream/cds_subscription.h" +#include "api/cds.pb.validate.h" + namespace Envoy { namespace Upstream { @@ -29,20 +29,16 @@ CdsApiImpl::CdsApiImpl(const envoy::api::v2::ConfigSource& cds_config, const LocalInfo::LocalInfo& local_info, Stats::Scope& scope) : cm_(cm), scope_(scope.createScope("cluster_manager.cds.")) { Config::Utility::checkLocalInfo("cds", local_info); - - // TODO: dummy to force linking the gRPC service proto - envoy::service::discovery::v2::CdsDummy dummy; - subscription_ = - Config::SubscriptionFactory::subscriptionFromConfigSource( + Config::SubscriptionFactory::subscriptionFromConfigSource( cds_config, local_info.node(), dispatcher, cm, random, *scope_, [this, &cds_config, &eds_config, &cm, &dispatcher, &random, - &local_info]() -> Config::Subscription* { + &local_info]() -> Config::Subscription* { return new CdsSubscription(Config::Utility::generateStats(*scope_), cds_config, eds_config, cm, dispatcher, random, local_info); }, - "envoy.service.discovery.v2.ClusterDiscoveryService.FetchClusters", - "envoy.service.discovery.v2.ClusterDiscoveryService.StreamClusters"); + "envoy.api.v2.ClusterDiscoveryService.FetchClusters", + "envoy.api.v2.ClusterDiscoveryService.StreamClusters"); } void CdsApiImpl::onConfigUpdate(const ResourceVector& resources) { diff --git a/source/common/upstream/cds_api_impl.h b/source/common/upstream/cds_api_impl.h index 2226c89ca1bfe..823f5b7de8f03 100644 --- a/source/common/upstream/cds_api_impl.h +++ b/source/common/upstream/cds_api_impl.h @@ -2,15 +2,15 @@ #include -#include "envoy/api/v2/cluster/cluster.pb.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" #include "envoy/local_info/local_info.h" -#include "envoy/service/discovery/v2/cds.pb.h" #include "envoy/upstream/cluster_manager.h" #include "common/common/logger.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { @@ -18,7 +18,7 @@ namespace Upstream { * CDS API implementation that fetches via Subscription. */ class CdsApiImpl : public CdsApi, - Config::SubscriptionCallbacks, + Config::SubscriptionCallbacks, Logger::Loggable { public: static CdsApiPtr create(const envoy::api::v2::ConfigSource& cds_config, @@ -46,7 +46,7 @@ class CdsApiImpl : public CdsApi, void runInitializeCallbackIfAny(); ClusterManager& cm_; - std::unique_ptr> subscription_; + std::unique_ptr> subscription_; std::function initialize_callback_; Stats::ScopePtr scope_; }; diff --git a/source/common/upstream/cds_subscription.cc b/source/common/upstream/cds_subscription.cc index 67ea980ed4224..2d43b912fa653 100644 --- a/source/common/upstream/cds_subscription.cc +++ b/source/common/upstream/cds_subscription.cc @@ -46,7 +46,7 @@ void CdsSubscription::parseResponse(const Http::Message& response) { response_json->validateSchema(Json::Schema::CDS_SCHEMA); std::vector clusters = response_json->getObjectArray("clusters"); - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; for (const Json::ObjectSharedPtr& cluster : clusters) { Config::CdsJson::translateCluster(*cluster, eds_config_, *resources.Add()); } diff --git a/source/common/upstream/cds_subscription.h b/source/common/upstream/cds_subscription.h index 93a3ac6eb5eca..f0231ad3cb379 100644 --- a/source/common/upstream/cds_subscription.h +++ b/source/common/upstream/cds_subscription.h @@ -2,16 +2,16 @@ #include -#include "envoy/api/v2/cluster/cluster.pb.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" #include "envoy/local_info/local_info.h" -#include "envoy/service/discovery/v2/cds.pb.h" #include "common/common/assert.h" #include "common/common/logger.h" #include "common/http/rest_api_fetcher.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { @@ -20,7 +20,7 @@ namespace Upstream { * Service. */ class CdsSubscription : public Http::RestApiFetcher, - public Config::Subscription, + public Config::Subscription, Logger::Loggable { public: CdsSubscription(Config::SubscriptionStats stats, const envoy::api::v2::ConfigSource& cds_config, @@ -31,7 +31,7 @@ class CdsSubscription : public Http::RestApiFetcher, private: // Config::Subscription void start(const std::vector& resources, - Config::SubscriptionCallbacks& callbacks) override { + Config::SubscriptionCallbacks& callbacks) override { // CDS subscribes to all clusters. ASSERT(resources.empty()); UNREFERENCED_PARAMETER(resources); @@ -56,7 +56,7 @@ class CdsSubscription : public Http::RestApiFetcher, std::string version_info_; const LocalInfo::LocalInfo& local_info_; - Config::SubscriptionCallbacks* callbacks_ = nullptr; + Config::SubscriptionCallbacks* callbacks_ = nullptr; Config::SubscriptionStats stats_; const Optional& eds_config_; }; diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index d13bfd92a0804..f0d1eb337dd20 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -163,7 +163,7 @@ void ClusterManagerInitHelper::setInitializedCb(std::function callback) } } -ClusterManagerImpl::ClusterManagerImpl(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, +ClusterManagerImpl::ClusterManagerImpl(const envoy::api::v2::Bootstrap& bootstrap, ClusterManagerFactory& factory, Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, Runtime::RandomGenerator& random, @@ -200,14 +200,14 @@ ClusterManagerImpl::ClusterManagerImpl(const envoy::config::bootstrap::v2::Boots // the cluster will depend on a non-EDS cluster, so the non-EDS clusters must be loaded first. for (const auto& cluster : bootstrap.static_resources().clusters()) { // First load all the primary clusters. - if (cluster.type() != envoy::api::v2::cluster::Cluster::EDS) { + if (cluster.type() != envoy::api::v2::Cluster::EDS) { loadCluster(cluster, false); } } for (const auto& cluster : bootstrap.static_resources().clusters()) { // Now load all the secondary clusters. - if (cluster.type() == envoy::api::v2::cluster::Cluster::EDS) { + if (cluster.type() == envoy::api::v2::Cluster::EDS) { loadCluster(cluster, false); } } @@ -265,7 +265,7 @@ ClusterManagerImpl::ClusterManagerImpl(const envoy::config::bootstrap::v2::Boots ->create(), primary_dispatcher, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.discovery.v2.AggregatedDiscoveryService.StreamAggregatedResources"))); + "envoy.api.v2.AggregatedDiscoveryService.StreamAggregatedResources"))); } else { ads_mux_.reset(new Config::NullGrpcMuxImpl()); } @@ -337,8 +337,7 @@ void ClusterManagerImpl::onClusterInit(Cluster& cluster) { } } -bool ClusterManagerImpl::addOrUpdatePrimaryCluster( - const envoy::api::v2::cluster::Cluster& cluster) { +bool ClusterManagerImpl::addOrUpdatePrimaryCluster(const envoy::api::v2::Cluster& cluster) { // First we need to see if this new config is new or an update to an existing dynamic cluster. // We don't allow updates to statically configured clusters in the main configuration. const std::string cluster_name = cluster.name(); @@ -403,8 +402,7 @@ bool ClusterManagerImpl::removePrimaryCluster(const std::string& cluster_name) { return true; } -void ClusterManagerImpl::loadCluster(const envoy::api::v2::cluster::Cluster& cluster, - bool added_via_api) { +void ClusterManagerImpl::loadCluster(const envoy::api::v2::Cluster& cluster, bool added_via_api) { ClusterSharedPtr new_cluster = factory_.clusterFromProto(cluster, *this, outlier_event_logger_, added_via_api); @@ -781,8 +779,8 @@ ClusterManagerImpl::ThreadLocalClusterManagerImpl::ClusterEntry::connPool( } ClusterManagerPtr ProdClusterManagerFactory::clusterManagerFromProto( - const envoy::config::bootstrap::v2::Bootstrap& bootstrap, Stats::Store& stats, - ThreadLocal::Instance& tls, Runtime::Loader& runtime, Runtime::RandomGenerator& random, + const envoy::api::v2::Bootstrap& bootstrap, Stats::Store& stats, ThreadLocal::Instance& tls, + Runtime::Loader& runtime, Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, AccessLog::AccessLogManager& log_manager) { return ClusterManagerPtr{new ClusterManagerImpl(bootstrap, *this, stats, tls, runtime, random, local_info, log_manager, primary_dispatcher_)}; @@ -802,7 +800,7 @@ ProdClusterManagerFactory::allocateConnPool(Event::Dispatcher& dispatcher, HostC } ClusterSharedPtr ProdClusterManagerFactory::clusterFromProto( - const envoy::api::v2::cluster::Cluster& cluster, ClusterManager& cm, + const envoy::api::v2::Cluster& cluster, ClusterManager& cm, Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) { return ClusterImplBase::create(cluster, cm, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, random_, primary_dispatcher_, local_info_, diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index acfbd49fee91f..4f95a4a5dd045 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -9,7 +9,6 @@ #include #include -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/http/codes.h" #include "envoy/local_info/local_info.h" #include "envoy/runtime/runtime.h" @@ -22,6 +21,8 @@ #include "common/upstream/load_stats_reporter.h" #include "common/upstream/upstream_impl.h" +#include "api/bootstrap.pb.h" + namespace Envoy { namespace Upstream { @@ -41,17 +42,17 @@ class ProdClusterManagerFactory : public ClusterManagerFactory { local_info_(local_info) {} // Upstream::ClusterManagerFactory - ClusterManagerPtr - clusterManagerFromProto(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, - AccessLog::AccessLogManager& log_manager) override; + ClusterManagerPtr clusterManagerFromProto(const envoy::api::v2::Bootstrap& bootstrap, + Stats::Store& stats, ThreadLocal::Instance& tls, + Runtime::Loader& runtime, + Runtime::RandomGenerator& random, + const LocalInfo::LocalInfo& local_info, + AccessLog::AccessLogManager& log_manager) override; Http::ConnectionPool::InstancePtr allocateConnPool(Event::Dispatcher& dispatcher, HostConstSharedPtr host, ResourcePriority priority, Http::Protocol protocol) override; - ClusterSharedPtr clusterFromProto(const envoy::api::v2::cluster::Cluster& cluster, - ClusterManager& cm, + ClusterSharedPtr clusterFromProto(const envoy::api::v2::Cluster& cluster, ClusterManager& cm, Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) override; CdsApiPtr createCds(const envoy::api::v2::ConfigSource& cds_config, @@ -145,15 +146,14 @@ struct ClusterManagerStats { */ class ClusterManagerImpl : public ClusterManager, Logger::Loggable { public: - ClusterManagerImpl(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - ClusterManagerFactory& factory, Stats::Store& stats, - ThreadLocal::Instance& tls, Runtime::Loader& runtime, + ClusterManagerImpl(const envoy::api::v2::Bootstrap& bootstrap, ClusterManagerFactory& factory, + Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, AccessLog::AccessLogManager& log_manager, Event::Dispatcher& primary_dispatcher); // Upstream::ClusterManager - bool addOrUpdatePrimaryCluster(const envoy::api::v2::cluster::Cluster& cluster) override; + bool addOrUpdatePrimaryCluster(const envoy::api::v2::Cluster& cluster) override; void setInitializedCb(std::function callback) override { init_helper_.setInitializedCb(callback); } @@ -279,7 +279,7 @@ class ClusterManagerImpl : public ClusterManager, Logger::Loggable& hosts_added, diff --git a/source/common/upstream/eds.cc b/source/common/upstream/eds.cc index bfd4f7a322469..6fbed336867d4 100644 --- a/source/common/upstream/eds.cc +++ b/source/common/upstream/eds.cc @@ -1,7 +1,6 @@ #include "common/upstream/eds.h" #include "envoy/common/exception.h" -#include "envoy/service/discovery/v2/eds.pb.validate.h" #include "common/config/metadata.h" #include "common/config/subscription_factory.h" @@ -13,14 +12,14 @@ #include "common/protobuf/utility.h" #include "common/upstream/sds_subscription.h" +#include "api/eds.pb.validate.h" #include "fmt/format.h" namespace Envoy { namespace Upstream { -EdsClusterImpl::EdsClusterImpl(const envoy::api::v2::cluster::Cluster& cluster, - Runtime::Loader& runtime, Stats::Store& stats, - Ssl::ContextManager& ssl_context_manager, +EdsClusterImpl::EdsClusterImpl(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime, + Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, const LocalInfo::LocalInfo& local_info, ClusterManager& cm, Event::Dispatcher& dispatcher, Runtime::RandomGenerator& random, bool added_via_api) @@ -31,20 +30,16 @@ EdsClusterImpl::EdsClusterImpl(const envoy::api::v2::cluster::Cluster& cluster, ? cluster.name() : cluster.eds_cluster_config().service_name()) { Config::Utility::checkLocalInfo("eds", local_info); - - // TODO: dummy to force linking the gRPC service proto - envoy::service::discovery::v2::EdsDummy dummy; - const auto& eds_config = cluster.eds_cluster_config().eds_config(); subscription_ = Config::SubscriptionFactory::subscriptionFromConfigSource< - envoy::service::discovery::v2::ClusterLoadAssignment>( + envoy::api::v2::ClusterLoadAssignment>( eds_config, local_info.node(), dispatcher, cm, random, info_->statsScope(), [this, &eds_config, &cm, &dispatcher, - &random]() -> Config::Subscription* { + &random]() -> Config::Subscription* { return new SdsSubscription(info_->stats(), eds_config, cm, dispatcher, random); }, - "envoy.service.discovery.v2.EndpointDiscoveryService.FetchEndpoints", - "envoy.service.discovery.v2.EndpointDiscoveryService.StreamEndpoints"); + "envoy.api.v2.EndpointDiscoveryService.FetchEndpoints", + "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints"); } void EdsClusterImpl::startPreInit() { subscription_->start({cluster_name_}, *this); } diff --git a/source/common/upstream/eds.h b/source/common/upstream/eds.h index 9fa38d09a372a..0e44ec4c13954 100644 --- a/source/common/upstream/eds.h +++ b/source/common/upstream/eds.h @@ -1,23 +1,23 @@ #pragma once -#include "envoy/api/v2/base.pb.h" #include "envoy/config/subscription.h" #include "envoy/local_info/local_info.h" -#include "envoy/service/discovery/v2/eds.pb.h" #include "common/upstream/upstream_impl.h" +#include "api/base.pb.h" +#include "api/eds.pb.h" + namespace Envoy { namespace Upstream { /** * Cluster implementation that reads host information from the Endpoint Discovery Service. */ -class EdsClusterImpl - : public BaseDynamicClusterImpl, - Config::SubscriptionCallbacks { +class EdsClusterImpl : public BaseDynamicClusterImpl, + Config::SubscriptionCallbacks { public: - EdsClusterImpl(const envoy::api::v2::cluster::Cluster& cluster, Runtime::Loader& runtime, + EdsClusterImpl(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, const LocalInfo::LocalInfo& local_info, ClusterManager& cm, Event::Dispatcher& dispatcher, Runtime::RandomGenerator& random, @@ -39,8 +39,7 @@ class EdsClusterImpl void startPreInit() override; const ClusterManager& cm_; - std::unique_ptr> - subscription_; + std::unique_ptr> subscription_; const LocalInfo::LocalInfo& local_info_; const std::string cluster_name_; }; diff --git a/source/common/upstream/health_checker_impl.h b/source/common/upstream/health_checker_impl.h index b562a59852b81..1f7d5edc5d21c 100644 --- a/source/common/upstream/health_checker_impl.h +++ b/source/common/upstream/health_checker_impl.h @@ -8,7 +8,6 @@ #include #include -#include "envoy/api/v2/health_check.pb.h" #include "envoy/event/timer.h" #include "envoy/grpc/status.h" #include "envoy/http/codec.h" @@ -24,6 +23,7 @@ #include "common/network/filter_impl.h" #include "common/protobuf/protobuf.h" +#include "api/health_check.pb.h" #include "src/proto/grpc/health/v1/health.pb.h" namespace Envoy { diff --git a/source/common/upstream/load_balancer_impl.h b/source/common/upstream/load_balancer_impl.h index 1d4a798ef6dad..4b0fc6f5e3999 100644 --- a/source/common/upstream/load_balancer_impl.h +++ b/source/common/upstream/load_balancer_impl.h @@ -4,11 +4,12 @@ #include #include -#include "envoy/api/v2/cluster/cluster.pb.h" #include "envoy/runtime/runtime.h" #include "envoy/upstream/load_balancer.h" #include "envoy/upstream/upstream.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { @@ -198,7 +199,7 @@ class RandomLoadBalancer : public LoadBalancer, ZoneAwareLoadBalancerBase { */ class LoadBalancerSubsetInfoImpl : public LoadBalancerSubsetInfo { public: - LoadBalancerSubsetInfoImpl(const envoy::api::v2::cluster::Cluster::LbSubsetConfig& subset_config) + LoadBalancerSubsetInfoImpl(const envoy::api::v2::Cluster::LbSubsetConfig& subset_config) : enabled_(!subset_config.subset_selectors().empty()), fallback_policy_(subset_config.fallback_policy()), default_subset_(subset_config.default_subset()) { @@ -212,8 +213,7 @@ class LoadBalancerSubsetInfoImpl : public LoadBalancerSubsetInfo { // Upstream::LoadBalancerSubsetInfo bool isEnabled() const override { return enabled_; } - envoy::api::v2::cluster::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy - fallbackPolicy() const override { + envoy::api::v2::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy fallbackPolicy() const override { return fallback_policy_; } const ProtobufWkt::Struct& defaultSubset() const override { return default_subset_; } @@ -221,7 +221,7 @@ class LoadBalancerSubsetInfoImpl : public LoadBalancerSubsetInfo { private: const bool enabled_; - const envoy::api::v2::cluster::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy fallback_policy_; + const envoy::api::v2::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy fallback_policy_; const ProtobufWkt::Struct default_subset_; std::vector> subset_keys_; }; diff --git a/source/common/upstream/load_stats_reporter.cc b/source/common/upstream/load_stats_reporter.cc index 9d90c88094861..40475df9a2780 100644 --- a/source/common/upstream/load_stats_reporter.cc +++ b/source/common/upstream/load_stats_reporter.cc @@ -13,7 +13,7 @@ LoadStatsReporter::LoadStatsReporter(const envoy::api::v2::Node& node, POOL_COUNTER_PREFIX(scope, "load_reporter."))}, async_client_(std::move(async_client)), service_method_(*Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.load_stats.v2.LoadReportingService.StreamLoadStats")) { + "envoy.api.v2.EndpointDiscoveryService.StreamLoadStats")) { request_.mutable_node()->MergeFrom(node); retry_timer_ = dispatcher.createTimer([this]() -> void { establishNewStream(); }); response_timer_ = dispatcher.createTimer([this]() -> void { sendLoadStatsRequest(); }); @@ -100,7 +100,7 @@ void LoadStatsReporter::onReceiveInitialMetadata(Http::HeaderMapPtr&& metadata) } void LoadStatsReporter::onReceiveMessage( - std::unique_ptr&& message) { + std::unique_ptr&& message) { ENVOY_LOG(debug, "New load report epoch: {}", message->DebugString()); stats_.requests_.inc(); message_ = std::move(message); diff --git a/source/common/upstream/load_stats_reporter.h b/source/common/upstream/load_stats_reporter.h index 03054d64e3831..4630bc68d6c15 100644 --- a/source/common/upstream/load_stats_reporter.h +++ b/source/common/upstream/load_stats_reporter.h @@ -1,13 +1,14 @@ #pragma once #include "envoy/event/dispatcher.h" -#include "envoy/service/load_stats/v2/lrs.pb.h" #include "envoy/stats/stats_macros.h" #include "envoy/upstream/cluster_manager.h" #include "common/common/logger.h" #include "common/grpc/async_client_impl.h" +#include "api/eds.pb.h" + namespace Envoy { namespace Upstream { @@ -28,9 +29,8 @@ struct LoadReporterStats { ALL_LOAD_REPORTER_STATS(GENERATE_COUNTER_STRUCT) }; -class LoadStatsReporter - : Grpc::TypedAsyncStreamCallbacks, - Logger::Loggable { +class LoadStatsReporter : Grpc::TypedAsyncStreamCallbacks, + Logger::Loggable { public: LoadStatsReporter(const envoy::api::v2::Node& node, ClusterManager& cluster_manager, Stats::Scope& scope, Grpc::AsyncClientPtr async_client, @@ -39,8 +39,7 @@ class LoadStatsReporter // Grpc::TypedAsyncStreamCallbacks void onCreateInitialMetadata(Http::HeaderMap& metadata) override; void onReceiveInitialMetadata(Http::HeaderMapPtr&& metadata) override; - void onReceiveMessage( - std::unique_ptr&& message) override; + void onReceiveMessage(std::unique_ptr&& message) override; void onReceiveTrailingMetadata(Http::HeaderMapPtr&& metadata) override; void onRemoteClose(Grpc::Status::GrpcStatus status, const std::string& message) override; @@ -61,8 +60,8 @@ class LoadStatsReporter const Protobuf::MethodDescriptor& service_method_; Event::TimerPtr retry_timer_; Event::TimerPtr response_timer_; - envoy::service::load_stats::v2::LoadStatsRequest request_; - std::unique_ptr message_; + envoy::api::v2::LoadStatsRequest request_; + std::unique_ptr message_; std::vector clusters_; }; diff --git a/source/common/upstream/logical_dns_cluster.cc b/source/common/upstream/logical_dns_cluster.cc index fa5e2469a0967..05b40bf271f29 100644 --- a/source/common/upstream/logical_dns_cluster.cc +++ b/source/common/upstream/logical_dns_cluster.cc @@ -16,7 +16,7 @@ namespace Envoy { namespace Upstream { -LogicalDnsCluster::LogicalDnsCluster(const envoy::api::v2::cluster::Cluster& cluster, +LogicalDnsCluster::LogicalDnsCluster(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, Network::DnsResolverSharedPtr dns_resolver, @@ -35,13 +35,13 @@ LogicalDnsCluster::LogicalDnsCluster(const envoy::api::v2::cluster::Cluster& clu } switch (cluster.dns_lookup_family()) { - case envoy::api::v2::cluster::Cluster::V6_ONLY: + case envoy::api::v2::Cluster::V6_ONLY: dns_lookup_family_ = Network::DnsLookupFamily::V6Only; break; - case envoy::api::v2::cluster::Cluster::V4_ONLY: + case envoy::api::v2::Cluster::V4_ONLY: dns_lookup_family_ = Network::DnsLookupFamily::V4Only; break; - case envoy::api::v2::cluster::Cluster::AUTO: + case envoy::api::v2::Cluster::AUTO: dns_lookup_family_ = Network::DnsLookupFamily::Auto; break; default: diff --git a/source/common/upstream/logical_dns_cluster.h b/source/common/upstream/logical_dns_cluster.h index aa460fb7d0a60..7e73c246bd09c 100644 --- a/source/common/upstream/logical_dns_cluster.h +++ b/source/common/upstream/logical_dns_cluster.h @@ -28,7 +28,7 @@ namespace Upstream { */ class LogicalDnsCluster : public ClusterImplBase { public: - LogicalDnsCluster(const envoy::api::v2::cluster::Cluster& cluster, Runtime::Loader& runtime, + LogicalDnsCluster(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, Network::DnsResolverSharedPtr dns_resolver, ThreadLocal::SlotAllocator& tls, ClusterManager& cm, Event::Dispatcher& dispatcher, bool added_via_api); diff --git a/source/common/upstream/original_dst_cluster.cc b/source/common/upstream/original_dst_cluster.cc index 543f08f094fcf..0c8ae80f7cad3 100644 --- a/source/common/upstream/original_dst_cluster.cc +++ b/source/common/upstream/original_dst_cluster.cc @@ -91,7 +91,7 @@ HostConstSharedPtr OriginalDstCluster::LoadBalancer::chooseHost(LoadBalancerCont return nullptr; } -OriginalDstCluster::OriginalDstCluster(const envoy::api::v2::cluster::Cluster& config, +OriginalDstCluster::OriginalDstCluster(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, ClusterManager& cm, Event::Dispatcher& dispatcher, bool added_via_api) diff --git a/source/common/upstream/original_dst_cluster.h b/source/common/upstream/original_dst_cluster.h index 5954620d6e918..0fcd723b39bf6 100644 --- a/source/common/upstream/original_dst_cluster.h +++ b/source/common/upstream/original_dst_cluster.h @@ -22,7 +22,7 @@ namespace Upstream { */ class OriginalDstCluster : public ClusterImplBase { public: - OriginalDstCluster(const envoy::api::v2::cluster::Cluster& config, Runtime::Loader& runtime, + OriginalDstCluster(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, ClusterManager& cm, Event::Dispatcher& dispatcher, bool added_via_api); diff --git a/source/common/upstream/outlier_detection_impl.cc b/source/common/upstream/outlier_detection_impl.cc index 9eac16f01ca30..ae0708baa5bf7 100644 --- a/source/common/upstream/outlier_detection_impl.cc +++ b/source/common/upstream/outlier_detection_impl.cc @@ -21,8 +21,8 @@ namespace Upstream { namespace Outlier { DetectorSharedPtr DetectorImplFactory::createForCluster( - Cluster& cluster, const envoy::api::v2::cluster::Cluster& cluster_config, - Event::Dispatcher& dispatcher, Runtime::Loader& runtime, EventLoggerSharedPtr event_logger) { + Cluster& cluster, const envoy::api::v2::Cluster& cluster_config, Event::Dispatcher& dispatcher, + Runtime::Loader& runtime, EventLoggerSharedPtr event_logger) { if (cluster_config.has_outlier_detection()) { return DetectorImpl::create(cluster, cluster_config.outlier_detection(), dispatcher, runtime, ProdMonotonicTimeSource::instance_, event_logger); @@ -100,7 +100,7 @@ void DetectorHostMonitorImpl::putResult(Result result) { putHttpResponseCode(enumToInt(http_code)); } -DetectorConfig::DetectorConfig(const envoy::api::v2::cluster::OutlierDetection& config) +DetectorConfig::DetectorConfig(const envoy::api::v2::Cluster::OutlierDetection& config) : interval_ms_(static_cast(PROTOBUF_GET_MS_OR_DEFAULT(config, interval, 10000))), base_ejection_time_ms_( static_cast(PROTOBUF_GET_MS_OR_DEFAULT(config, base_ejection_time, 30000))), @@ -124,7 +124,7 @@ DetectorConfig::DetectorConfig(const envoy::api::v2::cluster::OutlierDetection& PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, enforcing_success_rate, 100))) {} DetectorImpl::DetectorImpl(const Cluster& cluster, - const envoy::api::v2::cluster::OutlierDetection& config, + const envoy::api::v2::Cluster::OutlierDetection& config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, MonotonicTimeSource& time_source, EventLoggerSharedPtr event_logger) : config_(config), dispatcher_(dispatcher), runtime_(runtime), time_source_(time_source), @@ -144,7 +144,7 @@ DetectorImpl::~DetectorImpl() { std::shared_ptr DetectorImpl::create(const Cluster& cluster, - const envoy::api::v2::cluster::OutlierDetection& config, + const envoy::api::v2::Cluster::OutlierDetection& config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, MonotonicTimeSource& time_source, EventLoggerSharedPtr event_logger) { std::shared_ptr detector( diff --git a/source/common/upstream/outlier_detection_impl.h b/source/common/upstream/outlier_detection_impl.h index 4f5e73cf6144b..f93781260cb5e 100644 --- a/source/common/upstream/outlier_detection_impl.h +++ b/source/common/upstream/outlier_detection_impl.h @@ -10,12 +10,13 @@ #include #include "envoy/access_log/access_log.h" -#include "envoy/api/v2/cluster/outlier_detection.pb.h" #include "envoy/event/timer.h" #include "envoy/runtime/runtime.h" #include "envoy/upstream/outlier_detection.h" #include "envoy/upstream/upstream.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { namespace Outlier { @@ -44,7 +45,7 @@ class DetectorHostMonitorNullImpl : public DetectorHostMonitor { class DetectorImplFactory { public: static DetectorSharedPtr createForCluster(Cluster& cluster, - const envoy::api::v2::cluster::Cluster& cluster_config, + const envoy::api::v2::Cluster& cluster_config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, EventLoggerSharedPtr event_logger); }; @@ -170,7 +171,7 @@ struct DetectionStats { */ class DetectorConfig { public: - DetectorConfig(const envoy::api::v2::cluster::OutlierDetection& config); + DetectorConfig(const envoy::api::v2::Cluster::OutlierDetection& config); uint64_t intervalMs() { return interval_ms_; } uint64_t baseEjectionTimeMs() { return base_ejection_time_ms_; } @@ -206,7 +207,7 @@ class DetectorConfig { class DetectorImpl : public Detector, public std::enable_shared_from_this { public: static std::shared_ptr - create(const Cluster& cluster, const envoy::api::v2::cluster::OutlierDetection& config, + create(const Cluster& cluster, const envoy::api::v2::Cluster::OutlierDetection& config, Event::Dispatcher& dispatcher, Runtime::Loader& runtime, MonotonicTimeSource& time_source, EventLoggerSharedPtr event_logger); ~DetectorImpl(); @@ -222,7 +223,7 @@ class DetectorImpl : public Detector, public std::enable_shared_from_this& config) + const Optional& config) : LoadBalancerBase(priority_set, stats, runtime, random), config_(config), factory_(new LoadBalancerFactoryImpl(stats, random)) {} @@ -103,9 +103,8 @@ HostConstSharedPtr RingHashLoadBalancer::Ring::chooseHost(uint64_t h) const { } } -RingHashLoadBalancer::Ring::Ring( - const Optional& config, - const std::vector& hosts) { +RingHashLoadBalancer::Ring::Ring(const Optional& config, + const std::vector& hosts) { ENVOY_LOG(trace, "ring hash: building ring"); if (hosts.empty()) { return; diff --git a/source/common/upstream/ring_hash_lb.h b/source/common/upstream/ring_hash_lb.h index d9220667036cb..24f42a34991e8 100644 --- a/source/common/upstream/ring_hash_lb.h +++ b/source/common/upstream/ring_hash_lb.h @@ -30,7 +30,7 @@ class RingHashLoadBalancer : public LoadBalancerBase, public: RingHashLoadBalancer(PrioritySet& priority_set, ClusterStats& stats, Runtime::Loader& runtime, Runtime::RandomGenerator& random, - const Optional& config); + const Optional& config); // Upstream::ThreadAwareLoadBalancer LoadBalancerFactorySharedPtr factory() override { return factory_; } @@ -43,7 +43,7 @@ class RingHashLoadBalancer : public LoadBalancerBase, }; struct Ring { - Ring(const Optional& config, + Ring(const Optional& config, const std::vector& hosts); HostConstSharedPtr chooseHost(uint64_t hash) const; @@ -90,7 +90,7 @@ class RingHashLoadBalancer : public LoadBalancerBase, void refresh(); - const Optional& config_; + const Optional& config_; std::shared_ptr factory_; }; diff --git a/source/common/upstream/sds_subscription.cc b/source/common/upstream/sds_subscription.cc index 0af0fe7420231..df89f39eb8897 100644 --- a/source/common/upstream/sds_subscription.cc +++ b/source/common/upstream/sds_subscription.cc @@ -4,7 +4,6 @@ #include #include -#include "envoy/api/v2/endpoint/endpoint.pb.h" #include "envoy/common/exception.h" #include "common/config/metadata.h" @@ -15,6 +14,8 @@ #include "common/json/json_loader.h" #include "common/protobuf/protobuf.h" +#include "api/eds.pb.h" + namespace Envoy { namespace Upstream { @@ -41,8 +42,7 @@ void SdsSubscription::parseResponse(const Http::Message& response) { // Since in the v2 EDS API we place all the endpoints for a given zone in the same proto, we first // need to bin the returned hosts list so that we group them by zone. We use an ordered map here // to provide better determinism for debug/test behavior. - std::map> - zone_lb_endpoints; + std::map> zone_lb_endpoints; for (const Json::ObjectSharedPtr& host : json->getObjectArray("hosts")) { bool canary = false; uint32_t weight = 1; @@ -63,7 +63,7 @@ void SdsSubscription::parseResponse(const Http::Message& response) { lb_endpoint->mutable_load_balancing_weight()->set_value(weight); } - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name(cluster_name_); for (auto it : zone_lb_endpoints) { diff --git a/source/common/upstream/sds_subscription.h b/source/common/upstream/sds_subscription.h index 92deee49a84ed..2dfc06cf0a99d 100644 --- a/source/common/upstream/sds_subscription.h +++ b/source/common/upstream/sds_subscription.h @@ -3,13 +3,14 @@ #include #include -#include "envoy/api/v2/base.pb.h" #include "envoy/config/subscription.h" -#include "envoy/service/discovery/v2/eds.pb.h" #include "common/common/assert.h" #include "common/http/rest_api_fetcher.h" +#include "api/base.pb.h" +#include "api/eds.pb.h" + namespace Envoy { namespace Upstream { @@ -17,10 +18,9 @@ namespace Upstream { * Subscription implementation that reads host information from the v1 REST Service Discovery * Service. */ -class SdsSubscription - : public Http::RestApiFetcher, - public Config::Subscription, - Logger::Loggable { +class SdsSubscription : public Http::RestApiFetcher, + public Config::Subscription, + Logger::Loggable { public: SdsSubscription(ClusterStats& stats, const envoy::api::v2::ConfigSource& eds_config, ClusterManager& cm, Event::Dispatcher& dispatcher, @@ -31,9 +31,9 @@ class SdsSubscription private: // Config::Subscription - void start(const std::vector& resources, - Config::SubscriptionCallbacks& - callbacks) override { + void + start(const std::vector& resources, + Config::SubscriptionCallbacks& callbacks) override { // We can only handle a single cluster here, it's a design error to ever use this type of // Subscription with more than a single cluster. ASSERT(resources.size() == 1); @@ -57,8 +57,7 @@ class SdsSubscription std::string cluster_name_; std::string version_info_; - Config::SubscriptionCallbacks* callbacks_ = - nullptr; + Config::SubscriptionCallbacks* callbacks_ = nullptr; ClusterStats& stats_; }; diff --git a/source/common/upstream/subset_lb.cc b/source/common/upstream/subset_lb.cc index fbd8d0adceb7d..1be714526e740 100644 --- a/source/common/upstream/subset_lb.cc +++ b/source/common/upstream/subset_lb.cc @@ -2,7 +2,6 @@ #include -#include "envoy/api/v2/cluster/cluster.pb.h" #include "envoy/runtime/runtime.h" #include "common/common/assert.h" @@ -12,6 +11,8 @@ #include "common/upstream/load_balancer_impl.h" #include "common/upstream/ring_hash_lb.h" +#include "api/cds.pb.h" + namespace Envoy { namespace Upstream { @@ -19,7 +20,7 @@ SubsetLoadBalancer::SubsetLoadBalancer( LoadBalancerType lb_type, PrioritySet& priority_set, const PrioritySet* local_priority_set, ClusterStats& stats, Runtime::Loader& runtime, Runtime::RandomGenerator& random, const LoadBalancerSubsetInfo& subsets, - const Optional& lb_ring_hash_config) + const Optional& lb_ring_hash_config) : lb_type_(lb_type), lb_ring_hash_config_(lb_ring_hash_config), stats_(stats), runtime_(runtime), random_(random), fallback_policy_(subsets.fallbackPolicy()), default_subset_(subsets.defaultSubset()), subset_keys_(subsets.subsetKeys()), @@ -123,13 +124,13 @@ SubsetLoadBalancer::LbSubsetEntryPtr SubsetLoadBalancer::findSubset( void SubsetLoadBalancer::updateFallbackSubset(uint32_t priority, const std::vector& hosts_added, const std::vector& hosts_removed) { - if (fallback_policy_ == envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK) { + if (fallback_policy_ == envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK) { return; } HostPredicate predicate; - if (fallback_policy_ == envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT) { + if (fallback_policy_ == envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT) { predicate = [](const Host&) -> bool { return true; }; } else { predicate = diff --git a/source/common/upstream/subset_lb.h b/source/common/upstream/subset_lb.h index 4d50738845a2c..4e7ea79bff7d9 100644 --- a/source/common/upstream/subset_lb.h +++ b/source/common/upstream/subset_lb.h @@ -24,7 +24,7 @@ class SubsetLoadBalancer : public LoadBalancer, Logger::Loggable& lb_ring_hash_config); + const Optional& lb_ring_hash_config); // Upstream::LoadBalancer HostConstSharedPtr chooseHost(LoadBalancerContext* context) override; @@ -129,12 +129,12 @@ class SubsetLoadBalancer : public LoadBalancer, Logger::Loggable& subset_keys, const Host& host); const LoadBalancerType lb_type_; - const Optional lb_ring_hash_config_; + const Optional lb_ring_hash_config_; ClusterStats& stats_; Runtime::Loader& runtime_; Runtime::RandomGenerator& random_; - const envoy::api::v2::cluster::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy fallback_policy_; + const envoy::api::v2::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy fallback_policy_; const ProtobufWkt::Struct default_subset_; const std::vector> subset_keys_; diff --git a/source/common/upstream/upstream_impl.cc b/source/common/upstream/upstream_impl.cc index 6958b547c0393..27b667e9733e7 100644 --- a/source/common/upstream/upstream_impl.cc +++ b/source/common/upstream/upstream_impl.cc @@ -41,7 +41,7 @@ namespace Upstream { namespace { const Network::Address::InstanceConstSharedPtr -getSourceAddress(const envoy::api::v2::cluster::Cluster& cluster, +getSourceAddress(const envoy::api::v2::Cluster& cluster, const Network::Address::InstanceConstSharedPtr source_address) { // The source address from cluster config takes precedence. if (cluster.upstream_bind_config().has_source_address()) { @@ -91,7 +91,7 @@ ClusterLoadReportStats ClusterInfoImpl::generateLoadReportStats(Stats::Scope& sc return {ALL_CLUSTER_LOAD_REPORT_STATS(POOL_COUNTER(scope))}; } -ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::cluster::Cluster& config, +ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::Cluster& config, const Network::Address::InstanceConstSharedPtr source_address, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, bool added_via_api) @@ -110,8 +110,7 @@ ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::cluster::Cluster& config, resource_managers_(config, runtime, name_), maintenance_mode_runtime_key_(fmt::format("upstream.maintenance_mode.{}", name_)), source_address_(getSourceAddress(config, source_address)), - lb_ring_hash_config_( - envoy::api::v2::cluster::Cluster::RingHashLbConfig(config.ring_hash_lb_config())), + lb_ring_hash_config_(envoy::api::v2::Cluster::RingHashLbConfig(config.ring_hash_lb_config())), ssl_context_manager_(ssl_context_manager), added_via_api_(added_via_api), lb_subset_(LoadBalancerSubsetInfoImpl(config.lb_subset_config())), metadata_(config.metadata()) { @@ -133,20 +132,20 @@ ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::cluster::Cluster& config, transport_socket_factory_ = config_factory.createTransportSocketFactory(*message, *this); switch (config.lb_policy()) { - case envoy::api::v2::cluster::Cluster::ROUND_ROBIN: + case envoy::api::v2::Cluster::ROUND_ROBIN: lb_type_ = LoadBalancerType::RoundRobin; break; - case envoy::api::v2::cluster::Cluster::LEAST_REQUEST: + case envoy::api::v2::Cluster::LEAST_REQUEST: lb_type_ = LoadBalancerType::LeastRequest; break; - case envoy::api::v2::cluster::Cluster::RANDOM: + case envoy::api::v2::Cluster::RANDOM: lb_type_ = LoadBalancerType::Random; break; - case envoy::api::v2::cluster::Cluster::RING_HASH: + case envoy::api::v2::Cluster::RING_HASH: lb_type_ = LoadBalancerType::RingHash; break; - case envoy::api::v2::cluster::Cluster::ORIGINAL_DST_LB: - if (config.type() != envoy::api::v2::cluster::Cluster::ORIGINAL_DST) { + case envoy::api::v2::Cluster::ORIGINAL_DST_LB: + if (config.type() != envoy::api::v2::Cluster::ORIGINAL_DST) { throw EnvoyException(fmt::format( "cluster: LB type 'original_dst_lb' may only be used with cluser type 'original_dst'")); } @@ -156,7 +155,7 @@ ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::cluster::Cluster& config, NOT_REACHED; } - if (config.protocol_selection() == envoy::api::v2::cluster::Cluster::USE_CONFIGURED_PROTOCOL) { + if (config.protocol_selection() == envoy::api::v2::Cluster::USE_CONFIGURED_PROTOCOL) { // Make sure multiple protocol configurations are not present if (config.has_http_protocol_options() && config.has_http2_protocol_options()) { throw EnvoyException(fmt::format("cluster: Both HTTP1 and HTTP2 options may only be " @@ -168,14 +167,15 @@ ClusterInfoImpl::ClusterInfoImpl(const envoy::api::v2::cluster::Cluster& config, const HostListsConstSharedPtr ClusterImplBase::empty_host_lists_{ new std::vector>()}; -ClusterSharedPtr -ClusterImplBase::create(const envoy::api::v2::cluster::Cluster& cluster, ClusterManager& cm, - Stats::Store& stats, ThreadLocal::Instance& tls, - Network::DnsResolverSharedPtr dns_resolver, - Ssl::ContextManager& ssl_context_manager, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, Event::Dispatcher& dispatcher, - const LocalInfo::LocalInfo& local_info, - Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) { +ClusterSharedPtr ClusterImplBase::create(const envoy::api::v2::Cluster& cluster, ClusterManager& cm, + Stats::Store& stats, ThreadLocal::Instance& tls, + Network::DnsResolverSharedPtr dns_resolver, + Ssl::ContextManager& ssl_context_manager, + Runtime::Loader& runtime, Runtime::RandomGenerator& random, + Event::Dispatcher& dispatcher, + const LocalInfo::LocalInfo& local_info, + Outlier::EventLoggerSharedPtr outlier_event_logger, + bool added_via_api) { std::unique_ptr new_cluster; // We make this a shared pointer to deal with the distinct ownership @@ -196,22 +196,22 @@ ClusterImplBase::create(const envoy::api::v2::cluster::Cluster& cluster, Cluster } switch (cluster.type()) { - case envoy::api::v2::cluster::Cluster::STATIC: + case envoy::api::v2::Cluster::STATIC: new_cluster.reset( new StaticClusterImpl(cluster, runtime, stats, ssl_context_manager, cm, added_via_api)); break; - case envoy::api::v2::cluster::Cluster::STRICT_DNS: + case envoy::api::v2::Cluster::STRICT_DNS: new_cluster.reset(new StrictDnsClusterImpl(cluster, runtime, stats, ssl_context_manager, selected_dns_resolver, cm, dispatcher, added_via_api)); break; - case envoy::api::v2::cluster::Cluster::LOGICAL_DNS: + case envoy::api::v2::Cluster::LOGICAL_DNS: new_cluster.reset(new LogicalDnsCluster(cluster, runtime, stats, ssl_context_manager, selected_dns_resolver, tls, cm, dispatcher, added_via_api)); break; - case envoy::api::v2::cluster::Cluster::ORIGINAL_DST: - if (cluster.lb_policy() != envoy::api::v2::cluster::Cluster::ORIGINAL_DST_LB) { + case envoy::api::v2::Cluster::ORIGINAL_DST: + if (cluster.lb_policy() != envoy::api::v2::Cluster::ORIGINAL_DST_LB) { throw EnvoyException(fmt::format( "cluster: cluster type 'original_dst' may only be used with LB type 'original_dst_lb'")); } @@ -222,7 +222,7 @@ ClusterImplBase::create(const envoy::api::v2::cluster::Cluster& cluster, Cluster new_cluster.reset(new OriginalDstCluster(cluster, runtime, stats, ssl_context_manager, cm, dispatcher, added_via_api)); break; - case envoy::api::v2::cluster::Cluster::EDS: + case envoy::api::v2::Cluster::EDS: if (!cluster.has_eds_cluster_config()) { throw EnvoyException("cannot create an sds cluster without an sds config"); } @@ -247,7 +247,7 @@ ClusterImplBase::create(const envoy::api::v2::cluster::Cluster& cluster, Cluster return std::move(new_cluster); } -ClusterImplBase::ClusterImplBase(const envoy::api::v2::cluster::Cluster& cluster, +ClusterImplBase::ClusterImplBase(const envoy::api::v2::Cluster& cluster, const Network::Address::InstanceConstSharedPtr source_address, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, bool added_via_api) @@ -306,12 +306,12 @@ bool ClusterInfoImpl::maintenanceMode() const { return runtime_.snapshot().featureEnabled(maintenance_mode_runtime_key_, 0); } -uint64_t ClusterInfoImpl::parseFeatures(const envoy::api::v2::cluster::Cluster& config) { +uint64_t ClusterInfoImpl::parseFeatures(const envoy::api::v2::Cluster& config) { uint64_t features = 0; if (config.has_http2_protocol_options()) { features |= Features::HTTP2; } - if (config.protocol_selection() == envoy::api::v2::cluster::Cluster::USE_DOWNSTREAM_PROTOCOL) { + if (config.protocol_selection() == envoy::api::v2::Cluster::USE_DOWNSTREAM_PROTOCOL) { features |= Features::USE_DOWNSTREAM_PROTOCOL; } return features; @@ -414,7 +414,7 @@ void ClusterImplBase::reloadHealthyHosts() { } } -ClusterInfoImpl::ResourceManagers::ResourceManagers(const envoy::api::v2::cluster::Cluster& config, +ClusterInfoImpl::ResourceManagers::ResourceManagers(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime, const std::string& cluster_name) { managers_[enumToInt(ResourcePriority::Default)] = @@ -424,7 +424,7 @@ ClusterInfoImpl::ResourceManagers::ResourceManagers(const envoy::api::v2::cluste } ResourceManagerImplPtr -ClusterInfoImpl::ResourceManagers::load(const envoy::api::v2::cluster::Cluster& config, +ClusterInfoImpl::ResourceManagers::load(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime, const std::string& cluster_name, const envoy::api::v2::RoutingPriority& priority) { uint64_t max_connections = 1024; @@ -448,11 +448,11 @@ ClusterInfoImpl::ResourceManagers::load(const envoy::api::v2::cluster::Cluster& fmt::format("circuit_breakers.{}.{}.", cluster_name, priority_name); const auto& thresholds = config.circuit_breakers().thresholds(); - const auto it = std::find_if( - thresholds.cbegin(), thresholds.cend(), - [priority](const envoy::api::v2::cluster::CircuitBreakers::Thresholds& threshold) { - return threshold.priority() == priority; - }); + const auto it = + std::find_if(thresholds.cbegin(), thresholds.cend(), + [priority](const envoy::api::v2::CircuitBreakers::Thresholds& threshold) { + return threshold.priority() == priority; + }); if (it != thresholds.cend()) { max_connections = PROTOBUF_GET_WRAPPED_OR_DEFAULT(*it, max_connections, max_connections); max_pending_requests = @@ -464,7 +464,7 @@ ClusterInfoImpl::ResourceManagers::load(const envoy::api::v2::cluster::Cluster& runtime, runtime_prefix, max_connections, max_pending_requests, max_requests, max_retries)}; } -StaticClusterImpl::StaticClusterImpl(const envoy::api::v2::cluster::Cluster& cluster, +StaticClusterImpl::StaticClusterImpl(const envoy::api::v2::Cluster& cluster, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, ClusterManager& cm, bool added_via_api) @@ -582,7 +582,7 @@ bool BaseDynamicClusterImpl::updateDynamicHostList(const std::vector #include -#include "envoy/api/v2/base.pb.h" #include "envoy/event/timer.h" #include "envoy/local_info/local_info.h" #include "envoy/network/dns.h" @@ -34,6 +33,8 @@ #include "common/upstream/outlier_detection_impl.h" #include "common/upstream/resource_manager_impl.h" +#include "api/base.pb.h" + namespace Envoy { namespace Upstream { @@ -278,7 +279,7 @@ class PrioritySetImpl : public PrioritySet { class ClusterInfoImpl : public ClusterInfo, public Server::Configuration::TransportSocketFactoryContext { public: - ClusterInfoImpl(const envoy::api::v2::cluster::Cluster& config, + ClusterInfoImpl(const envoy::api::v2::Cluster& config, const Network::Address::InstanceConstSharedPtr source_address, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, bool added_via_api); @@ -295,9 +296,8 @@ class ClusterInfoImpl : public ClusterInfo, uint64_t features() const override { return features_; } const Http::Http2Settings& http2Settings() const override { return http2_settings_; } LoadBalancerType lbType() const override { return lb_type_; } - envoy::api::v2::cluster::Cluster::DiscoveryType type() const override { return type_; } - const Optional& - lbRingHashConfig() const override { + envoy::api::v2::Cluster::DiscoveryType type() const override { return type_; } + const Optional& lbRingHashConfig() const override { return lb_ring_hash_config_; } bool maintenanceMode() const override; @@ -321,10 +321,10 @@ class ClusterInfoImpl : public ClusterInfo, private: struct ResourceManagers { - ResourceManagers(const envoy::api::v2::cluster::Cluster& config, Runtime::Loader& runtime, + ResourceManagers(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime, const std::string& cluster_name); - ResourceManagerImplPtr load(const envoy::api::v2::cluster::Cluster& config, - Runtime::Loader& runtime, const std::string& cluster_name, + ResourceManagerImplPtr load(const envoy::api::v2::Cluster& config, Runtime::Loader& runtime, + const std::string& cluster_name, const envoy::api::v2::RoutingPriority& priority); typedef std::array Managers; @@ -332,11 +332,11 @@ class ClusterInfoImpl : public ClusterInfo, Managers managers_; }; - static uint64_t parseFeatures(const envoy::api::v2::cluster::Cluster& config); + static uint64_t parseFeatures(const envoy::api::v2::Cluster& config); Runtime::Loader& runtime_; const std::string name_; - const envoy::api::v2::cluster::Cluster::DiscoveryType type_; + const envoy::api::v2::Cluster::DiscoveryType type_; const uint64_t max_requests_per_connection_; const std::chrono::milliseconds connect_timeout_; const uint32_t per_connection_buffer_limit_bytes_; @@ -351,7 +351,7 @@ class ClusterInfoImpl : public ClusterInfo, const std::string maintenance_mode_runtime_key_; const Network::Address::InstanceConstSharedPtr source_address_; LoadBalancerType lb_type_; - Optional lb_ring_hash_config_; + Optional lb_ring_hash_config_; Ssl::ContextManager& ssl_context_manager_; const bool added_via_api_; LoadBalancerSubsetInfoImpl lb_subset_; @@ -364,13 +364,14 @@ class ClusterInfoImpl : public ClusterInfo, class ClusterImplBase : public Cluster, protected Logger::Loggable { public: - static ClusterSharedPtr - create(const envoy::api::v2::cluster::Cluster& cluster, ClusterManager& cm, Stats::Store& stats, - ThreadLocal::Instance& tls, Network::DnsResolverSharedPtr dns_resolver, - Ssl::ContextManager& ssl_context_manager, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, Event::Dispatcher& dispatcher, - const LocalInfo::LocalInfo& local_info, Outlier::EventLoggerSharedPtr outlier_event_logger, - bool added_via_api); + static ClusterSharedPtr create(const envoy::api::v2::Cluster& cluster, ClusterManager& cm, + Stats::Store& stats, ThreadLocal::Instance& tls, + Network::DnsResolverSharedPtr dns_resolver, + Ssl::ContextManager& ssl_context_manager, Runtime::Loader& runtime, + Runtime::RandomGenerator& random, Event::Dispatcher& dispatcher, + const LocalInfo::LocalInfo& local_info, + Outlier::EventLoggerSharedPtr outlier_event_logger, + bool added_via_api); // From Upstream::Cluster virtual PrioritySet& prioritySet() override { return priority_set_; } virtual const PrioritySet& prioritySet() const override { return priority_set_; } @@ -396,7 +397,7 @@ class ClusterImplBase : public Cluster, protected Logger::Loggable callback) override; protected: - ClusterImplBase(const envoy::api::v2::cluster::Cluster& cluster, + ClusterImplBase(const envoy::api::v2::Cluster& cluster, const Network::Address::InstanceConstSharedPtr source_address, Runtime::Loader& runtime, Stats::Store& stats, Ssl::ContextManager& ssl_context_manager, bool added_via_api); @@ -444,7 +445,7 @@ class ClusterImplBase : public Cluster, protected Logger::Loggable ![LbSubsetMap Diagram](subset_load_balancer_diagram.svg) -Given these `envoy::api::v2::route::Route` entries: +Given these `envoy::api::v2::Route` entries: ``` json "routes": [ diff --git a/source/exe/main_common.cc b/source/exe/main_common.cc index 2b7808b43498b..3ee4a735aad06 100644 --- a/source/exe/main_common.cc +++ b/source/exe/main_common.cc @@ -31,7 +31,7 @@ class ProdComponentFactory : public ComponentFactory { // The global drain manager only triggers on listener modification, which effectively is // hot restart at the global level. The per-listener drain managers decide whether to // to include /healthcheck/fail status. - new DrainManagerImpl(server, envoy::api::v2::listener::Listener_DrainType_MODIFY_ONLY)}; + new DrainManagerImpl(server, envoy::api::v2::Listener_DrainType_MODIFY_ONLY)}; } Runtime::LoaderPtr createRuntime(Server::Instance& server, diff --git a/source/server/BUILD b/source/server/BUILD index eb847e87db6ce..5e73eafb5eae2 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -21,6 +21,11 @@ envoy_cc_library( name = "configuration_lib", srcs = ["configuration_impl.cc"], hdrs = ["configuration_impl.h"], + external_deps = [ + "envoy_bootstrap", + "envoy_lds", + "envoy_trace", + ], deps = [ ":lds_api_lib", "//include/envoy/http:filter_interface", @@ -41,9 +46,6 @@ envoy_cc_library( "//source/common/protobuf:utility_lib", "//source/common/ratelimit:ratelimit_lib", "//source/common/tracing:http_tracer_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", - "@envoy_api//envoy/config/trace/v2:trace_cc", - "@envoy_api//envoy/service/discovery/v2:lds_cc", ], ) @@ -159,6 +161,7 @@ envoy_cc_library( name = "lds_api_lib", srcs = ["lds_api.cc"], hdrs = ["lds_api.h"], + external_deps = ["envoy_lds"], deps = [ ":lds_subscription_lib", "//include/envoy/config:subscription_interface", @@ -169,7 +172,6 @@ envoy_cc_library( "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/service/discovery/v2:lds_cc", ], ) @@ -177,6 +179,7 @@ envoy_cc_library( name = "lds_subscription_lib", srcs = ["lds_subscription.cc"], hdrs = ["lds_subscription.h"], + external_deps = ["envoy_lds"], deps = [ "//include/envoy/config:subscription_interface", "//source/common/common:assert_lib", @@ -185,7 +188,6 @@ envoy_cc_library( "//source/common/http:rest_api_fetcher_lib", "//source/common/json:config_schemas_lib", "//source/common/json:json_validator_lib", - "@envoy_api//envoy/service/discovery/v2:lds_cc", ], ) @@ -193,6 +195,7 @@ envoy_cc_library( name = "listener_manager_lib", srcs = ["listener_manager_impl.cc"], hdrs = ["listener_manager_impl.h"], + external_deps = ["envoy_lds"], deps = [ ":configuration_lib", ":drain_manager_lib", @@ -208,7 +211,6 @@ envoy_cc_library( "//source/common/ssl:context_config_lib", "//source/server/config/listener:original_dst_lib", "//source/server/config/listener:proxy_protocol_lib", - "@envoy_api//envoy/service/discovery/v2:lds_cc", ], ) @@ -216,6 +218,7 @@ envoy_cc_library( name = "server_lib", srcs = ["server.cc"], hdrs = ["server.h"], + external_deps = ["envoy_bootstrap"], deps = [ ":configuration_lib", ":connection_handler_lib", @@ -251,7 +254,6 @@ envoy_cc_library( "//source/common/stats:thread_local_store_lib", "//source/common/upstream:cluster_manager_lib", "//source/server/http:admin_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) diff --git a/source/server/config/access_log/file_access_log.cc b/source/server/config/access_log/file_access_log.cc index 6df08a081ee13..d380a00c5d96f 100644 --- a/source/server/config/access_log/file_access_log.cc +++ b/source/server/config/access_log/file_access_log.cc @@ -1,6 +1,5 @@ #include "server/config/access_log/file_access_log.h" -#include "envoy/api/v2/filter/accesslog/accesslog.pb.validate.h" #include "envoy/registry/registry.h" #include "envoy/server/filter_config.h" @@ -10,6 +9,8 @@ #include "common/config/well_known_names.h" #include "common/protobuf/protobuf.h" +#include "api/filter/accesslog/accesslog.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/access_log/grpc_access_log.cc b/source/server/config/access_log/grpc_access_log.cc index 1adcbc108e65f..9bb28b5faf6c3 100644 --- a/source/server/config/access_log/grpc_access_log.cc +++ b/source/server/config/access_log/grpc_access_log.cc @@ -1,7 +1,5 @@ #include "server/config/access_log/grpc_access_log.h" -#include "envoy/api/v2/filter/accesslog/accesslog.pb.validate.h" -#include "envoy/config/accesslog/v2/als.pb.validate.h" #include "envoy/registry/registry.h" #include "envoy/server/filter_config.h" @@ -11,6 +9,8 @@ #include "common/grpc/async_client_impl.h" #include "common/protobuf/protobuf.h" +#include "api/filter/accesslog/accesslog.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { @@ -21,7 +21,7 @@ SINGLETON_MANAGER_REGISTRATION(grpc_access_log_streamer); AccessLog::InstanceSharedPtr HttpGrpcAccessLogFactory::createAccessLogInstance( const Protobuf::Message& config, AccessLog::FilterPtr&& filter, FactoryContext& context) { const auto& proto_config = MessageUtil::downcastAndValidate< - const envoy::config::accesslog::v2::HttpGrpcAccessLogConfig&>(config); + const envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig&>(config); std::shared_ptr grpc_access_log_streamer = context.singletonManager().getTyped( SINGLETON_MANAGER_REGISTERED_NAME(grpc_access_log_streamer), @@ -37,7 +37,8 @@ AccessLog::InstanceSharedPtr HttpGrpcAccessLogFactory::createAccessLogInstance( } ProtobufTypes::MessagePtr HttpGrpcAccessLogFactory::createEmptyConfigProto() { - return ProtobufTypes::MessagePtr{new envoy::config::accesslog::v2::HttpGrpcAccessLogConfig()}; + return ProtobufTypes::MessagePtr{ + new envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig()}; } std::string HttpGrpcAccessLogFactory::name() const { diff --git a/source/server/config/http/BUILD b/source/server/config/http/BUILD index 809e5709ef0be..842bba28b0e2e 100644 --- a/source/server/config/http/BUILD +++ b/source/server/config/http/BUILD @@ -167,6 +167,7 @@ envoy_cc_library( name = "router_lib", srcs = ["router.cc"], hdrs = ["router.h"], + external_deps = ["envoy_filter_http_router"], deps = [ "//include/envoy/registry", "//include/envoy/server:filter_config_interface", @@ -175,7 +176,6 @@ envoy_cc_library( "//source/common/json:config_schemas_lib", "//source/common/router:router_lib", "//source/common/router:shadow_writer_lib", - "@envoy_api//envoy/api/v2/filter/http:router_cc", ], ) diff --git a/source/server/config/http/buffer.cc b/source/server/config/http/buffer.cc index 241b2ae34c64e..ea2a4309f0c25 100644 --- a/source/server/config/http/buffer.cc +++ b/source/server/config/http/buffer.cc @@ -4,13 +4,14 @@ #include #include -#include "envoy/api/v2/filter/http/buffer.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/http/filter/buffer_filter.h" #include "common/protobuf/utility.h" +#include "api/filter/http/buffer.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/buffer.h b/source/server/config/http/buffer.h index 3359e3f5caa7a..c48bbc4ffb8fb 100644 --- a/source/server/config/http/buffer.h +++ b/source/server/config/http/buffer.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/http/buffer.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/http/buffer.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/fault.cc b/source/server/config/http/fault.cc index 95157366a8341..7d2704c16f60e 100644 --- a/source/server/config/http/fault.cc +++ b/source/server/config/http/fault.cc @@ -1,11 +1,12 @@ #include "server/config/http/fault.h" -#include "envoy/api/v2/filter/http/fault.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/http/filter/fault_filter.h" +#include "api/filter/http/fault.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/fault.h b/source/server/config/http/fault.h index f9f40311c0ddc..7caecc5a66971 100644 --- a/source/server/config/http/fault.h +++ b/source/server/config/http/fault.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/http/fault.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/http/fault.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/grpc_json_transcoder.cc b/source/server/config/http/grpc_json_transcoder.cc index cd03c8869f36c..ba4e85b852845 100644 --- a/source/server/config/http/grpc_json_transcoder.cc +++ b/source/server/config/http/grpc_json_transcoder.cc @@ -1,12 +1,13 @@ #include "server/config/http/grpc_json_transcoder.h" -#include "envoy/api/v2/filter/http/transcoder.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/grpc/json_transcoder_filter.h" #include "common/json/config_schemas.h" +#include "api/filter/http/transcoder.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/grpc_json_transcoder.h b/source/server/config/http/grpc_json_transcoder.h index cf2420db44530..1b2a5eb50bd0a 100644 --- a/source/server/config/http/grpc_json_transcoder.h +++ b/source/server/config/http/grpc_json_transcoder.h @@ -2,13 +2,14 @@ #include -#include "envoy/api/v2/filter/http/transcoder.pb.h" #include "envoy/server/instance.h" #include "common/config/well_known_names.h" #include "server/config/network/http_connection_manager.h" +#include "api/filter/http/transcoder.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/lua.cc b/source/server/config/http/lua.cc index 38d69cbebdeb8..280049b51bc12 100644 --- a/source/server/config/http/lua.cc +++ b/source/server/config/http/lua.cc @@ -1,11 +1,12 @@ #include "server/config/http/lua.h" -#include "envoy/api/v2/filter/http/lua.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/http/filter/lua/lua_filter.h" +#include "api/filter/http/lua.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/lua.h b/source/server/config/http/lua.h index 8c47511e2852d..150b2b53eb1bf 100644 --- a/source/server/config/http/lua.h +++ b/source/server/config/http/lua.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/http/lua.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/http/lua.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/ratelimit.cc b/source/server/config/http/ratelimit.cc index 007d454af8aee..64fb8d7142733 100644 --- a/source/server/config/http/ratelimit.cc +++ b/source/server/config/http/ratelimit.cc @@ -3,13 +3,14 @@ #include #include -#include "envoy/api/v2/filter/http/rate_limit.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/http/filter/ratelimit.h" #include "common/protobuf/utility.h" +#include "api/filter/http/rate_limit.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/ratelimit.h b/source/server/config/http/ratelimit.h index c5ab368e1784b..832afa767dbb0 100644 --- a/source/server/config/http/ratelimit.h +++ b/source/server/config/http/ratelimit.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/http/rate_limit.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/http/rate_limit.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/router.cc b/source/server/config/http/router.cc index 8356478960d1d..585db89ca6cb5 100644 --- a/source/server/config/http/router.cc +++ b/source/server/config/http/router.cc @@ -2,7 +2,6 @@ #include -#include "envoy/api/v2/filter/http/router.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" @@ -10,6 +9,8 @@ #include "common/router/router.h" #include "common/router/shadow_writer_impl.h" +#include "api/filter/http/router.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/http/router.h b/source/server/config/http/router.h index d22a429be698a..fe1459161468e 100644 --- a/source/server/config/http/router.h +++ b/source/server/config/http/router.h @@ -2,12 +2,13 @@ #include -#include "envoy/api/v2/filter/http/router.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" #include "common/protobuf/protobuf.h" +#include "api/filter/http/router.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/BUILD b/source/server/config/network/BUILD index 6f677e2fb8791..949b589c4262b 100644 --- a/source/server/config/network/BUILD +++ b/source/server/config/network/BUILD @@ -107,13 +107,15 @@ envoy_cc_library( name = "tcp_proxy_lib", srcs = ["tcp_proxy.cc"], hdrs = ["tcp_proxy.h"], + external_deps = [ + "envoy_filter_network_tcp_proxy", + ], deps = [ "//include/envoy/registry", "//include/envoy/server:filter_config_interface", "//source/common/config:filter_json_lib", "//source/common/config:well_known_names", "//source/common/filter:tcp_proxy_lib", - "@envoy_api//envoy/api/v2/filter/network:tcp_proxy_cc", ], ) @@ -134,6 +136,9 @@ envoy_cc_library( name = "ssl_socket_lib", srcs = ["ssl_socket.cc"], hdrs = ["ssl_socket.h"], + external_deps = [ + "envoy_sds", + ], deps = [ "//include/envoy/network:transport_socket_interface", "//include/envoy/registry", @@ -141,6 +146,5 @@ envoy_cc_library( "//source/common/config:well_known_names", "//source/common/network:raw_buffer_socket_lib", "//source/common/ssl:connection_lib", - "@envoy_api//envoy/api/v2/auth:cert_cc", ], ) diff --git a/source/server/config/network/client_ssl_auth.cc b/source/server/config/network/client_ssl_auth.cc index bd0b2fb289741..5c3fc46be7ed5 100644 --- a/source/server/config/network/client_ssl_auth.cc +++ b/source/server/config/network/client_ssl_auth.cc @@ -2,13 +2,14 @@ #include -#include "envoy/api/v2/filter/network/client_ssl_auth.pb.validate.h" #include "envoy/network/connection.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/filter/auth/client_ssl.h" +#include "api/filter/network/client_ssl_auth.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/client_ssl_auth.h b/source/server/config/network/client_ssl_auth.h index 9a6abfe7c9739..91c494a5a452e 100644 --- a/source/server/config/network/client_ssl_auth.h +++ b/source/server/config/network/client_ssl_auth.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/network/client_ssl_auth.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/network/client_ssl_auth.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/http_connection_manager.cc b/source/server/config/network/http_connection_manager.cc index 0d9ebf0400b93..c3abdc8a63d59 100644 --- a/source/server/config/network/http_connection_manager.cc +++ b/source/server/config/network/http_connection_manager.cc @@ -5,7 +5,6 @@ #include #include -#include "envoy/api/v2/filter/network/http_connection_manager.pb.validate.h" #include "envoy/filesystem/filesystem.h" #include "envoy/network/connection.h" #include "envoy/registry/registry.h" @@ -24,6 +23,7 @@ #include "common/protobuf/utility.h" #include "common/router/rds_impl.h" +#include "api/filter/network/http_connection_manager.pb.validate.h" #include "fmt/format.h" namespace Envoy { diff --git a/source/server/config/network/mongo_proxy.cc b/source/server/config/network/mongo_proxy.cc index d748585635971..48f5c6f0a24dd 100644 --- a/source/server/config/network/mongo_proxy.cc +++ b/source/server/config/network/mongo_proxy.cc @@ -2,13 +2,13 @@ #include -#include "envoy/api/v2/filter/network/mongo_proxy.pb.validate.h" #include "envoy/network/connection.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/mongo/proxy.h" +#include "api/filter/network/mongo_proxy.pb.validate.h" #include "fmt/format.h" namespace Envoy { diff --git a/source/server/config/network/mongo_proxy.h b/source/server/config/network/mongo_proxy.h index 5183c2fae304c..c05936e90bee9 100644 --- a/source/server/config/network/mongo_proxy.h +++ b/source/server/config/network/mongo_proxy.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/network/mongo_proxy.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/network/mongo_proxy.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/ratelimit.cc b/source/server/config/network/ratelimit.cc index bc950eeb57b04..954e7e478e84c 100644 --- a/source/server/config/network/ratelimit.cc +++ b/source/server/config/network/ratelimit.cc @@ -3,7 +3,6 @@ #include #include -#include "envoy/api/v2/filter/network/rate_limit.pb.validate.h" #include "envoy/network/connection.h" #include "envoy/registry/registry.h" @@ -11,6 +10,8 @@ #include "common/filter/ratelimit.h" #include "common/protobuf/utility.h" +#include "api/filter/network/rate_limit.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/ratelimit.h b/source/server/config/network/ratelimit.h index 9a02a44948f4d..c96de7e93640a 100644 --- a/source/server/config/network/ratelimit.h +++ b/source/server/config/network/ratelimit.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/network/rate_limit.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/network/rate_limit.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/redis_proxy.cc b/source/server/config/network/redis_proxy.cc index 9c240cdfd916e..691d7e4474050 100644 --- a/source/server/config/network/redis_proxy.cc +++ b/source/server/config/network/redis_proxy.cc @@ -3,7 +3,6 @@ #include #include -#include "envoy/api/v2/filter/network/redis_proxy.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" @@ -12,6 +11,8 @@ #include "common/redis/conn_pool_impl.h" #include "common/redis/proxy_filter.h" +#include "api/filter/network/redis_proxy.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/redis_proxy.h b/source/server/config/network/redis_proxy.h index b73bbce6f789b..2c71acbff8ab9 100644 --- a/source/server/config/network/redis_proxy.h +++ b/source/server/config/network/redis_proxy.h @@ -2,11 +2,12 @@ #include -#include "envoy/api/v2/filter/network/redis_proxy.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/network/redis_proxy.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/ssl_socket.cc b/source/server/config/network/ssl_socket.cc index e4916d7392d82..3c043f47e4990 100644 --- a/source/server/config/network/ssl_socket.cc +++ b/source/server/config/network/ssl_socket.cc @@ -1,7 +1,5 @@ #include "server/config/network/ssl_socket.h" -#include "envoy/api/v2/auth/cert.pb.h" -#include "envoy/api/v2/auth/cert.pb.validate.h" #include "envoy/registry/registry.h" #include "common/network/raw_buffer_socket.h" @@ -9,6 +7,9 @@ #include "common/ssl/context_config_impl.h" #include "common/ssl/ssl_socket.h" +#include "api/sds.pb.h" +#include "api/sds.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { @@ -18,13 +19,12 @@ UpstreamSslSocketFactory::createTransportSocketFactory(const Protobuf::Message& TransportSocketFactoryContext& context) { return std::make_unique( Ssl::ClientContextConfigImpl( - MessageUtil::downcastAndValidate( - message)), + MessageUtil::downcastAndValidate(message)), context.sslContextManager(), context.statsScope()); } ProtobufTypes::MessagePtr UpstreamSslSocketFactory::createEmptyConfigProto() { - return std::make_unique(); + return std::make_unique(); } static Registry::RegisterFactory diff --git a/source/server/config/network/tcp_proxy.cc b/source/server/config/network/tcp_proxy.cc index e13976bf5c23a..801fdee6c5573 100644 --- a/source/server/config/network/tcp_proxy.cc +++ b/source/server/config/network/tcp_proxy.cc @@ -2,13 +2,14 @@ #include -#include "envoy/api/v2/filter/network/tcp_proxy.pb.validate.h" #include "envoy/network/connection.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" #include "common/filter/tcp_proxy.h" +#include "api/filter/network/tcp_proxy.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/network/tcp_proxy.h b/source/server/config/network/tcp_proxy.h index 331d0cb2b9c35..cb9da1841fcf2 100644 --- a/source/server/config/network/tcp_proxy.h +++ b/source/server/config/network/tcp_proxy.h @@ -1,10 +1,11 @@ #pragma once -#include "envoy/api/v2/filter/network/tcp_proxy.pb.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/network/tcp_proxy.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/config/stats/BUILD b/source/server/config/stats/BUILD index 5d32031f9b88e..f6c67422ff38e 100644 --- a/source/server/config/stats/BUILD +++ b/source/server/config/stats/BUILD @@ -12,6 +12,9 @@ envoy_cc_library( name = "statsd_lib", srcs = ["statsd.cc"], hdrs = ["statsd.h"], + external_deps = [ + "envoy_stats", + ], deps = [ "//include/envoy/registry", "//source/common/config:well_known_names", @@ -19,7 +22,6 @@ envoy_cc_library( "//source/common/network:resolver_lib", "//source/common/stats:statsd_lib", "//source/server:configuration_lib", - "@envoy_api//envoy/config/metrics/v2:stats_cc", ], ) @@ -27,6 +29,9 @@ envoy_cc_library( name = "dog_statsd_lib", srcs = ["dog_statsd.cc"], hdrs = ["dog_statsd.h"], + external_deps = [ + "envoy_stats", + ], deps = [ "//include/envoy/registry", "//source/common/config:well_known_names", @@ -34,7 +39,6 @@ envoy_cc_library( "//source/common/network:resolver_lib", "//source/common/stats:statsd_lib", "//source/server:configuration_lib", - "@envoy_api//envoy/config/metrics/v2:stats_cc", ], ) @@ -42,12 +46,14 @@ envoy_cc_library( name = "metrics_service_lib", srcs = ["metrics_service.cc"], hdrs = ["metrics_service.h"], + external_deps = [ + "envoy_stats", + "envoy_metrics", + ], deps = [ "//include/envoy/registry", "//source/common/config:well_known_names", "//source/common/stats:metrics_service_grpc_lib", "//source/server:configuration_lib", - "@envoy_api//envoy/config/metrics/v2:stats_cc", - "@envoy_api//envoy/service/metrics/v2:metrics_service_cc", ], ) diff --git a/source/server/config/stats/dog_statsd.cc b/source/server/config/stats/dog_statsd.cc index f7b9436088116..da679c70eb8c6 100644 --- a/source/server/config/stats/dog_statsd.cc +++ b/source/server/config/stats/dog_statsd.cc @@ -2,14 +2,15 @@ #include -#include "envoy/config/metrics/v2/stats.pb.h" -#include "envoy/config/metrics/v2/stats.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/well_known_names.h" #include "common/network/resolver_impl.h" #include "common/stats/statsd.h" +#include "api/stats.pb.h" +#include "api/stats.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { @@ -17,7 +18,7 @@ namespace Configuration { Stats::SinkPtr DogStatsdSinkFactory::createStatsSink(const Protobuf::Message& config, Server::Instance& server) { const auto& sink_config = - MessageUtil::downcastAndValidate(config); + MessageUtil::downcastAndValidate(config); Network::Address::InstanceConstSharedPtr address = Network::Address::resolveProtoAddress(sink_config.address()); ENVOY_LOG(debug, "dog_statsd UDP ip address: {}", address->asString()); @@ -26,8 +27,7 @@ Stats::SinkPtr DogStatsdSinkFactory::createStatsSink(const Protobuf::Message& co } ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { - return std::unique_ptr( - new envoy::config::metrics::v2::DogStatsdSink()); + return std::unique_ptr(new envoy::api::v2::DogStatsdSink()); } std::string DogStatsdSinkFactory::name() { return Config::StatsSinkNames::get().DOG_STATSD; } diff --git a/source/server/config/stats/metrics_service.cc b/source/server/config/stats/metrics_service.cc index 6f9c281a6dc19..a9208568c10ed 100644 --- a/source/server/config/stats/metrics_service.cc +++ b/source/server/config/stats/metrics_service.cc @@ -2,8 +2,6 @@ #include -#include "envoy/config/metrics/v2/metrics_service.pb.h" -#include "envoy/config/metrics/v2/metrics_service.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/well_known_names.h" @@ -11,6 +9,9 @@ #include "common/network/resolver_impl.h" #include "common/stats/grpc_metrics_service_impl.h" +#include "api/metrics_service.pb.h" +#include "api/metrics_service.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { @@ -18,8 +19,7 @@ namespace Configuration { Stats::SinkPtr MetricsServiceSinkFactory::createStatsSink(const Protobuf::Message& config, Server::Instance& server) { const auto& sink_config = - MessageUtil::downcastAndValidate( - config); + MessageUtil::downcastAndValidate(config); const auto& grpc_service = sink_config.grpc_service(); ENVOY_LOG(debug, "Metrics Service gRPC service configuration: {}", grpc_service.DebugString()); @@ -34,8 +34,8 @@ Stats::SinkPtr MetricsServiceSinkFactory::createStatsSink(const Protobuf::Messag } ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() { - return std::unique_ptr( - std::make_unique()); + return std::unique_ptr( + std::make_unique()); } std::string MetricsServiceSinkFactory::name() { diff --git a/source/server/config/stats/statsd.cc b/source/server/config/stats/statsd.cc index b7cd75164daff..13c890048c611 100644 --- a/source/server/config/stats/statsd.cc +++ b/source/server/config/stats/statsd.cc @@ -2,14 +2,15 @@ #include -#include "envoy/config/metrics/v2/stats.pb.h" -#include "envoy/config/metrics/v2/stats.pb.validate.h" #include "envoy/registry/registry.h" #include "common/config/well_known_names.h" #include "common/network/resolver_impl.h" #include "common/stats/statsd.h" +#include "api/stats.pb.h" +#include "api/stats.pb.validate.h" + namespace Envoy { namespace Server { namespace Configuration { @@ -18,9 +19,9 @@ Stats::SinkPtr StatsdSinkFactory::createStatsSink(const Protobuf::Message& confi Server::Instance& server) { const auto& statsd_sink = - MessageUtil::downcastAndValidate(config); + MessageUtil::downcastAndValidate(config); switch (statsd_sink.statsd_specifier_case()) { - case envoy::config::metrics::v2::StatsdSink::kAddress: { + case envoy::api::v2::StatsdSink::kAddress: { Network::Address::InstanceConstSharedPtr address = Network::Address::resolveProtoAddress(statsd_sink.address()); ENVOY_LOG(debug, "statsd UDP ip address: {}", address->asString()); @@ -28,7 +29,7 @@ Stats::SinkPtr StatsdSinkFactory::createStatsSink(const Protobuf::Message& confi new Stats::Statsd::UdpStatsdSink(server.threadLocal(), std::move(address), false)); break; } - case envoy::config::metrics::v2::StatsdSink::kTcpClusterName: + case envoy::api::v2::StatsdSink::kTcpClusterName: ENVOY_LOG(debug, "statsd TCP cluster: {}", statsd_sink.tcp_cluster_name()); return Stats::SinkPtr(new Stats::Statsd::TcpStatsdSink( server.localInfo(), statsd_sink.tcp_cluster_name(), server.threadLocal(), @@ -41,8 +42,7 @@ Stats::SinkPtr StatsdSinkFactory::createStatsSink(const Protobuf::Message& confi } ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { - return std::unique_ptr( - new envoy::config::metrics::v2::StatsdSink()); + return std::unique_ptr(new envoy::api::v2::StatsdSink()); } std::string StatsdSinkFactory::name() { return Config::StatsSinkNames::get().STATSD; } diff --git a/source/server/config_validation/BUILD b/source/server/config_validation/BUILD index 75789426b4a59..d7418ae74a3d7 100644 --- a/source/server/config_validation/BUILD +++ b/source/server/config_validation/BUILD @@ -74,6 +74,7 @@ envoy_cc_library( name = "server_lib", srcs = ["server.cc"], hdrs = ["server.h"], + external_deps = ["envoy_bootstrap"], deps = [ ":admin_lib", ":api_lib", @@ -99,6 +100,5 @@ envoy_cc_library( "//source/server:configuration_lib", "//source/server:server_lib", "//source/server/http:admin_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) diff --git a/source/server/config_validation/cluster_manager.cc b/source/server/config_validation/cluster_manager.cc index 8a202ab56f4aa..d63c1007b6722 100644 --- a/source/server/config_validation/cluster_manager.cc +++ b/source/server/config_validation/cluster_manager.cc @@ -12,8 +12,8 @@ ValidationClusterManagerFactory::ValidationClusterManagerFactory( primary_dispatcher, local_info) {} ClusterManagerPtr ValidationClusterManagerFactory::clusterManagerFromProto( - const envoy::config::bootstrap::v2::Bootstrap& bootstrap, Stats::Store& stats, - ThreadLocal::Instance& tls, Runtime::Loader& runtime, Runtime::RandomGenerator& random, + const envoy::api::v2::Bootstrap& bootstrap, Stats::Store& stats, ThreadLocal::Instance& tls, + Runtime::Loader& runtime, Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, AccessLog::AccessLogManager& log_manager) { return ClusterManagerPtr{new ValidationClusterManager( bootstrap, *this, stats, tls, runtime, random, local_info, log_manager, primary_dispatcher_)}; @@ -30,10 +30,10 @@ ValidationClusterManagerFactory::createCds(const envoy::api::v2::ConfigSource& c } ValidationClusterManager::ValidationClusterManager( - const envoy::config::bootstrap::v2::Bootstrap& bootstrap, ClusterManagerFactory& factory, - Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, - AccessLog::AccessLogManager& log_manager, Event::Dispatcher& primary_dispatcher) + const envoy::api::v2::Bootstrap& bootstrap, ClusterManagerFactory& factory, Stats::Store& stats, + ThreadLocal::Instance& tls, Runtime::Loader& runtime, Runtime::RandomGenerator& random, + const LocalInfo::LocalInfo& local_info, AccessLog::AccessLogManager& log_manager, + Event::Dispatcher& primary_dispatcher) : ClusterManagerImpl(bootstrap, factory, stats, tls, runtime, random, local_info, log_manager, primary_dispatcher) {} diff --git a/source/server/config_validation/cluster_manager.h b/source/server/config_validation/cluster_manager.h index 9ca0cc941754a..b13a1a4847f52 100644 --- a/source/server/config_validation/cluster_manager.h +++ b/source/server/config_validation/cluster_manager.h @@ -22,11 +22,12 @@ class ValidationClusterManagerFactory : public ProdClusterManagerFactory { Event::Dispatcher& primary_dispatcher, const LocalInfo::LocalInfo& local_info); - ClusterManagerPtr - clusterManagerFromProto(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, - AccessLog::AccessLogManager& log_manager) override; + ClusterManagerPtr clusterManagerFromProto(const envoy::api::v2::Bootstrap& bootstrap, + Stats::Store& stats, ThreadLocal::Instance& tls, + Runtime::Loader& runtime, + Runtime::RandomGenerator& random, + const LocalInfo::LocalInfo& local_info, + AccessLog::AccessLogManager& log_manager) override; // Delegates to ProdClusterManagerFactory::createCds, but discards the result and returns nullptr // unconditionally. @@ -40,7 +41,7 @@ class ValidationClusterManagerFactory : public ProdClusterManagerFactory { */ class ValidationClusterManager : public ClusterManagerImpl { public: - ValidationClusterManager(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, + ValidationClusterManager(const envoy::api::v2::Bootstrap& bootstrap, ClusterManagerFactory& factory, Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, diff --git a/source/server/config_validation/server.cc b/source/server/config_validation/server.cc index fad2908ea45cd..13de23bcd9326 100644 --- a/source/server/config_validation/server.cc +++ b/source/server/config_validation/server.cc @@ -1,8 +1,5 @@ #include "server/config_validation/server.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.validate.h" - #include "common/common/version.h" #include "common/config/bootstrap_json.h" #include "common/config/utility.h" @@ -12,6 +9,9 @@ #include "server/configuration_impl.h" +#include "api/bootstrap.pb.h" +#include "api/bootstrap.pb.validate.h" + namespace Envoy { namespace Server { @@ -64,7 +64,7 @@ void ValidationInstance::initialize(Options& options, // If we get all the way through that stripped-down initialization flow, to the point where we'd // be ready to serve, then the config has passed validation. // Handle configuration that needs to take place prior to the main configuration load. - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; InstanceUtil::loadBootstrapConfig(bootstrap, options.configPath(), options.v2ConfigOnly()); Config::Utility::createTagProducer(bootstrap); diff --git a/source/server/config_validation/server.h b/source/server/config_validation/server.h index 1d714f2955dc3..e09ffa24ad405 100644 --- a/source/server/config_validation/server.h +++ b/source/server/config_validation/server.h @@ -89,13 +89,13 @@ class ValidationInstance : Logger::Loggable, const LocalInfo::LocalInfo& localInfo() override { return *local_info_; } // Server::ListenerComponentFactory - std::vector createNetworkFilterFactoryList( - const Protobuf::RepeatedPtrField& filters, - Configuration::FactoryContext& context) override { + std::vector + createNetworkFilterFactoryList(const Protobuf::RepeatedPtrField& filters, + Configuration::FactoryContext& context) override { return ProdListenerComponentFactory::createNetworkFilterFactoryList_(filters, context); } std::vector createListenerFilterFactoryList( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context) override { return ProdListenerComponentFactory::createListenerFilterFactoryList_(filters, context); } @@ -105,7 +105,7 @@ class ValidationInstance : Logger::Loggable, // validation mock. return nullptr; } - DrainManagerPtr createDrainManager(envoy::api::v2::listener::Listener::DrainType) override { + DrainManagerPtr createDrainManager(envoy::api::v2::Listener::DrainType) override { return nullptr; } uint64_t nextListenerTag() override { return 0; } diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index b49d26f7dd1e6..4d3933a777d97 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -6,7 +6,6 @@ #include #include -#include "envoy/config/trace/v2/trace.pb.h" #include "envoy/network/connection.h" #include "envoy/runtime/runtime.h" #include "envoy/server/instance.h" @@ -20,6 +19,8 @@ #include "common/ratelimit/ratelimit_impl.h" #include "common/tracing/http_tracer_impl.h" +#include "api/lds.pb.h" +#include "api/trace.pb.h" #include "fmt/format.h" namespace Envoy { @@ -44,8 +45,7 @@ bool FilterChainUtility::buildFilterChain(Network::ListenerFilterManager& filter return true; } -void MainImpl::initialize(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Instance& server, +void MainImpl::initialize(const envoy::api::v2::Bootstrap& bootstrap, Instance& server, Upstream::ClusterManagerFactory& cluster_manager_factory) { cluster_manager_ = cluster_manager_factory.clusterManagerFromProto( bootstrap, server.stats(), server.threadLocal(), server.runtime(), server.random(), @@ -90,8 +90,7 @@ void MainImpl::initialize(const envoy::config::bootstrap::v2::Bootstrap& bootstr initializeStatsSinks(bootstrap, server); } -void MainImpl::initializeTracers(const envoy::config::trace::v2::Tracing& configuration, - Instance& server) { +void MainImpl::initializeTracers(const envoy::api::v2::Tracing& configuration, Instance& server) { ENVOY_LOG(info, "loading tracing configuration"); if (!configuration.has_http()) { @@ -117,11 +116,10 @@ void MainImpl::initializeTracers(const envoy::config::trace::v2::Tracing& config http_tracer_ = factory.createHttpTracer(*driver_config, server, *cluster_manager_); } -void MainImpl::initializeStatsSinks(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Instance& server) { +void MainImpl::initializeStatsSinks(const envoy::api::v2::Bootstrap& bootstrap, Instance& server) { ENVOY_LOG(info, "loading stats sink configuration"); - for (const envoy::config::metrics::v2::StatsSink& sink_object : bootstrap.stats_sinks()) { + for (const envoy::api::v2::StatsSink& sink_object : bootstrap.stats_sinks()) { // Generate factory and translate stats sink custom config auto& factory = Config::Utility::getAndCheckFactory(sink_object.name()); ProtobufTypes::MessagePtr message = @@ -131,7 +129,7 @@ void MainImpl::initializeStatsSinks(const envoy::config::bootstrap::v2::Bootstra } } -InitialImpl::InitialImpl(const envoy::config::bootstrap::v2::Bootstrap& bootstrap) { +InitialImpl::InitialImpl(const envoy::api::v2::Bootstrap& bootstrap) { const auto& admin = bootstrap.admin(); admin_.access_log_path_ = admin.access_log_path(); admin_.profile_path_ = diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 3adf670e80469..2ba943f429754 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -9,8 +9,6 @@ #include #include -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" -#include "envoy/config/trace/v2/trace.pb.h" #include "envoy/http/filter.h" #include "envoy/network/filter.h" #include "envoy/server/configuration.h" @@ -25,6 +23,9 @@ #include "server/lds_api.h" +#include "api/bootstrap.pb.h" +#include "api/trace.pb.h" + namespace Envoy { namespace Server { namespace Configuration { @@ -120,7 +121,7 @@ class MainImpl : Logger::Loggable, public Main { * @param server supplies the owning server. * @param cluster_manager_factory supplies the cluster manager creation factory. */ - void initialize(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, Instance& server, + void initialize(const envoy::api::v2::Bootstrap& bootstrap, Instance& server, Upstream::ClusterManagerFactory& cluster_manager_factory); // Server::Configuration::Main @@ -142,10 +143,9 @@ class MainImpl : Logger::Loggable, public Main { /** * Initialize tracers and corresponding sinks. */ - void initializeTracers(const envoy::config::trace::v2::Tracing& configuration, Instance& server); + void initializeTracers(const envoy::api::v2::Tracing& configuration, Instance& server); - void initializeStatsSinks(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Instance& server); + void initializeStatsSinks(const envoy::api::v2::Bootstrap& bootstrap, Instance& server); std::unique_ptr cluster_manager_; std::unique_ptr lds_api_; @@ -164,7 +164,7 @@ class MainImpl : Logger::Loggable, public Main { */ class InitialImpl : public Initial { public: - InitialImpl(const envoy::config::bootstrap::v2::Bootstrap& bootstrap); + InitialImpl(const envoy::api::v2::Bootstrap& bootstrap); // Server::Configuration::Initial Admin& admin() override { return admin_; } diff --git a/source/server/drain_manager_impl.cc b/source/server/drain_manager_impl.cc index 799e049eb0b36..2e5c468b25881 100644 --- a/source/server/drain_manager_impl.cc +++ b/source/server/drain_manager_impl.cc @@ -14,8 +14,7 @@ namespace Envoy { namespace Server { -DrainManagerImpl::DrainManagerImpl(Instance& server, - envoy::api::v2::listener::Listener::DrainType drain_type) +DrainManagerImpl::DrainManagerImpl(Instance& server, envoy::api::v2::Listener::DrainType drain_type) : server_(server), drain_type_(drain_type) {} bool DrainManagerImpl::drainClose() const { @@ -25,8 +24,7 @@ bool DrainManagerImpl::drainClose() const { // if even in the case of server health check failure we had some period of drain ramp up. This // would allow the other side to fail health check for the host which will require some thread // jumps versus immediately start GOAWAY/connection thrashing. - if (drain_type_ == envoy::api::v2::listener::Listener_DrainType_DEFAULT && - server_.healthCheckFailed()) { + if (drain_type_ == envoy::api::v2::Listener_DrainType_DEFAULT && server_.healthCheckFailed()) { return true; } diff --git a/source/server/drain_manager_impl.h b/source/server/drain_manager_impl.h index edb79ec454938..4182edb9e8437 100644 --- a/source/server/drain_manager_impl.h +++ b/source/server/drain_manager_impl.h @@ -19,7 +19,7 @@ namespace Server { */ class DrainManagerImpl : Logger::Loggable, public DrainManager { public: - DrainManagerImpl(Instance& server, envoy::api::v2::listener::Listener::DrainType drain_type); + DrainManagerImpl(Instance& server, envoy::api::v2::Listener::DrainType drain_type); // Server::DrainManager bool drainClose() const override; @@ -31,7 +31,7 @@ class DrainManagerImpl : Logger::Loggable, public DrainManager void drainSequenceTick(); Instance& server_; - const envoy::api::v2::listener::Listener::DrainType drain_type_; + const envoy::api::v2::Listener::DrainType drain_type_; Event::TimerPtr drain_tick_timer_; std::atomic drain_time_completed_{}; Event::TimerPtr parent_shutdown_timer_; diff --git a/source/server/http/BUILD b/source/server/http/BUILD index 88988cc11c348..cf9e834745c3d 100644 --- a/source/server/http/BUILD +++ b/source/server/http/BUILD @@ -55,6 +55,7 @@ envoy_cc_library( name = "health_check_lib", srcs = ["health_check.cc"], hdrs = ["health_check.h"], + external_deps = ["envoy_filter_http_health_check"], deps = [ "//include/envoy/event:dispatcher_interface", "//include/envoy/event:timer_interface", @@ -71,6 +72,5 @@ envoy_cc_library( "//source/common/http:utility_lib", "//source/common/protobuf:utility_lib", "//source/server/config/network:http_connection_manager_lib", - "@envoy_api//envoy/api/v2/filter/http:health_check_cc", ], ) diff --git a/source/server/http/health_check.h b/source/server/http/health_check.h index e93b4ac61ab7b..a8f65dcd2dde2 100644 --- a/source/server/http/health_check.h +++ b/source/server/http/health_check.h @@ -5,13 +5,14 @@ #include #include -#include "envoy/api/v2/filter/http/health_check.pb.h" #include "envoy/http/codes.h" #include "envoy/http/filter.h" #include "envoy/server/filter_config.h" #include "common/config/well_known_names.h" +#include "api/filter/http/health_check.pb.h" + namespace Envoy { namespace Server { namespace Configuration { diff --git a/source/server/lds_api.cc b/source/server/lds_api.cc index 080e3e054ab56..0031240b8ef75 100644 --- a/source/server/lds_api.cc +++ b/source/server/lds_api.cc @@ -2,8 +2,6 @@ #include -#include "envoy/api/v2/listener/listener.pb.validate.h" - #include "common/common/cleanup.h" #include "common/config/resources.h" #include "common/config/subscription_factory.h" @@ -12,6 +10,8 @@ #include "server/lds_subscription.h" +#include "api/lds.pb.validate.h" + namespace Envoy { namespace Server { @@ -20,19 +20,16 @@ LdsApi::LdsApi(const envoy::api::v2::ConfigSource& lds_config, Upstream::Cluster Init::Manager& init_manager, const LocalInfo::LocalInfo& local_info, Stats::Scope& scope, ListenerManager& lm) : listener_manager_(lm), scope_(scope.createScope("listener_manager.lds.")), cm_(cm) { - // TODO: dummy to force linking the gRPC service proto - envoy::service::discovery::v2::LdsDummy dummy; - - subscription_ = Envoy::Config::SubscriptionFactory::subscriptionFromConfigSource< - envoy::api::v2::listener::Listener>( - lds_config, local_info.node(), dispatcher, cm, random, *scope_, - [this, &lds_config, &cm, &dispatcher, &random, - &local_info]() -> Config::Subscription* { - return new LdsSubscription(Config::Utility::generateStats(*scope_), lds_config, cm, - dispatcher, random, local_info); - }, - "envoy.service.discovery.v2.ListenerDiscoveryService.FetchListeners", - "envoy.service.discovery.v2.ListenerDiscoveryService.StreamListeners"); + subscription_ = + Envoy::Config::SubscriptionFactory::subscriptionFromConfigSource( + lds_config, local_info.node(), dispatcher, cm, random, *scope_, + [this, &lds_config, &cm, &dispatcher, &random, + &local_info]() -> Config::Subscription* { + return new LdsSubscription(Config::Utility::generateStats(*scope_), lds_config, cm, + dispatcher, random, local_info); + }, + "envoy.api.v2.ListenerDiscoveryService.FetchListeners", + "envoy.api.v2.ListenerDiscoveryService.StreamListeners"); Config::Utility::checkLocalInfo("lds", local_info); init_manager.registerTarget(*this); } diff --git a/source/server/lds_api.h b/source/server/lds_api.h index 683e9672af233..6a2f78754cad5 100644 --- a/source/server/lds_api.h +++ b/source/server/lds_api.h @@ -5,10 +5,11 @@ #include "envoy/config/subscription.h" #include "envoy/init/init.h" #include "envoy/server/listener_manager.h" -#include "envoy/service/discovery/v2/lds.pb.h" #include "common/common/logger.h" +#include "api/lds.pb.h" + namespace Envoy { namespace Server { @@ -16,7 +17,7 @@ namespace Server { * LDS API implementation that fetches via Subscription. */ class LdsApi : public Init::Target, - Config::SubscriptionCallbacks, + Config::SubscriptionCallbacks, Logger::Loggable { public: LdsApi(const envoy::api::v2::ConfigSource& lds_config, Upstream::ClusterManager& cm, @@ -36,7 +37,7 @@ class LdsApi : public Init::Target, private: void runInitializeCallbackIfAny(); - std::unique_ptr> subscription_; + std::unique_ptr> subscription_; ListenerManager& listener_manager_; Stats::ScopePtr scope_; Upstream::ClusterManager& cm_; diff --git a/source/server/lds_subscription.cc b/source/server/lds_subscription.cc index 643cfc7f8c8c7..b3a3fce705786 100644 --- a/source/server/lds_subscription.cc +++ b/source/server/lds_subscription.cc @@ -1,13 +1,12 @@ #include "server/lds_subscription.h" -#include "envoy/api/v2/listener/listener.pb.h" - #include "common/config/lds_json.h" #include "common/config/utility.h" #include "common/http/headers.h" #include "common/json/config_schemas.h" #include "common/json/json_loader.h" +#include "api/lds.pb.h" #include "fmt/format.h" namespace Envoy { @@ -47,7 +46,7 @@ void LdsSubscription::parseResponse(const Http::Message& response) { response_json->validateSchema(Json::Schema::LDS_SCHEMA); std::vector json_listeners = response_json->getObjectArray("listeners"); - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; for (const Json::ObjectSharedPtr& json_listener : json_listeners) { Config::LdsJson::translateListener(*json_listener, *resources.Add()); } diff --git a/source/server/lds_subscription.h b/source/server/lds_subscription.h index 5c4e9001073ea..de523df6ab81c 100644 --- a/source/server/lds_subscription.h +++ b/source/server/lds_subscription.h @@ -1,14 +1,14 @@ #pragma once -#include "envoy/api/v2/listener/listener.pb.h" #include "envoy/config/subscription.h" -#include "envoy/service/discovery/v2/lds.pb.h" #include "common/common/assert.h" #include "common/common/logger.h" #include "common/http/rest_api_fetcher.h" #include "common/json/json_validator.h" +#include "api/lds.pb.h" + namespace Envoy { namespace Server { @@ -17,7 +17,7 @@ namespace Server { * Service. */ class LdsSubscription : public Http::RestApiFetcher, - public Config::Subscription, + public Config::Subscription, Logger::Loggable { public: LdsSubscription(Config::SubscriptionStats stats, const envoy::api::v2::ConfigSource& lds_config, @@ -26,9 +26,8 @@ class LdsSubscription : public Http::RestApiFetcher, private: // Config::Subscription - void - start(const std::vector& resources, - Config::SubscriptionCallbacks& callbacks) override { + void start(const std::vector& resources, + Config::SubscriptionCallbacks& callbacks) override { // LDS subscribes to all clusters. ASSERT(resources.empty()); UNREFERENCED_PARAMETER(resources); @@ -53,7 +52,7 @@ class LdsSubscription : public Http::RestApiFetcher, std::string version_info_; const LocalInfo::LocalInfo& local_info_; - Config::SubscriptionCallbacks* callbacks_ = nullptr; + Config::SubscriptionCallbacks* callbacks_ = nullptr; Config::SubscriptionStats stats_; }; diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 9883f97498b4f..26d2f4982fb3a 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -20,7 +20,7 @@ namespace Server { std::vector ProdListenerComponentFactory::createNetworkFilterFactoryList_( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context) { std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { @@ -51,7 +51,7 @@ ProdListenerComponentFactory::createNetworkFilterFactoryList_( std::vector ProdListenerComponentFactory::createListenerFilterFactoryList_( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context) { std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { @@ -91,14 +91,14 @@ ProdListenerComponentFactory::createListenSocket(Network::Address::InstanceConst } } -DrainManagerPtr ProdListenerComponentFactory::createDrainManager( - envoy::api::v2::listener::Listener::DrainType drain_type) { +DrainManagerPtr +ProdListenerComponentFactory::createDrainManager(envoy::api::v2::Listener::DrainType drain_type) { return DrainManagerPtr{new DrainManagerImpl(server_, drain_type)}; } -ListenerImpl::ListenerImpl(const envoy::api::v2::listener::Listener& config, - ListenerManagerImpl& parent, const std::string& name, bool modifiable, - bool workers_started, uint64_t hash) +ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, ListenerManagerImpl& parent, + const std::string& name, bool modifiable, bool workers_started, + uint64_t hash) : parent_(parent), // TODO(htuch): Validate not pipe when doing v2. address_( @@ -262,7 +262,7 @@ ListenerManagerStats ListenerManagerImpl::generateStats(Stats::Scope& scope) { POOL_GAUGE_PREFIX(scope, final_prefix))}; } -bool ListenerManagerImpl::addOrUpdateListener(const envoy::api::v2::listener::Listener& config, +bool ListenerManagerImpl::addOrUpdateListener(const envoy::api::v2::Listener& config, bool modifiable) { std::string name; if (!config.name().empty()) { diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index 4b7dcd6bff6a1..b8d638b01a258 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -1,6 +1,5 @@ #pragma once -#include "envoy/api/v2/listener/listener.pb.h" #include "envoy/server/filter_config.h" #include "envoy/server/instance.h" #include "envoy/server/listener_manager.h" @@ -10,6 +9,8 @@ #include "server/init_manager_impl.h" +#include "api/lds.pb.h" + namespace Envoy { namespace Server { @@ -26,32 +27,31 @@ class ProdListenerComponentFactory : public ListenerComponentFactory, /** * Static worker for createNetworkFilterFactoryList() that can be used directly in tests. */ - static std::vector createNetworkFilterFactoryList_( - const Protobuf::RepeatedPtrField& filters, - Configuration::FactoryContext& context); + static std::vector + createNetworkFilterFactoryList_(const Protobuf::RepeatedPtrField& filters, + Configuration::FactoryContext& context); /** * Static worker for createListenerFilterFactoryList() that can be used directly in tests. */ static std::vector createListenerFilterFactoryList_( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context); // Server::ListenerComponentFactory - std::vector createNetworkFilterFactoryList( - const Protobuf::RepeatedPtrField& filters, - Configuration::FactoryContext& context) override { + std::vector + createNetworkFilterFactoryList(const Protobuf::RepeatedPtrField& filters, + Configuration::FactoryContext& context) override { return createNetworkFilterFactoryList_(filters, context); } std::vector createListenerFilterFactoryList( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context) override { return createListenerFilterFactoryList_(filters, context); } Network::ListenSocketSharedPtr createListenSocket(Network::Address::InstanceConstSharedPtr address, bool bind_to_port) override; - DrainManagerPtr - createDrainManager(envoy::api::v2::listener::Listener::DrainType drain_type) override; + DrainManagerPtr createDrainManager(envoy::api::v2::Listener::DrainType drain_type) override; uint64_t nextListenerTag() override { return next_listener_tag_++; } private: @@ -95,8 +95,7 @@ class ListenerManagerImpl : public ListenerManager, Logger::Loggable> listeners() override; uint64_t numConnections() override; bool removeListener(const std::string& listener_name) override; @@ -182,7 +181,7 @@ class ListenerImpl : public Network::ListenerConfig, * have been started. This controls various behavior related to init management. * @param hash supplies the hash to use for duplicate checking. */ - ListenerImpl(const envoy::api::v2::listener::Listener& config, ListenerManagerImpl& parent, + ListenerImpl(const envoy::api::v2::Listener& config, ListenerManagerImpl& parent, const std::string& name, bool modifiable, bool workers_started, uint64_t hash); ~ListenerImpl(); diff --git a/source/server/server.cc b/source/server/server.cc index bd695f155ed62..448a9c23cbcd6 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -7,8 +7,6 @@ #include #include -#include "envoy/config/bootstrap/v2//bootstrap.pb.validate.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/event/dispatcher.h" #include "envoy/event/signal.h" #include "envoy/event/timer.h" @@ -37,6 +35,9 @@ #include "server/guarddog_impl.h" #include "server/test_hooks.h" +#include "api/bootstrap.pb.h" +#include "api/bootstrap.pb.validate.h" + namespace Envoy { namespace Server { @@ -156,7 +157,7 @@ void InstanceImpl::getParentStats(HotRestart::GetParentStatsInfo& info) { bool InstanceImpl::healthCheckFailed() { return server_stats_->live_.value() == 0; } -void InstanceUtil::loadBootstrapConfig(envoy::config::bootstrap::v2::Bootstrap& bootstrap, +void InstanceUtil::loadBootstrapConfig(envoy::api::v2::Bootstrap& bootstrap, const std::string& config_path, bool v2_only) { bool v2_config_loaded = false; try { @@ -184,7 +185,7 @@ void InstanceImpl::initialize(Options& options, restarter_.version()); // Handle configuration that needs to take place prior to the main configuration load. - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; InstanceUtil::loadBootstrapConfig(bootstrap, options.configPath(), options.v2ConfigOnly()); // Needs to happen as early as possible in the instantiation to preempt the objects that require diff --git a/source/server/server.h b/source/server/server.h index b742d5ac41550..02c8840d61d06 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -93,7 +93,7 @@ class InstanceUtil : Logger::Loggable { * @param config_path supplies the config path. * @param v2_only supplies whether to attempt v1 fallback. */ - static void loadBootstrapConfig(envoy::config::bootstrap::v2::Bootstrap& bootstrap, + static void loadBootstrapConfig(envoy::api::v2::Bootstrap& bootstrap, const std::string& config_path, bool v2_only); }; diff --git a/test/common/access_log/grpc_access_log_impl_test.cc b/test/common/access_log/grpc_access_log_impl_test.cc index b73688114d625..d06b739158e74 100644 --- a/test/common/access_log/grpc_access_log_impl_test.cc +++ b/test/common/access_log/grpc_access_log_impl_test.cc @@ -20,7 +20,8 @@ namespace AccessLog { class GrpcAccessLogStreamerImplTest : public testing::Test { public: typedef Grpc::MockAsyncStream MockAccessLogStream; - typedef Grpc::TypedAsyncStreamCallbacks + typedef Grpc::TypedAsyncStreamCallbacks< + envoy::api::v2::filter::accesslog::StreamAccessLogsResponse> AccessLogCallbacks; GrpcAccessLogStreamerImplTest() { @@ -57,7 +58,7 @@ TEST_F(GrpcAccessLogStreamerImplTest, BasicFlow) { expectStreamStart(stream1, &callbacks1); EXPECT_CALL(local_info_, node()); EXPECT_CALL(stream1, sendMessage(_, false)); - envoy::service::accesslog::v2::StreamAccessLogsMessage message_log1; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage message_log1; streamer_->send(message_log1, "log1"); message_log1.Clear(); @@ -70,12 +71,12 @@ TEST_F(GrpcAccessLogStreamerImplTest, BasicFlow) { expectStreamStart(stream2, &callbacks2); EXPECT_CALL(local_info_, node()); EXPECT_CALL(stream2, sendMessage(_, false)); - envoy::service::accesslog::v2::StreamAccessLogsMessage message_log2; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage message_log2; streamer_->send(message_log2, "log2"); // Verify that sending an empty response message doesn't do anything bad. callbacks1->onReceiveMessage( - std::make_unique()); + std::make_unique()); // Close stream 2 and make sure we make a new one. callbacks2->onRemoteClose(Grpc::Status::Internal, "bad"); @@ -96,14 +97,14 @@ TEST_F(GrpcAccessLogStreamerImplTest, StreamFailure) { return nullptr; })); EXPECT_CALL(local_info_, node()); - envoy::service::accesslog::v2::StreamAccessLogsMessage message_log1; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage message_log1; streamer_->send(message_log1, "log1"); } class MockGrpcAccessLogStreamer : public GrpcAccessLogStreamer { public: // GrpcAccessLogStreamer - MOCK_METHOD2(send, void(envoy::service::accesslog::v2::StreamAccessLogsMessage& message, + MOCK_METHOD2(send, void(envoy::api::v2::filter::accesslog::StreamAccessLogsMessage& message, const std::string& log_name)); }; @@ -116,18 +117,18 @@ class HttpGrpcAccessLogTest : public testing::Test { } void expectLog(const std::string& expected_request_msg_yaml) { - envoy::service::accesslog::v2::StreamAccessLogsMessage expected_request_msg; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage expected_request_msg; MessageUtil::loadFromYaml(expected_request_msg_yaml, expected_request_msg); EXPECT_CALL(*streamer_, send(_, "hello_log")) - .WillOnce(Invoke( - [expected_request_msg](envoy::service::accesslog::v2::StreamAccessLogsMessage& message, - const std::string&) { - EXPECT_EQ(message.DebugString(), expected_request_msg.DebugString()); - })); + .WillOnce(Invoke([expected_request_msg]( + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage& message, + const std::string&) { + EXPECT_EQ(message.DebugString(), expected_request_msg.DebugString()); + })); } MockFilter* filter_{new NiceMock()}; - envoy::config::accesslog::v2::HttpGrpcAccessLogConfig config_; + envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig config_; std::shared_ptr streamer_{new MockGrpcAccessLogStreamer()}; std::unique_ptr access_log_; }; diff --git a/test/common/config/BUILD b/test/common/config/BUILD index d20f04b141024..75e9115bde61c 100644 --- a/test/common/config/BUILD +++ b/test/common/config/BUILD @@ -20,6 +20,7 @@ envoy_cc_test( envoy_cc_test_library( name = "filesystem_subscription_test_harness", srcs = ["filesystem_subscription_test_harness.h"], + external_deps = ["envoy_eds"], deps = [ ":subscription_test_harness", "//source/common/config:filesystem_subscription_lib", @@ -28,13 +29,16 @@ envoy_cc_test_library( "//test/mocks/config:config_mocks", "//test/test_common:environment_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) envoy_cc_test( name = "grpc_mux_impl_test", srcs = ["grpc_mux_impl_test.cc"], + external_deps = [ + "envoy_discovery", + "envoy_eds", + ], deps = [ "//source/common/config:grpc_mux_lib", "//source/common/config:resources_lib", @@ -43,9 +47,6 @@ envoy_cc_test( "//test/mocks/event:event_mocks", "//test/mocks/grpc:grpc_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:ads_cc", - "@envoy_api//envoy/service/discovery/v2:common_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -60,6 +61,7 @@ envoy_cc_test( envoy_cc_test_library( name = "grpc_subscription_test_harness", hdrs = ["grpc_subscription_test_harness.h"], + external_deps = ["envoy_eds"], deps = [ ":subscription_test_harness", "//source/common/common:hash_lib", @@ -70,7 +72,6 @@ envoy_cc_test_library( "//test/mocks/grpc:grpc_mocks", "//test/mocks/upstream:upstream_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -85,6 +86,7 @@ envoy_cc_test( envoy_cc_test_library( name = "http_subscription_test_harness", srcs = ["http_subscription_test_harness.h"], + external_deps = ["envoy_eds"], deps = [ ":subscription_test_harness", "//include/envoy/http:async_client_interface", @@ -97,13 +99,16 @@ envoy_cc_test_library( "//test/mocks/runtime:runtime_mocks", "//test/mocks/upstream:upstream_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) envoy_cc_test( name = "subscription_factory_test", srcs = ["subscription_factory_test.cc"], + external_deps = [ + "envoy_base", + "envoy_eds", + ], deps = [ "//source/common/config:subscription_factory_lib", "//test/mocks/config:config_mocks", @@ -114,8 +119,6 @@ envoy_cc_test( "//test/mocks/upstream:upstream_mocks", "//test/test_common:environment_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/api/v2:base_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -151,6 +154,7 @@ envoy_cc_test( envoy_cc_test( name = "utility_test", srcs = ["utility_test.cc"], + external_deps = ["envoy_eds"], deps = [ "//source/common/config:cds_json_lib", "//source/common/config:lds_json_lib", @@ -164,7 +168,6 @@ envoy_cc_test( "//test/mocks/upstream:upstream_mocks", "//test/test_common:environment_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) diff --git a/test/common/config/filesystem_subscription_test_harness.h b/test/common/config/filesystem_subscription_test_harness.h index 0b5fb146855e3..d18fbc694a820 100644 --- a/test/common/config/filesystem_subscription_test_harness.h +++ b/test/common/config/filesystem_subscription_test_harness.h @@ -1,7 +1,5 @@ #include -#include "envoy/service/discovery/v2/eds.pb.h" - #include "common/config/filesystem_subscription_impl.h" #include "common/config/utility.h" #include "common/event/dispatcher_impl.h" @@ -11,6 +9,7 @@ #include "test/test_common/environment.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -21,7 +20,7 @@ using testing::_; namespace Envoy { namespace Config { -typedef FilesystemSubscriptionImpl +typedef FilesystemSubscriptionImpl FilesystemEdsSubscriptionImpl; class FilesystemSubscriptionTestHarness : public SubscriptionTestHarness { @@ -63,17 +62,17 @@ class FilesystemSubscriptionTestHarness : public SubscriptionTestHarness { std::string file_json = "{\"versionInfo\":\"" + version + "\",\"resources\":["; for (const auto& cluster : cluster_names) { file_json += "{\"@type\":\"type.googleapis.com/" - "envoy.service.discovery.v2.ClusterLoadAssignment\",\"clusterName\":\"" + + "envoy.api.v2.ClusterLoadAssignment\",\"clusterName\":\"" + cluster + "\"},"; } file_json.pop_back(); file_json += "]}"; - envoy::service::discovery::v2::DiscoveryResponse response_pb; + envoy::api::v2::DiscoveryResponse response_pb; EXPECT_TRUE(Protobuf::util::JsonStringToMessage(file_json, &response_pb).ok()); EXPECT_CALL(callbacks_, onConfigUpdate(RepeatedProtoEq( - Config::Utility::getTypedResources< - envoy::service::discovery::v2::ClusterLoadAssignment>(response_pb)))) + Config::Utility::getTypedResources( + response_pb)))) .WillOnce(ThrowOnRejectedConfig(accept)); if (accept) { version_ = version; @@ -94,8 +93,7 @@ class FilesystemSubscriptionTestHarness : public SubscriptionTestHarness { const std::string path_; std::string version_; Event::DispatcherImpl dispatcher_; - NiceMock> - callbacks_; + NiceMock> callbacks_; FilesystemEdsSubscriptionImpl subscription_; bool file_at_start_{false}; }; diff --git a/test/common/config/filter_json_test.cc b/test/common/config/filter_json_test.cc index 25bbf475f6061..e72863c5a1419 100644 --- a/test/common/config/filter_json_test.cc +++ b/test/common/config/filter_json_test.cc @@ -1,8 +1,7 @@ -#include "envoy/api/v2/filter/http/router.pb.h" - #include "common/config/filter_json.h" #include "common/json/json_loader.h" +#include "api/filter/http/router.pb.h" #include "gtest/gtest.h" namespace Envoy { diff --git a/test/common/config/grpc_mux_impl_test.cc b/test/common/config/grpc_mux_impl_test.cc index 32e122c313080..f3af1f317ed0d 100644 --- a/test/common/config/grpc_mux_impl_test.cc +++ b/test/common/config/grpc_mux_impl_test.cc @@ -1,7 +1,3 @@ -#include "envoy/service/discovery/v2/ads.pb.h" -#include "envoy/service/discovery/v2/common.pb.h" -#include "envoy/service/discovery/v2/eds.pb.h" - #include "common/config/grpc_mux_impl.h" #include "common/config/resources.h" #include "common/protobuf/protobuf.h" @@ -11,6 +7,8 @@ #include "test/mocks/grpc/mocks.h" #include "test/test_common/utility.h" +#include "api/discovery.pb.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -34,19 +32,16 @@ class GrpcMuxImplTest : public testing::Test { timer_cb_ = timer_cb; return timer_; })); - - envoy::service::discovery::v2::AdsDummy dummy; - grpc_mux_.reset(new GrpcMuxImpl( envoy::api::v2::Node(), std::unique_ptr(async_client_), dispatcher_, *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.discovery.v2.AggregatedDiscoveryService.StreamAggregatedResources"))); + "envoy.api.v2.AggregatedDiscoveryService.StreamAggregatedResources"))); } void expectSendMessage(const std::string& type_url, const std::vector& resource_names, const std::string& version) { - envoy::service::discovery::v2::DiscoveryRequest expected_request; + envoy::api::v2::DiscoveryRequest expected_request; expected_request.mutable_node()->CopyFrom(node_); for (const auto& resource : resource_names) { expected_request.add_resource_names(resource); @@ -142,15 +137,15 @@ TEST_F(GrpcMuxImplTest, TypeUrlMismatch) { grpc_mux_->start(); { - std::unique_ptr response( - new envoy::service::discovery::v2::DiscoveryResponse()); + std::unique_ptr response( + new envoy::api::v2::DiscoveryResponse()); response->set_type_url("bar"); grpc_mux_->onReceiveMessage(std::move(response)); } { - std::unique_ptr response( - new envoy::service::discovery::v2::DiscoveryResponse()); + std::unique_ptr response( + new envoy::api::v2::DiscoveryResponse()); response->set_type_url("foo"); response->mutable_resources()->Add()->set_type_url("bar"); EXPECT_CALL(callbacks_, onConfigUpdateFailed(_)).WillOnce(Invoke([](const EnvoyException* e) { @@ -174,11 +169,11 @@ TEST_F(GrpcMuxImplTest, WildcardWatch) { grpc_mux_->start(); { - std::unique_ptr response( - new envoy::service::discovery::v2::DiscoveryResponse()); + std::unique_ptr response( + new envoy::api::v2::DiscoveryResponse()); response->set_type_url(type_url); response->set_version_info("1"); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment; + envoy::api::v2::ClusterLoadAssignment load_assignment; load_assignment.set_cluster_name("x"); response->add_resources()->PackFrom(load_assignment); EXPECT_CALL(callbacks_, onConfigUpdate(_, "1")) @@ -186,7 +181,7 @@ TEST_F(GrpcMuxImplTest, WildcardWatch) { Invoke([&load_assignment](const Protobuf::RepeatedPtrField& resources, const std::string&) { EXPECT_EQ(1, resources.size()); - envoy::service::discovery::v2::ClusterLoadAssignment expected_assignment; + envoy::api::v2::ClusterLoadAssignment expected_assignment; resources[0].UnpackTo(&expected_assignment); EXPECT_TRUE(TestUtility::protoEqual(expected_assignment, load_assignment)); })); @@ -209,11 +204,11 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { grpc_mux_->start(); { - std::unique_ptr response( - new envoy::service::discovery::v2::DiscoveryResponse()); + std::unique_ptr response( + new envoy::api::v2::DiscoveryResponse()); response->set_type_url(type_url); response->set_version_info("1"); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment; + envoy::api::v2::ClusterLoadAssignment load_assignment; load_assignment.set_cluster_name("x"); response->add_resources()->PackFrom(load_assignment); EXPECT_CALL(bar_callbacks, onConfigUpdate(_, "1")) @@ -224,7 +219,7 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { Invoke([&load_assignment](const Protobuf::RepeatedPtrField& resources, const std::string&) { EXPECT_EQ(1, resources.size()); - envoy::service::discovery::v2::ClusterLoadAssignment expected_assignment; + envoy::api::v2::ClusterLoadAssignment expected_assignment; resources[0].UnpackTo(&expected_assignment); EXPECT_TRUE(TestUtility::protoEqual(expected_assignment, load_assignment)); })); @@ -233,17 +228,17 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { } { - std::unique_ptr response( - new envoy::service::discovery::v2::DiscoveryResponse()); + std::unique_ptr response( + new envoy::api::v2::DiscoveryResponse()); response->set_type_url(type_url); response->set_version_info("2"); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment_x; + envoy::api::v2::ClusterLoadAssignment load_assignment_x; load_assignment_x.set_cluster_name("x"); response->add_resources()->PackFrom(load_assignment_x); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment_y; + envoy::api::v2::ClusterLoadAssignment load_assignment_y; load_assignment_y.set_cluster_name("y"); response->add_resources()->PackFrom(load_assignment_y); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment_z; + envoy::api::v2::ClusterLoadAssignment load_assignment_z; load_assignment_z.set_cluster_name("z"); response->add_resources()->PackFrom(load_assignment_z); EXPECT_CALL(bar_callbacks, onConfigUpdate(_, "2")) @@ -251,7 +246,7 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { [&load_assignment_y, &load_assignment_z]( const Protobuf::RepeatedPtrField& resources, const std::string&) { EXPECT_EQ(2, resources.size()); - envoy::service::discovery::v2::ClusterLoadAssignment expected_assignment; + envoy::api::v2::ClusterLoadAssignment expected_assignment; resources[0].UnpackTo(&expected_assignment); EXPECT_TRUE(TestUtility::protoEqual(expected_assignment, load_assignment_y)); resources[1].UnpackTo(&expected_assignment); @@ -262,7 +257,7 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { [&load_assignment_x, &load_assignment_y]( const Protobuf::RepeatedPtrField& resources, const std::string&) { EXPECT_EQ(2, resources.size()); - envoy::service::discovery::v2::ClusterLoadAssignment expected_assignment; + envoy::api::v2::ClusterLoadAssignment expected_assignment; resources[0].UnpackTo(&expected_assignment); EXPECT_TRUE(TestUtility::protoEqual(expected_assignment, load_assignment_x)); resources[1].UnpackTo(&expected_assignment); diff --git a/test/common/config/grpc_subscription_test_harness.h b/test/common/config/grpc_subscription_test_harness.h index 92c3abe7618af..707c19ae68849 100644 --- a/test/common/config/grpc_subscription_test_harness.h +++ b/test/common/config/grpc_subscription_test_harness.h @@ -1,7 +1,5 @@ #pragma once -#include "envoy/service/discovery/v2/eds.pb.h" - #include "common/common/hash.h" #include "common/config/grpc_subscription_impl.h" #include "common/config/resources.h" @@ -13,6 +11,7 @@ #include "test/mocks/upstream/mocks.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -25,14 +24,13 @@ using testing::_; namespace Envoy { namespace Config { -typedef GrpcSubscriptionImpl - GrpcEdsSubscriptionImpl; +typedef GrpcSubscriptionImpl GrpcEdsSubscriptionImpl; class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { public: GrpcSubscriptionTestHarness() : method_descriptor_(Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.discovery.v2.EndpointDiscoveryService.StreamEndpoints")), + "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints")), async_client_(new Grpc::MockAsyncClient()), timer_(new Event::MockTimer()) { node_.set_id("fo0"); EXPECT_CALL(dispatcher_, createTimer_(_)).WillOnce(Invoke([this](Event::TimerCb timer_cb) { @@ -48,7 +46,7 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { void expectSendMessage(const std::vector& cluster_names, const std::string& version) override { - envoy::service::discovery::v2::DiscoveryRequest expected_request; + envoy::api::v2::DiscoveryRequest expected_request; expected_request.mutable_node()->CopyFrom(node_); for (const auto& cluster : cluster_names) { expected_request.add_resource_names(cluster); @@ -76,19 +74,17 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { void deliverConfigUpdate(const std::vector& cluster_names, const std::string& version, bool accept) override { - std::unique_ptr response( - new envoy::service::discovery::v2::DiscoveryResponse()); + std::unique_ptr response( + new envoy::api::v2::DiscoveryResponse()); response->set_version_info(version); last_response_nonce_ = std::to_string(HashUtil::xxHash64(version)); response->set_nonce(last_response_nonce_); response->set_type_url(Config::TypeUrl::get().ClusterLoadAssignment); - Protobuf::RepeatedPtrField - typed_resources; + Protobuf::RepeatedPtrField typed_resources; for (const auto& cluster : cluster_names) { if (std::find(last_cluster_names_.begin(), last_cluster_names_.end(), cluster) != last_cluster_names_.end()) { - envoy::service::discovery::v2::ClusterLoadAssignment* load_assignment = - typed_resources.Add(); + envoy::api::v2::ClusterLoadAssignment* load_assignment = typed_resources.Add(); load_assignment->set_cluster_name(cluster); response->add_resources()->PackFrom(*load_assignment); } @@ -125,8 +121,7 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { Event::MockTimer* timer_; Event::TimerCb timer_cb_; envoy::api::v2::Node node_; - Config::MockSubscriptionCallbacks - callbacks_; + Config::MockSubscriptionCallbacks callbacks_; Grpc::MockAsyncStream async_stream_; std::unique_ptr subscription_; std::string last_response_nonce_; diff --git a/test/common/config/http_subscription_test_harness.h b/test/common/config/http_subscription_test_harness.h index a3e61a4623ff7..270fbcacdc683 100644 --- a/test/common/config/http_subscription_test_harness.h +++ b/test/common/config/http_subscription_test_harness.h @@ -1,5 +1,4 @@ #include "envoy/http/async_client.h" -#include "envoy/service/discovery/v2/eds.pb.h" #include "common/common/utility.h" #include "common/config/http_subscription_impl.h" @@ -14,6 +13,7 @@ #include "test/mocks/upstream/mocks.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -24,14 +24,13 @@ using testing::_; namespace Envoy { namespace Config { -typedef HttpSubscriptionImpl - HttpEdsSubscriptionImpl; +typedef HttpSubscriptionImpl HttpEdsSubscriptionImpl; class HttpSubscriptionTestHarness : public SubscriptionTestHarness { public: HttpSubscriptionTestHarness() : method_descriptor_(Protobuf::DescriptorPool::generated_pool()->FindMethodByName( - "envoy.service.discovery.v2.EndpointDiscoveryService.FetchEndpoints")), + "envoy.api.v2.EndpointDiscoveryService.FetchEndpoints")), timer_(new Event::MockTimer()), http_request_(&cm_.async_client_) { node_.set_id("fo0"); EXPECT_CALL(dispatcher_, createTimer_(_)).WillOnce(Invoke([this](Event::TimerCb timer_cb) { @@ -98,20 +97,20 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { std::string response_json = "{\"version_info\":\"" + version + "\",\"resources\":["; for (const auto& cluster : cluster_names) { response_json += "{\"@type\":\"type.googleapis.com/" - "envoy.service.discovery.v2.ClusterLoadAssignment\",\"cluster_name\":\"" + + "envoy.api.v2.ClusterLoadAssignment\",\"cluster_name\":\"" + cluster + "\"},"; } response_json.pop_back(); response_json += "]}"; - envoy::service::discovery::v2::DiscoveryResponse response_pb; + envoy::api::v2::DiscoveryResponse response_pb; EXPECT_TRUE(Protobuf::util::JsonStringToMessage(response_json, &response_pb).ok()); Http::HeaderMapPtr response_headers{new Http::TestHeaderMapImpl{{":status", "200"}}}; Http::MessagePtr message{new Http::ResponseMessageImpl(std::move(response_headers))}; message->body().reset(new Buffer::OwnedImpl(response_json)); EXPECT_CALL(callbacks_, onConfigUpdate(RepeatedProtoEq( - Config::Utility::getTypedResources< - envoy::service::discovery::v2::ClusterLoadAssignment>(response_pb)))) + Config::Utility::getTypedResources( + response_pb)))) .WillOnce(ThrowOnRejectedConfig(accept)); if (!accept) { EXPECT_CALL(callbacks_, onConfigUpdateFailed(_)); @@ -144,8 +143,7 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { Runtime::MockRandomGenerator random_gen_; Http::MockAsyncClientRequest http_request_; Http::AsyncClient::Callbacks* http_callbacks_; - Config::MockSubscriptionCallbacks - callbacks_; + Config::MockSubscriptionCallbacks callbacks_; std::unique_ptr subscription_; }; diff --git a/test/common/config/subscription_factory_test.cc b/test/common/config/subscription_factory_test.cc index 7f7949aae4f36..06a260e79a91f 100644 --- a/test/common/config/subscription_factory_test.cc +++ b/test/common/config/subscription_factory_test.cc @@ -1,5 +1,4 @@ #include "envoy/common/exception.h" -#include "envoy/service/discovery/v2/eds.pb.h" #include "common/config/subscription_factory.h" @@ -12,6 +11,7 @@ #include "test/test_common/environment.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -25,29 +25,26 @@ namespace Config { class SubscriptionFactoryTest : public ::testing::Test { public: SubscriptionFactoryTest() : http_request_(&cm_.async_client_) { - legacy_subscription_.reset( - new MockSubscription()); + legacy_subscription_.reset(new MockSubscription()); } - std::unique_ptr> + std::unique_ptr> subscriptionFromConfigSource(const envoy::api::v2::ConfigSource& config) { - return SubscriptionFactory::subscriptionFromConfigSource< - envoy::service::discovery::v2::ClusterLoadAssignment>( + return SubscriptionFactory::subscriptionFromConfigSource( config, node_, dispatcher_, cm_, random_, stats_store_, - [this]() -> Subscription* { + [this]() -> Subscription* { return legacy_subscription_.release(); }, - "envoy.service.discovery.v2.EndpointDiscoveryService.FetchEndpoints", - "envoy.service.discovery.v2.EndpointDiscoveryService.StreamEndpoints"); + "envoy.api.v2.EndpointDiscoveryService.FetchEndpoints", + "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints"); } envoy::api::v2::Node node_; Upstream::MockClusterManager cm_; Event::MockDispatcher dispatcher_; Runtime::MockRandomGenerator random_; - MockSubscriptionCallbacks callbacks_; - std::unique_ptr> - legacy_subscription_; + MockSubscriptionCallbacks callbacks_; + std::unique_ptr> legacy_subscription_; Http::MockAsyncClientRequest http_request_; Stats::MockIsolatedStatsStore stats_store_; }; @@ -232,7 +229,7 @@ TEST_P(SubscriptionFactoryTestApiConfigSource, EDSClusterBackingEDSCluster) { EXPECT_CALL(cm_, clusters()).WillOnce(Return(cluster_map)); EXPECT_CALL(cluster, info()).Times(2); EXPECT_CALL(*cluster.info_, addedViaApi()); - EXPECT_CALL(*cluster.info_, type()).WillOnce(Return(envoy::api::v2::cluster::Cluster::EDS)); + EXPECT_CALL(*cluster.info_, type()).WillOnce(Return(envoy::api::v2::Cluster::EDS)); EXPECT_THROW_WITH_MESSAGE( subscriptionFromConfigSource(config)->start({"foo"}, callbacks_), EnvoyException, "envoy::api::v2::ConfigSource must have a statically defined non-EDS cluster: 'eds_cluster' " diff --git a/test/common/config/utility_test.cc b/test/common/config/utility_test.cc index 919e50106685b..70521f80436a9 100644 --- a/test/common/config/utility_test.cc +++ b/test/common/config/utility_test.cc @@ -1,5 +1,4 @@ #include "envoy/common/exception.h" -#include "envoy/service/discovery/v2/eds.pb.h" #include "common/config/cds_json.h" #include "common/config/lds_json.h" @@ -16,6 +15,7 @@ #include "test/test_common/environment.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "fmt/format.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -29,20 +29,18 @@ namespace Envoy { namespace Config { TEST(UtilityTest, GetTypedResources) { - envoy::service::discovery::v2::DiscoveryResponse response; - EXPECT_EQ( - 0, Utility::getTypedResources(response) - .size()); + envoy::api::v2::DiscoveryResponse response; + EXPECT_EQ(0, Utility::getTypedResources(response).size()); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment_0; + envoy::api::v2::ClusterLoadAssignment load_assignment_0; load_assignment_0.set_cluster_name("0"); response.add_resources()->PackFrom(load_assignment_0); - envoy::service::discovery::v2::ClusterLoadAssignment load_assignment_1; + envoy::api::v2::ClusterLoadAssignment load_assignment_1; load_assignment_1.set_cluster_name("1"); response.add_resources()->PackFrom(load_assignment_1); auto typed_resources = - Utility::getTypedResources(response); + Utility::getTypedResources(response); EXPECT_EQ(2, typed_resources.size()); EXPECT_EQ("0", typed_resources[0].cluster_name()); EXPECT_EQ("1", typed_resources[1].cluster_name()); @@ -87,7 +85,7 @@ TEST(UtilityTest, TranslateApiConfigSource) { } TEST(UtilityTest, createTagProducer) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; auto producer = Utility::createTagProducer(bootstrap); ASSERT(producer != nullptr); std::vector tags; @@ -114,7 +112,7 @@ TEST(UtilityTest, ObjNameLength) { R"EOF({ "name": ")EOF" + name + R"EOF(", "address": "foo", "filters":[]})EOF"; auto json_object_ptr = Json::Factory::loadFromString(json); - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; EXPECT_THROW_WITH_MESSAGE(Config::LdsJson::translateListener(*json_object_ptr, listener), EnvoyException, err_prefix + err_suffix); } @@ -123,7 +121,7 @@ TEST(UtilityTest, ObjNameLength) { err_prefix = "Invalid virtual host name"; std::string json = R"EOF({ "name": ")EOF" + name + R"EOF(", "domains": [], "routes": []})EOF"; auto json_object_ptr = Json::Factory::loadFromString(json); - envoy::api::v2::route::VirtualHost vhost; + envoy::api::v2::VirtualHost vhost; EXPECT_THROW_WITH_MESSAGE(Config::RdsJson::translateVirtualHost(*json_object_ptr, vhost), EnvoyException, err_prefix + err_suffix); } @@ -134,7 +132,7 @@ TEST(UtilityTest, ObjNameLength) { R"EOF({ "name": ")EOF" + name + R"EOF(", "type": "static", "lb_type": "random", "connect_timeout_ms" : 1})EOF"; auto json_object_ptr = Json::Factory::loadFromString(json); - envoy::api::v2::cluster::Cluster cluster; + envoy::api::v2::Cluster cluster; envoy::api::v2::ConfigSource eds_config; EXPECT_THROW_WITH_MESSAGE( Config::CdsJson::translateCluster(*json_object_ptr, eds_config, cluster), EnvoyException, @@ -159,7 +157,7 @@ TEST(UtilityTest, UnixClusterDns) { R"EOF({ "name": "test", "type": ")EOF" + cluster_type + R"EOF(", "lb_type": "random", "connect_timeout_ms" : 1, "hosts": [{"url": "unix:///test.sock"}]})EOF"; auto json_object_ptr = Json::Factory::loadFromString(json); - envoy::api::v2::cluster::Cluster cluster; + envoy::api::v2::Cluster cluster; envoy::api::v2::ConfigSource eds_config; EXPECT_THROW_WITH_MESSAGE( Config::CdsJson::translateCluster(*json_object_ptr, eds_config, cluster), EnvoyException, @@ -174,7 +172,7 @@ TEST(UtilityTest, UnixClusterStatic) { R"EOF({ "name": "test", "type": ")EOF" + cluster_type + R"EOF(", "lb_type": "random", "connect_timeout_ms" : 1, "hosts": [{"url": "unix:///test.sock"}]})EOF"; auto json_object_ptr = Json::Factory::loadFromString(json); - envoy::api::v2::cluster::Cluster cluster; + envoy::api::v2::Cluster cluster; envoy::api::v2::ConfigSource eds_config; Config::CdsJson::translateCluster(*json_object_ptr, eds_config, cluster); EXPECT_EQ("/test.sock", cluster.hosts(0).pipe().path()); @@ -215,7 +213,7 @@ TEST(UtilityTest, CheckApiConfigSourceSubscriptionBackingCluster) { // EDS Cluster backing EDS Cluster. EXPECT_CALL(cluster, info()).Times(2); EXPECT_CALL(*cluster.info_, addedViaApi()); - EXPECT_CALL(*cluster.info_, type()).WillOnce(Return(envoy::api::v2::cluster::Cluster::EDS)); + EXPECT_CALL(*cluster.info_, type()).WillOnce(Return(envoy::api::v2::Cluster::EDS)); EXPECT_THROW_WITH_MESSAGE( Utility::checkApiConfigSourceSubscriptionBackingCluster(cluster_map, *api_config_source), EnvoyException, diff --git a/test/common/mongo/proxy_test.cc b/test/common/mongo/proxy_test.cc index 1b2b5151b8322..a6d2e647b8e8b 100644 --- a/test/common/mongo/proxy_test.cc +++ b/test/common/mongo/proxy_test.cc @@ -3,8 +3,6 @@ #include #include -#include "envoy/api/v2/filter/fault.pb.h" - #include "common/mongo/bson_impl.h" #include "common/mongo/codec_impl.h" #include "common/mongo/proxy.h" @@ -17,6 +15,7 @@ #include "test/mocks/runtime/mocks.h" #include "test/test_common/printers.h" +#include "api/filter/fault.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/test/common/network/resolver_impl_test.cc b/test/common/network/resolver_impl_test.cc index bc1bd39b1e351..248015ed6f042 100644 --- a/test/common/network/resolver_impl_test.cc +++ b/test/common/network/resolver_impl_test.cc @@ -2,7 +2,6 @@ #include #include -#include "envoy/api/v2/address.pb.h" #include "envoy/common/exception.h" #include "envoy/network/resolver.h" #include "envoy/registry/registry.h" @@ -16,6 +15,7 @@ #include "test/test_common/registry.h" #include "test/test_common/utility.h" +#include "api/address.pb.h" #include "gtest/gtest.h" namespace Envoy { diff --git a/test/common/protobuf/BUILD b/test/common/protobuf/BUILD index 95a59961695a7..526f49ec6aa65 100644 --- a/test/common/protobuf/BUILD +++ b/test/common/protobuf/BUILD @@ -11,10 +11,10 @@ envoy_package() envoy_cc_test( name = "utility_test", srcs = ["utility_test.cc"], + external_deps = ["envoy_bootstrap"], deps = [ "//source/common/protobuf:utility_lib", "//test/test_common:environment_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) diff --git a/test/common/protobuf/utility_test.cc b/test/common/protobuf/utility_test.cc index 766d3936da6fa..5237c3e8b2bcd 100644 --- a/test/common/protobuf/utility_test.cc +++ b/test/common/protobuf/utility_test.cc @@ -1,28 +1,26 @@ #include -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.validate.h" - #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" #include "test/test_common/environment.h" #include "test/test_common/utility.h" +#include "api/bootstrap.pb.h" +#include "api/bootstrap.pb.validate.h" #include "gtest/gtest.h" namespace Envoy { TEST(UtilityTest, DowncastAndValidate) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; EXPECT_THROW(MessageUtil::validate(bootstrap), ProtoValidationException); - EXPECT_THROW( - MessageUtil::downcastAndValidate(bootstrap), - ProtoValidationException); + EXPECT_THROW(MessageUtil::downcastAndValidate(bootstrap), + ProtoValidationException); } TEST(UtilityTest, LoadBinaryProtoFromFile) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; bootstrap.mutable_cluster_manager() ->mutable_upstream_bind_config() ->mutable_source_address() @@ -31,13 +29,13 @@ TEST(UtilityTest, LoadBinaryProtoFromFile) { const std::string filename = TestEnvironment::writeStringToFileForTest("proto.pb", bootstrap.SerializeAsString()); - envoy::config::bootstrap::v2::Bootstrap proto_from_file; + envoy::api::v2::Bootstrap proto_from_file; MessageUtil::loadFromFile(filename, proto_from_file); EXPECT_TRUE(TestUtility::protoEqual(bootstrap, proto_from_file)); } TEST(UtilityTest, LoadTextProtoFromFile) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; bootstrap.mutable_cluster_manager() ->mutable_upstream_bind_config() ->mutable_source_address() @@ -48,7 +46,7 @@ TEST(UtilityTest, LoadTextProtoFromFile) { const std::string filename = TestEnvironment::writeStringToFileForTest("proto.pb_text", bootstrap_text); - envoy::config::bootstrap::v2::Bootstrap proto_from_file; + envoy::api::v2::Bootstrap proto_from_file; MessageUtil::loadFromFile(filename, proto_from_file); EXPECT_TRUE(TestUtility::protoEqual(bootstrap, proto_from_file)); } @@ -57,10 +55,10 @@ TEST(UtilityTest, LoadTextProtoFromFile_Failure) { const std::string filename = TestEnvironment::writeStringToFileForTest("proto.pb_text", "invalid {"); - envoy::config::bootstrap::v2::Bootstrap proto_from_file; + envoy::api::v2::Bootstrap proto_from_file; EXPECT_THROW_WITH_MESSAGE(MessageUtil::loadFromFile(filename, proto_from_file), EnvoyException, "Unable to parse file \"" + filename + - "\" as a text protobuf (type envoy.config.bootstrap.v2.Bootstrap)"); + "\" as a text protobuf (type envoy.api.v2.Bootstrap)"); } TEST(UtilityTest, ValueUtilEqual_NullValues) { diff --git a/test/common/ratelimit/ratelimit_impl_test.cc b/test/common/ratelimit/ratelimit_impl_test.cc index 846356b00f91a..5aa2aadfd6c17 100644 --- a/test/common/ratelimit/ratelimit_impl_test.cc +++ b/test/common/ratelimit/ratelimit_impl_test.cc @@ -120,7 +120,7 @@ TEST_F(RateLimitGrpcClientTest, Cancel) { } TEST(RateLimitGrpcFactoryTest, Create) { - envoy::config::ratelimit::v2::RateLimitServiceConfig config; + envoy::api::v2::RateLimitServiceConfig config; config.mutable_grpc_service()->mutable_envoy_grpc()->set_cluster_name("foo"); Grpc::MockAsyncClientManager async_client_manager; Stats::MockStore scope; @@ -135,7 +135,7 @@ TEST(RateLimitGrpcFactoryTest, Create) { // TODO(htuch): cluster_name is deprecated, remove after 1.6.0. TEST(RateLimitGrpcFactoryTest, CreateLegacy) { - envoy::config::ratelimit::v2::RateLimitServiceConfig config; + envoy::api::v2::RateLimitServiceConfig config; config.set_cluster_name("foo"); Grpc::MockAsyncClientManager async_client_manager; Stats::MockStore scope; diff --git a/test/common/router/BUILD b/test/common/router/BUILD index 1ff18448175f7..80d924b43f42b 100644 --- a/test/common/router/BUILD +++ b/test/common/router/BUILD @@ -61,6 +61,7 @@ envoy_cc_test( envoy_cc_test( name = "router_ratelimit_test", srcs = ["router_ratelimit_test.cc"], + external_deps = ["envoy_rds"], deps = [ "//source/common/http:header_map_lib", "//source/common/json:json_loader_lib", @@ -71,7 +72,6 @@ envoy_cc_test( "//test/mocks/router:router_mocks", "//test/mocks/upstream:upstream_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:rds_cc", ], ) @@ -100,6 +100,7 @@ envoy_cc_test( envoy_cc_test( name = "router_upstream_log_test", srcs = ["router_upstream_log_test.cc"], + external_deps = ["envoy_filter_http_router"], deps = [ "//include/envoy/common:optional", "//source/common/buffer:buffer_lib", @@ -121,7 +122,6 @@ envoy_cc_test( "//test/mocks/ssl:ssl_mocks", "//test/mocks/upstream:upstream_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/api/v2/filter/http:router_cc", ], ) diff --git a/test/common/router/config_impl_test.cc b/test/common/router/config_impl_test.cc index 64e6de4013ae3..ff5f33733ae5b 100644 --- a/test/common/router/config_impl_test.cc +++ b/test/common/router/config_impl_test.cc @@ -40,17 +40,15 @@ Http::TestHeaderMapImpl genHeaders(const std::string& host, const std::string& p return Http::TestHeaderMapImpl{{":authority", host}, {":path", path}, {":method", method}}; } -envoy::api::v2::route::RouteConfiguration -parseRouteConfigurationFromJson(const std::string& json_string) { - envoy::api::v2::route::RouteConfiguration route_config; +envoy::api::v2::RouteConfiguration parseRouteConfigurationFromJson(const std::string& json_string) { + envoy::api::v2::RouteConfiguration route_config; auto json_object_ptr = Json::Factory::loadFromString(json_string); Envoy::Config::RdsJson::translateRouteConfiguration(*json_object_ptr, route_config); return route_config; } -envoy::api::v2::route::RouteConfiguration -parseRouteConfigurationFromV2Yaml(const std::string& yaml) { - envoy::api::v2::route::RouteConfiguration route_config; +envoy::api::v2::RouteConfiguration parseRouteConfigurationFromV2Yaml(const std::string& yaml) { + envoy::api::v2::RouteConfiguration route_config; MessageUtil::loadFromYaml(yaml, route_config); return route_config; } @@ -692,7 +690,7 @@ name: foo NiceMock cm; NiceMock request_info; - envoy::api::v2::route::RouteConfiguration route_config = parseRouteConfigurationFromV2Yaml(yaml); + envoy::api::v2::RouteConfiguration route_config = parseRouteConfigurationFromV2Yaml(yaml); ConfigImpl config(route_config, runtime, cm, true); @@ -1233,7 +1231,7 @@ class RouterMatcherHashPolicyTest : public testing::Test { route_config_ = parseRouteConfigurationFromJson(json); } - envoy::api::v2::route::RouteAction_HashPolicy* firstRouteHashPolicy() { + envoy::api::v2::RouteAction_HashPolicy* firstRouteHashPolicy() { auto hash_policies = route_config_.mutable_virtual_hosts(0) ->mutable_routes(0) ->mutable_route() @@ -1254,7 +1252,7 @@ class RouterMatcherHashPolicyTest : public testing::Test { NiceMock runtime_; NiceMock cm_; - envoy::api::v2::route::RouteConfiguration route_config_; + envoy::api::v2::RouteConfiguration route_config_; HashPolicy::AddCookieCallback add_cookie_nop_; private: @@ -1492,7 +1490,7 @@ TEST_F(RouterMatcherHashPolicyTest, InvalidHashPolicies) { NiceMock cm; { auto hash_policy = firstRouteHashPolicy(); - EXPECT_EQ(envoy::api::v2::route::RouteAction::HashPolicy::POLICY_SPECIFIER_NOT_SET, + EXPECT_EQ(envoy::api::v2::RouteAction::HashPolicy::POLICY_SPECIFIER_NOT_SET, hash_policy->policy_specifier_case()); EXPECT_THROW(config(), EnvoyException); } @@ -1501,7 +1499,7 @@ TEST_F(RouterMatcherHashPolicyTest, InvalidHashPolicies) { route->add_hash_policy()->mutable_header()->set_header_name("foo_header"); route->add_hash_policy()->mutable_connection_properties()->set_source_ip(true); auto hash_policy = route->add_hash_policy(); - EXPECT_EQ(envoy::api::v2::route::RouteAction::HashPolicy::POLICY_SPECIFIER_NOT_SET, + EXPECT_EQ(envoy::api::v2::RouteAction::HashPolicy::POLICY_SPECIFIER_NOT_SET, hash_policy->policy_specifier_case()); EXPECT_THROW(config(), EnvoyException); } @@ -3481,7 +3479,7 @@ TEST(MetadataMatchCriteriaImpl, Merge) { } TEST(RouteEntryMetadataMatchTest, ParsesMetadata) { - auto route_config = envoy::api::v2::route::RouteConfiguration(); + auto route_config = envoy::api::v2::RouteConfiguration(); auto* vhost = route_config.add_virtual_hosts(); vhost->set_name("vhost"); vhost->add_domains("www.lyft.com"); @@ -3593,17 +3591,15 @@ TEST(RouteEntryMetadataMatchTest, ParsesMetadata) { } TEST(ConfigUtility, ParseResponseCode) { - const std::vector< - std::pair> - test_set = { - std::make_pair(envoy::api::v2::route::RedirectAction::MOVED_PERMANENTLY, - Http::Code::MovedPermanently), - std::make_pair(envoy::api::v2::route::RedirectAction::FOUND, Http::Code::Found), - std::make_pair(envoy::api::v2::route::RedirectAction::SEE_OTHER, Http::Code::SeeOther), - std::make_pair(envoy::api::v2::route::RedirectAction::TEMPORARY_REDIRECT, - Http::Code::TemporaryRedirect), - std::make_pair(envoy::api::v2::route::RedirectAction::PERMANENT_REDIRECT, - Http::Code::PermanentRedirect)}; + const std::vector> + test_set = {std::make_pair(envoy::api::v2::RedirectAction::MOVED_PERMANENTLY, + Http::Code::MovedPermanently), + std::make_pair(envoy::api::v2::RedirectAction::FOUND, Http::Code::Found), + std::make_pair(envoy::api::v2::RedirectAction::SEE_OTHER, Http::Code::SeeOther), + std::make_pair(envoy::api::v2::RedirectAction::TEMPORARY_REDIRECT, + Http::Code::TemporaryRedirect), + std::make_pair(envoy::api::v2::RedirectAction::PERMANENT_REDIRECT, + Http::Code::PermanentRedirect)}; for (const auto& test_case : test_set) { EXPECT_EQ(test_case.second, ConfigUtility::parseRedirectResponseCode(test_case.first)); } diff --git a/test/common/router/header_formatter_test.cc b/test/common/router/header_formatter_test.cc index 250abb9c96f52..f13615f35ad8e 100644 --- a/test/common/router/header_formatter_test.cc +++ b/test/common/router/header_formatter_test.cc @@ -20,15 +20,15 @@ using testing::ReturnRef; namespace Envoy { namespace Router { -static envoy::api::v2::route::Route parseRouteFromJson(const std::string& json_string) { - envoy::api::v2::route::Route route; +static envoy::api::v2::Route parseRouteFromJson(const std::string& json_string) { + envoy::api::v2::Route route; auto json_object_ptr = Json::Factory::loadFromString(json_string); Envoy::Config::RdsJson::translateRoute(*json_object_ptr, route); return route; } -static envoy::api::v2::route::Route parseRouteFromV2Yaml(const std::string& yaml) { - envoy::api::v2::route::Route route; +static envoy::api::v2::Route parseRouteFromV2Yaml(const std::string& yaml) { + envoy::api::v2::Route route; MessageUtil::loadFromYaml(yaml, route); return route; } @@ -407,7 +407,7 @@ TEST(HeaderParserTest, EvaluateHeadersWithAppendFalse) { )EOF"; // Disable append mode. - envoy::api::v2::route::RouteAction route_action = parseRouteFromJson(json).route(); + envoy::api::v2::RouteAction route_action = parseRouteFromJson(json).route(); route_action.mutable_request_headers_to_add(0)->mutable_append()->set_value(false); route_action.mutable_request_headers_to_add(1)->mutable_append()->set_value(false); diff --git a/test/common/router/rds_impl_test.cc b/test/common/router/rds_impl_test.cc index 5c618aa6d1f39..9aee219affd35 100644 --- a/test/common/router/rds_impl_test.cc +++ b/test/common/router/rds_impl_test.cc @@ -563,7 +563,7 @@ TEST_F(RouteConfigProviderManagerImplTest, Basic) { TEST_F(RouteConfigProviderManagerImplTest, ValidateFail) { setup(); auto& provider_impl = dynamic_cast(*provider_.get()); - Protobuf::RepeatedPtrField route_configs; + Protobuf::RepeatedPtrField route_configs; auto* route_config = route_configs.Add(); route_config->set_name("foo_route_config"); route_config->mutable_virtual_hosts()->Add(); @@ -583,7 +583,7 @@ TEST_F(RouteConfigProviderManagerImplTest, onConfigUpdateWrongSize) { setup(); init_manager_.initialize(); auto& provider_impl = dynamic_cast(*provider_.get()); - Protobuf::RepeatedPtrField route_configs; + Protobuf::RepeatedPtrField route_configs; route_configs.Add(); route_configs.Add(); EXPECT_CALL(init_manager_.initialized_, ready()); diff --git a/test/common/router/router_ratelimit_test.cc b/test/common/router/router_ratelimit_test.cc index 62df49cad182d..9b9583092d0d3 100644 --- a/test/common/router/router_ratelimit_test.cc +++ b/test/common/router/router_ratelimit_test.cc @@ -27,8 +27,8 @@ namespace Envoy { namespace Router { namespace { -envoy::api::v2::route::RateLimit parseRateLimitFromJson(const std::string& json_string) { - envoy::api::v2::route::RateLimit rate_limit; +envoy::api::v2::RateLimit parseRateLimitFromJson(const std::string& json_string) { + envoy::api::v2::RateLimit rate_limit; auto json_object_ptr = Json::Factory::loadFromString(json_string); Envoy::Config::RdsJson::translateRateLimit(*json_object_ptr, rate_limit); return rate_limit; @@ -100,7 +100,7 @@ static Http::TestHeaderMapImpl genHeaders(const std::string& host, const std::st class RateLimitConfiguration : public testing::Test { public: void SetUpTest(const std::string json) { - envoy::api::v2::route::RouteConfiguration route_config; + envoy::api::v2::RouteConfiguration route_config; auto json_object_ptr = Json::Factory::loadFromString(json); Envoy::Config::RdsJson::translateRouteConfiguration(*json_object_ptr, route_config); config_.reset(new ConfigImpl(route_config, runtime_, cm_, true)); diff --git a/test/common/ssl/context_impl_test.cc b/test/common/ssl/context_impl_test.cc index bded5be55ecfb..cd1d73a8c625f 100644 --- a/test/common/ssl/context_impl_test.cc +++ b/test/common/ssl/context_impl_test.cc @@ -178,9 +178,9 @@ class SslServerContextImplTicketTest : public SslContextImplTest { ServerContextPtr server_ctx(manager.createSslServerContext("", {}, store, cfg, true)); } - static void loadConfigV2(envoy::api::v2::auth::DownstreamTlsContext& cfg) { + static void loadConfigV2(envoy::api::v2::DownstreamTlsContext& cfg) { // Must add a certificate for the config to be considered valid. - envoy::api::v2::auth::TlsCertificate* server_cert = + envoy::api::v2::TlsCertificate* server_cert = cfg.mutable_common_tls_context()->add_tls_certificates(); server_cert->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_tmpdir }}/unittestcert.pem")); @@ -245,42 +245,42 @@ TEST_F(SslServerContextImplTicketTest, TicketKeyInvalidCannotRead) { } TEST_F(SslServerContextImplTicketTest, TicketKeyNone) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; EXPECT_NO_THROW(loadConfigV2(cfg)); } TEST_F(SslServerContextImplTicketTest, TicketKeyInlineBytesSuccess) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; cfg.mutable_session_ticket_keys()->add_keys()->set_inline_bytes(std::string(80, '\0')); EXPECT_NO_THROW(loadConfigV2(cfg)); } TEST_F(SslServerContextImplTicketTest, TicketKeyInlineStringSuccess) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; cfg.mutable_session_ticket_keys()->add_keys()->set_inline_string(std::string(80, '\0')); EXPECT_NO_THROW(loadConfigV2(cfg)); } TEST_F(SslServerContextImplTicketTest, TicketKeyInlineBytesFailTooBig) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; cfg.mutable_session_ticket_keys()->add_keys()->set_inline_bytes(std::string(81, '\0')); EXPECT_THROW(loadConfigV2(cfg), EnvoyException); } TEST_F(SslServerContextImplTicketTest, TicketKeyInlineStringFailTooBig) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; cfg.mutable_session_ticket_keys()->add_keys()->set_inline_string(std::string(81, '\0')); EXPECT_THROW(loadConfigV2(cfg), EnvoyException); } TEST_F(SslServerContextImplTicketTest, TicketKeyInlineBytesFailTooSmall) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; cfg.mutable_session_ticket_keys()->add_keys()->set_inline_bytes(std::string(79, '\0')); EXPECT_THROW(loadConfigV2(cfg), EnvoyException); } TEST_F(SslServerContextImplTicketTest, TicketKeyInlineStringFailTooSmall) { - envoy::api::v2::auth::DownstreamTlsContext cfg; + envoy::api::v2::DownstreamTlsContext cfg; cfg.mutable_session_ticket_keys()->add_keys()->set_inline_string(std::string(79, '\0')); EXPECT_THROW(loadConfigV2(cfg), EnvoyException); } diff --git a/test/common/ssl/ssl_socket_test.cc b/test/common/ssl/ssl_socket_test.cc index b7e358a665ef9..f1bde2f0fe41e 100644 --- a/test/common/ssl/ssl_socket_test.cc +++ b/test/common/ssl/ssl_socket_test.cc @@ -117,8 +117,8 @@ void testUtil(const std::string& client_ctx_json, const std::string& server_ctx_ } } -const std::string testUtilV2(const envoy::api::v2::listener::Listener& server_proto, - const envoy::api::v2::auth::UpstreamTlsContext& client_ctx_proto, +const std::string testUtilV2(const envoy::api::v2::Listener& server_proto, + const envoy::api::v2::UpstreamTlsContext& client_ctx_proto, const std::string& client_session, bool expect_success, const std::string& expected_protocol_version, const std::string& expected_server_cert_digest, @@ -273,9 +273,9 @@ TEST_P(SslSocketTest, GetCertDigest) { } TEST_P(SslSocketTest, GetCertDigestInline) { - envoy::api::v2::listener::Listener listener; - envoy::api::v2::listener::FilterChain* filter_chain = listener.add_filter_chains(); - envoy::api::v2::auth::TlsCertificate* server_cert = + envoy::api::v2::Listener listener; + envoy::api::v2::FilterChain* filter_chain = listener.add_filter_chains(); + envoy::api::v2::TlsCertificate* server_cert = filter_chain->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); // From test/common/ssl/test_data/san_dns_cert.pem. @@ -360,8 +360,8 @@ TEST_P(SslSocketTest, GetCertDigestInline) { "SA==\n" "-----END CERTIFICATE-----"); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; - envoy::api::v2::auth::TlsCertificate* client_cert = + envoy::api::v2::UpstreamTlsContext client_ctx; + envoy::api::v2::TlsCertificate* client_cert = client_ctx.mutable_common_tls_context()->add_tls_certificates(); // From test/common/ssl/test_data/san_uri_cert.pem. @@ -1283,19 +1283,19 @@ TEST_P(SslSocketTest, SslError) { } TEST_P(SslSocketTest, ProtocolVersions) { - envoy::api::v2::listener::Listener listener; - envoy::api::v2::listener::FilterChain* filter_chain = listener.add_filter_chains(); - envoy::api::v2::auth::TlsCertificate* server_cert = + envoy::api::v2::Listener listener; + envoy::api::v2::FilterChain* filter_chain = listener.add_filter_chains(); + envoy::api::v2::TlsCertificate* server_cert = filter_chain->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); server_cert->mutable_private_key()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_key.pem")); - envoy::api::v2::auth::TlsParameters* server_params = + envoy::api::v2::TlsParameters* server_params = filter_chain->mutable_tls_context()->mutable_common_tls_context()->mutable_tls_params(); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; - envoy::api::v2::auth::TlsParameters* client_params = + envoy::api::v2::UpstreamTlsContext client_ctx; + envoy::api::v2::TlsParameters* client_params = client_ctx.mutable_common_tls_context()->mutable_tls_params(); // Connection using defaults (client & server) succeeds, negotiating TLSv1.2. @@ -1303,74 +1303,74 @@ TEST_P(SslSocketTest, ProtocolVersions) { // Connection using TLSv1.0 (client) and defaults (server) succeeds. // ssl.handshake logged by both: client & server. - client_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_0); - client_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_0); + client_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_0); + client_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_0); testUtilV2(listener, client_ctx, "", true, "TLSv1", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using TLSv1.1 (client) and defaults (server) succeeds. // ssl.handshake logged by both: client & server. - client_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_1); - client_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_1); + client_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_1); + client_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_1); testUtilV2(listener, client_ctx, "", true, "TLSv1.1", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using TLSv1.2 (client) and defaults (server) succeeds. // ssl.handshake logged by both: client & server. - client_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_2); - client_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_2); + client_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_2); + client_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_2); testUtilV2(listener, client_ctx, "", true, "TLSv1.2", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using TLSv1.3 (client) and defaults (server) fails. - client_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_3); - client_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_3); + client_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_3); + client_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_3); testUtilV2(listener, client_ctx, "", false, "", "", "", "", "ssl.connection_error", 1, GetParam()); // Connection using TLSv1.3 (client) and TLSv1.0-1.3 (server) succeeds. // ssl.handshake logged by both: client & server. - server_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_0); - server_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_3); + server_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_0); + server_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_3); testUtilV2(listener, client_ctx, "", true, "TLSv1.3", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using defaults (client) and TLSv1.0 (server) succeeds. // ssl.handshake logged by both: client & server. client_params->clear_tls_minimum_protocol_version(); client_params->clear_tls_maximum_protocol_version(); - server_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_0); - server_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_0); + server_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_0); + server_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_0); testUtilV2(listener, client_ctx, "", true, "TLSv1", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using defaults (client) and TLSv1.1 (server) succeeds. // ssl.handshake logged by both: client & server. - server_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_1); - server_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_1); + server_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_1); + server_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_1); testUtilV2(listener, client_ctx, "", true, "TLSv1.1", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using defaults (client) and TLSv1.2 (server) succeeds. // ssl.handshake logged by both: client & server. - server_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_2); - server_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_2); + server_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_2); + server_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_2); testUtilV2(listener, client_ctx, "", true, "TLSv1.2", "", "", "", "ssl.handshake", 2, GetParam()); // Connection using defaults (client) and TLSv1.3 (server) succeeds. - server_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_3); - server_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_3); + server_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_3); + server_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_3); testUtilV2(listener, client_ctx, "", false, "", "", "", "", "ssl.connection_error", 1, GetParam()); // Connection using TLSv1.0-TLSv1.3 (client) and TLSv1.3 (server) succeeds. // ssl.handshake logged by both: client & server. - client_params->set_tls_minimum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_0); - client_params->set_tls_maximum_protocol_version(envoy::api::v2::auth::TlsParameters::TLSv1_3); + client_params->set_tls_minimum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_0); + client_params->set_tls_maximum_protocol_version(envoy::api::v2::TlsParameters::TLSv1_3); testUtilV2(listener, client_ctx, "", true, "TLSv1.3", "", "", "", "ssl.handshake", 2, GetParam()); } TEST_P(SslSocketTest, SniCertificate) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_dns_cert.pem: server1.example.com - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("server1.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); @@ -1378,17 +1378,17 @@ TEST_P(SslSocketTest, SniCertificate) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_key.pem")); // san_multiple_dns_cert.pem: server2.example.com, *.example.com - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("server2.example.com"); filter_chain2->mutable_filter_chain_match()->add_sni_domains("*.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); server_cert2->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_key.pem")); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Connection to server1.example.com succeeds, client receives san_dns_cert.pem (exact match). // ssl.handshake logged by both: client & server. @@ -1416,8 +1416,8 @@ TEST_P(SslSocketTest, SniCertificate) { GetParam()); // no_san_cert.pem: * (no SNI restrictions) - envoy::api::v2::listener::FilterChain* filter_chain3 = listener.add_filter_chains(); - envoy::api::v2::auth::TlsCertificate* server_cert3 = + envoy::api::v2::FilterChain* filter_chain3 = listener.add_filter_chains(); + envoy::api::v2::TlsCertificate* server_cert3 = filter_chain3->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert3->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/no_san_cert.pem")); @@ -1440,13 +1440,13 @@ TEST_P(SslSocketTest, SniCertificate) { } TEST_P(SslSocketTest, SniSessionResumption) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_dns_cert.pem: server1.example.com, * - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("server1.example.com"); filter_chain1->mutable_filter_chain_match()->add_sni_domains(""); // Catch-all, no SNI. - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); @@ -1456,10 +1456,10 @@ TEST_P(SslSocketTest, SniSessionResumption) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/ticket_key_a")); // san_multiple_dns_cert.pem: server2.example.com, *.example.com - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("server2.example.com"); filter_chain2->mutable_filter_chain_match()->add_sni_domains("*.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); @@ -1469,9 +1469,9 @@ TEST_P(SslSocketTest, SniSessionResumption) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/ticket_key_a")); // san_multiple_dns_cert.pem: protected.example.com (same certificate as #2, but different SNI) - envoy::api::v2::listener::FilterChain* filter_chain3 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain3 = listener.add_filter_chains(); filter_chain3->mutable_filter_chain_match()->add_sni_domains("protected.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert3 = + envoy::api::v2::TlsCertificate* server_cert3 = filter_chain3->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert3->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); @@ -1480,7 +1480,7 @@ TEST_P(SslSocketTest, SniSessionResumption) { filter_chain3->mutable_tls_context()->mutable_session_ticket_keys()->add_keys()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/ticket_key_a")); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Connection to www.example.com succeeds, new session established. client_ctx.set_sni("www.example.com"); @@ -1519,12 +1519,12 @@ TEST_P(SslSocketTest, SniSessionResumption) { } TEST_P(SslSocketTest, SniClientCertificate) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_multiple_dns_cert.pem: *.example.com - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("*.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); @@ -1535,9 +1535,9 @@ TEST_P(SslSocketTest, SniClientCertificate) { // san_multiple_dns_cert.pem: protected.example.com // (same certificate as #1, but requires Client Certificate) - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("protected.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); @@ -1546,7 +1546,7 @@ TEST_P(SslSocketTest, SniClientCertificate) { filter_chain2->mutable_tls_context()->mutable_session_ticket_keys()->add_keys()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/ticket_key_a")); filter_chain2->mutable_tls_context()->mutable_require_client_certificate()->set_value(true); - envoy::api::v2::auth::CertificateValidationContext* validation_ctx2 = + envoy::api::v2::CertificateValidationContext* validation_ctx2 = filter_chain2->mutable_tls_context() ->mutable_common_tls_context() ->mutable_validation_context(); @@ -1554,7 +1554,7 @@ TEST_P(SslSocketTest, SniClientCertificate) { validation_ctx2->mutable_trusted_ca()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/ca_cert.pem")); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Connection to www.example.com succeeds. // ssl.handshake logged by both: client & server. @@ -1570,7 +1570,7 @@ TEST_P(SslSocketTest, SniClientCertificate) { // Connection to protected.example.com with a valid client certificate fails, beacuse its SAN // is not whitelisted. - envoy::api::v2::auth::TlsCertificate* client_cert = + envoy::api::v2::TlsCertificate* client_cert = client_ctx.mutable_common_tls_context()->add_tls_certificates(); client_cert->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_uri_cert.pem")); @@ -1594,12 +1594,12 @@ TEST_P(SslSocketTest, SniClientCertificate) { } TEST_P(SslSocketTest, SniALPN) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_dns_cert.pem: server1.example.com - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("server1.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); @@ -1607,20 +1607,20 @@ TEST_P(SslSocketTest, SniALPN) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_key.pem")); // san_multiple_dns_cert.pem: server2.example.com - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("server2.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); server_cert2->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_key.pem")); - envoy::api::v2::auth::CommonTlsContext* server_ctx1 = + envoy::api::v2::CommonTlsContext* server_ctx1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::CommonTlsContext* server_ctx2 = + envoy::api::v2::CommonTlsContext* server_ctx2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Test ALPN. server_ctx1->add_alpn_protocols("srv1"); @@ -1644,12 +1644,12 @@ TEST_P(SslSocketTest, SniALPN) { } TEST_P(SslSocketTest, SniCipherSuites) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_dns_cert.pem: server1.example.com - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("server1.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); @@ -1657,20 +1657,20 @@ TEST_P(SslSocketTest, SniCipherSuites) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_key.pem")); // san_multiple_dns_cert.pem: server2.example.com - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("server2.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); server_cert2->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_key.pem")); - envoy::api::v2::auth::CommonTlsContext* server_ctx1 = + envoy::api::v2::CommonTlsContext* server_ctx1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::CommonTlsContext* server_ctx2 = + envoy::api::v2::CommonTlsContext* server_ctx2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Test cipher suites. server_ctx1->mutable_tls_params()->add_cipher_suites("ECDHE-RSA-CHACHA20-POLY1305"); @@ -1707,12 +1707,12 @@ TEST_P(SslSocketTest, SniCipherSuites) { } TEST_P(SslSocketTest, SniEcdhCurves) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_dns_cert.pem: server1.example.com - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("server1.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); @@ -1720,20 +1720,20 @@ TEST_P(SslSocketTest, SniEcdhCurves) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_key.pem")); // san_multiple_dns_cert.pem: server2.example.com - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("server2.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); server_cert2->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_key.pem")); - envoy::api::v2::auth::CommonTlsContext* server_ctx1 = + envoy::api::v2::CommonTlsContext* server_ctx1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::CommonTlsContext* server_ctx2 = + envoy::api::v2::CommonTlsContext* server_ctx2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Test ECDH curves. server_ctx1->mutable_tls_params()->add_cipher_suites("ECDHE-RSA-AES128-GCM-SHA256"); @@ -1770,12 +1770,12 @@ TEST_P(SslSocketTest, SniEcdhCurves) { } TEST_P(SslSocketTest, SniProtocolVersions) { - envoy::api::v2::listener::Listener listener; + envoy::api::v2::Listener listener; // san_dns_cert.pem: server1.example.com - envoy::api::v2::listener::FilterChain* filter_chain1 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain1 = listener.add_filter_chains(); filter_chain1->mutable_filter_chain_match()->add_sni_domains("server1.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert1 = + envoy::api::v2::TlsCertificate* server_cert1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert1->mutable_certificate_chain()->set_filename( TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_cert.pem")); @@ -1783,39 +1783,39 @@ TEST_P(SslSocketTest, SniProtocolVersions) { TestEnvironment::substitute("{{ test_rundir }}/test/common/ssl/test_data/san_dns_key.pem")); // san_multiple_dns_cert.pem: server2.example.com - envoy::api::v2::listener::FilterChain* filter_chain2 = listener.add_filter_chains(); + envoy::api::v2::FilterChain* filter_chain2 = listener.add_filter_chains(); filter_chain2->mutable_filter_chain_match()->add_sni_domains("server2.example.com"); - envoy::api::v2::auth::TlsCertificate* server_cert2 = + envoy::api::v2::TlsCertificate* server_cert2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context()->add_tls_certificates(); server_cert2->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_cert.pem")); server_cert2->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/common/ssl/test_data/san_multiple_dns_key.pem")); - envoy::api::v2::auth::CommonTlsContext* server_ctx1 = + envoy::api::v2::CommonTlsContext* server_ctx1 = filter_chain1->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::CommonTlsContext* server_ctx2 = + envoy::api::v2::CommonTlsContext* server_ctx2 = filter_chain2->mutable_tls_context()->mutable_common_tls_context(); - envoy::api::v2::auth::UpstreamTlsContext client_ctx; + envoy::api::v2::UpstreamTlsContext client_ctx; // Test protocol versions. server_ctx1->mutable_tls_params()->set_tls_minimum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_2); + envoy::api::v2::TlsParameters::TLSv1_2); server_ctx1->mutable_tls_params()->set_tls_maximum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_3); + envoy::api::v2::TlsParameters::TLSv1_3); server_ctx2->mutable_tls_params()->set_tls_minimum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_0); + envoy::api::v2::TlsParameters::TLSv1_0); server_ctx2->mutable_tls_params()->set_tls_maximum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_2); + envoy::api::v2::TlsParameters::TLSv1_2); // Connection to server1.example.com using TLSv1.3 succeeds. // ssl.handshake logged by both: client & server. client_ctx.set_sni("server1.example.com"); client_ctx.mutable_common_tls_context()->mutable_tls_params()->set_tls_minimum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_3); + envoy::api::v2::TlsParameters::TLSv1_3); client_ctx.mutable_common_tls_context()->mutable_tls_params()->set_tls_maximum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_3); + envoy::api::v2::TlsParameters::TLSv1_3); testUtilV2(listener, client_ctx, "", true, "TLSv1.3", "1406294e80c818158697d65d2aaca16748ff132442ab0e2f28bc1109f1d47a2e", "", "", "ssl.handshake", 2, GetParam()); @@ -1828,9 +1828,9 @@ TEST_P(SslSocketTest, SniProtocolVersions) { // Connection to server1.example.com using TLSv1.0 fails. client_ctx.set_sni("server1.example.com"); client_ctx.mutable_common_tls_context()->mutable_tls_params()->set_tls_minimum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_0); + envoy::api::v2::TlsParameters::TLSv1_0); client_ctx.mutable_common_tls_context()->mutable_tls_params()->set_tls_maximum_protocol_version( - envoy::api::v2::auth::TlsParameters::TLSv1_0); + envoy::api::v2::TlsParameters::TLSv1_0); testUtilV2(listener, client_ctx, "", false, "", "", "", "", "ssl.connection_error", 1, GetParam()); diff --git a/test/common/stats/BUILD b/test/common/stats/BUILD index 64f69c29f30a3..822c200268c8f 100644 --- a/test/common/stats/BUILD +++ b/test/common/stats/BUILD @@ -11,10 +11,10 @@ envoy_package() envoy_cc_test( name = "stats_impl_test", srcs = ["stats_impl_test.cc"], + external_deps = ["envoy_stats"], deps = [ "//source/common/stats:stats_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/config/metrics/v2:stats_cc", ], ) diff --git a/test/common/stats/grpc_metrics_service_impl_test.cc b/test/common/stats/grpc_metrics_service_impl_test.cc index 67026f8724aa8..a6315ab3ac53d 100644 --- a/test/common/stats/grpc_metrics_service_impl_test.cc +++ b/test/common/stats/grpc_metrics_service_impl_test.cc @@ -19,7 +19,7 @@ namespace Metrics { class GrpcMetricsStreamerImplTest : public testing::Test { public: typedef Grpc::MockAsyncStream MockMetricsStream; - typedef Grpc::TypedAsyncStreamCallbacks + typedef Grpc::TypedAsyncStreamCallbacks MetricsServiceCallbacks; GrpcMetricsStreamerImplTest() { @@ -56,11 +56,10 @@ TEST_F(GrpcMetricsStreamerImplTest, BasicFlow) { expectStreamStart(stream1, &callbacks1); EXPECT_CALL(local_info_, node()); EXPECT_CALL(stream1, sendMessage(_, false)); - envoy::service::metrics::v2::StreamMetricsMessage message_metrics1; + envoy::api::v2::StreamMetricsMessage message_metrics1; streamer_->send(message_metrics1); // Verify that sending an empty response message doesn't do anything bad. - callbacks1->onReceiveMessage( - std::make_unique()); + callbacks1->onReceiveMessage(std::make_unique()); } // Test that stream failure is handled correctly. @@ -74,21 +73,21 @@ TEST_F(GrpcMetricsStreamerImplTest, StreamFailure) { return nullptr; })); EXPECT_CALL(local_info_, node()); - envoy::service::metrics::v2::StreamMetricsMessage message_metrics1; + envoy::api::v2::StreamMetricsMessage message_metrics1; streamer_->send(message_metrics1); } class MockGrpcMetricsStreamer : public GrpcMetricsStreamer { public: // GrpcMetricsStreamer - MOCK_METHOD1(send, void(envoy::service::metrics::v2::StreamMetricsMessage& message)); + MOCK_METHOD1(send, void(envoy::api::v2::StreamMetricsMessage& message)); }; class TestGrpcMetricsStreamer : public GrpcMetricsStreamer { public: int metric_count; // GrpcMetricsStreamer - void send(envoy::service::metrics::v2::StreamMetricsMessage& message) { + void send(envoy::api::v2::StreamMetricsMessage& message) { metric_count = message.envoy_metrics_size(); } }; diff --git a/test/common/stats/stats_impl_test.cc b/test/common/stats/stats_impl_test.cc index c0ce225f60b06..e79147888b737 100644 --- a/test/common/stats/stats_impl_test.cc +++ b/test/common/stats/stats_impl_test.cc @@ -1,7 +1,6 @@ #include #include -#include "envoy/config/metrics/v2/stats.pb.h" #include "envoy/stats/stats_macros.h" #include "common/config/well_known_names.h" @@ -9,6 +8,7 @@ #include "test/test_common/utility.h" +#include "api/stats.pb.h" #include "gtest/gtest.h" namespace Envoy { @@ -368,7 +368,7 @@ TEST(TagExtractorTest, DefaultTagExtractors) { } TEST(TagProducerTest, CheckConstructor) { - envoy::config::metrics::v2::StatsConfig stats_config; + envoy::api::v2::StatsConfig stats_config; // Should pass there were no tag name conflict. auto& tag_specifier1 = *stats_config.mutable_stats_tags()->Add(); diff --git a/test/common/upstream/BUILD b/test/common/upstream/BUILD index c6068e5f99a09..a43ad05814079 100644 --- a/test/common/upstream/BUILD +++ b/test/common/upstream/BUILD @@ -53,6 +53,7 @@ envoy_cc_test( envoy_cc_test( name = "eds_test", srcs = ["eds_test.cc"], + external_deps = ["envoy_eds"], deps = [ ":utility_lib", "//source/common/config:utility_lib", @@ -64,7 +65,6 @@ envoy_cc_test( "//test/mocks/ssl:ssl_mocks", "//test/mocks/upstream:upstream_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -135,6 +135,7 @@ envoy_cc_test( envoy_cc_test( name = "load_stats_reporter_test", srcs = ["load_stats_reporter_test.cc"], + external_deps = ["envoy_eds"], deps = [ "//source/common/stats:stats_lib", "//source/common/upstream:load_stats_reporter_lib", @@ -142,9 +143,6 @@ envoy_cc_test( "//test/mocks/grpc:grpc_mocks", "//test/mocks/upstream:upstream_mocks", "//test/test_common:utility_lib", - "@envoy_api//envoy/api/v2/endpoint:endpoint_cc", - "@envoy_api//envoy/api/v2/endpoint:load_report_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) @@ -235,6 +233,7 @@ envoy_cc_test( name = "sds_test", srcs = ["sds_test.cc"], data = glob(["test_data/**"]), + external_deps = ["envoy_base"], deps = [ ":utility_lib", "//source/common/config:utility_lib", @@ -250,7 +249,6 @@ envoy_cc_test( "//test/mocks/upstream:upstream_mocks", "//test/test_common:environment_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/api/v2:base_cc", ], ) diff --git a/test/common/upstream/cds_api_impl_test.cc b/test/common/upstream/cds_api_impl_test.cc index 54b6919acc71c..f709cbf82ac94 100644 --- a/test/common/upstream/cds_api_impl_test.cc +++ b/test/common/upstream/cds_api_impl_test.cc @@ -63,7 +63,7 @@ class CdsApiImplTest : public testing::Test { void expectAdd(const std::string& cluster_name) { EXPECT_CALL(cm_, addOrUpdatePrimaryCluster(_)) - .WillOnce(Invoke([cluster_name](const envoy::api::v2::cluster::Cluster& cluster) -> bool { + .WillOnce(Invoke([cluster_name](const envoy::api::v2::Cluster& cluster) -> bool { EXPECT_EQ(cluster_name, cluster.name()); return true; })); @@ -114,7 +114,7 @@ TEST_F(CdsApiImplTest, ValidateFail) { setup(true); - Protobuf::RepeatedPtrField clusters; + Protobuf::RepeatedPtrField clusters; clusters.Add(); EXPECT_THROW(dynamic_cast(cds_.get())->onConfigUpdate(clusters), diff --git a/test/common/upstream/cluster_manager_impl_test.cc b/test/common/upstream/cluster_manager_impl_test.cc index 66826f45e5b53..8803aec6d9ce4 100644 --- a/test/common/upstream/cluster_manager_impl_test.cc +++ b/test/common/upstream/cluster_manager_impl_test.cc @@ -45,14 +45,13 @@ class TestClusterManagerFactory : public ClusterManagerFactory { public: TestClusterManagerFactory() { ON_CALL(*this, clusterFromProto_(_, _, _, _)) - .WillByDefault( - Invoke([&](const envoy::api::v2::cluster::Cluster& cluster, ClusterManager& cm, - Outlier::EventLoggerSharedPtr outlier_event_logger, - bool added_via_api) -> ClusterSharedPtr { - return ClusterImplBase::create(cluster, cm, stats_, tls_, dns_resolver_, - ssl_context_manager_, runtime_, random_, dispatcher_, - local_info_, outlier_event_logger, added_via_api); - })); + .WillByDefault(Invoke([&](const envoy::api::v2::Cluster& cluster, ClusterManager& cm, + Outlier::EventLoggerSharedPtr outlier_event_logger, + bool added_via_api) -> ClusterSharedPtr { + return ClusterImplBase::create(cluster, cm, stats_, tls_, dns_resolver_, + ssl_context_manager_, runtime_, random_, dispatcher_, + local_info_, outlier_event_logger, added_via_api); + })); } Http::ConnectionPool::InstancePtr allocateConnPool(Event::Dispatcher&, HostConstSharedPtr host, @@ -60,8 +59,7 @@ class TestClusterManagerFactory : public ClusterManagerFactory { return Http::ConnectionPool::InstancePtr{allocateConnPool_(host)}; } - ClusterSharedPtr clusterFromProto(const envoy::api::v2::cluster::Cluster& cluster, - ClusterManager& cm, + ClusterSharedPtr clusterFromProto(const envoy::api::v2::Cluster& cluster, ClusterManager& cm, Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) override { return clusterFromProto_(cluster, cm, outlier_event_logger, added_via_api); @@ -72,24 +70,25 @@ class TestClusterManagerFactory : public ClusterManagerFactory { return CdsApiPtr{createCds_()}; } - ClusterManagerPtr - clusterManagerFromProto(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Stats::Store& stats, ThreadLocal::Instance& tls, Runtime::Loader& runtime, - Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, - AccessLog::AccessLogManager& log_manager) override { + ClusterManagerPtr clusterManagerFromProto(const envoy::api::v2::Bootstrap& bootstrap, + Stats::Store& stats, ThreadLocal::Instance& tls, + Runtime::Loader& runtime, + Runtime::RandomGenerator& random, + const LocalInfo::LocalInfo& local_info, + AccessLog::AccessLogManager& log_manager) override { return ClusterManagerPtr{ clusterManagerFromProto_(bootstrap, stats, tls, runtime, random, local_info, log_manager)}; } MOCK_METHOD7(clusterManagerFromProto_, - ClusterManager*(const envoy::config::bootstrap::v2::Bootstrap& bootstrap, - Stats::Store& stats, ThreadLocal::Instance& tls, - Runtime::Loader& runtime, Runtime::RandomGenerator& random, + ClusterManager*(const envoy::api::v2::Bootstrap& bootstrap, Stats::Store& stats, + ThreadLocal::Instance& tls, Runtime::Loader& runtime, + Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info, AccessLog::AccessLogManager& log_manager)); MOCK_METHOD1(allocateConnPool_, Http::ConnectionPool::Instance*(HostConstSharedPtr host)); MOCK_METHOD4(clusterFromProto_, - ClusterSharedPtr(const envoy::api::v2::cluster::Cluster& cluster, ClusterManager& cm, + ClusterSharedPtr(const envoy::api::v2::Cluster& cluster, ClusterManager& cm, Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api)); MOCK_METHOD0(createCds_, CdsApi*()); @@ -107,7 +106,7 @@ class TestClusterManagerFactory : public ClusterManagerFactory { class ClusterManagerImplTest : public testing::Test { public: - void create(const envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + void create(const envoy::api::v2::Bootstrap& bootstrap) { cluster_manager_.reset(new ClusterManagerImpl( bootstrap, factory_, factory_.stats_, factory_.tls_, factory_.runtime_, factory_.random_, factory_.local_info_, log_manager_, factory_.dispatcher_)); @@ -118,15 +117,15 @@ class ClusterManagerImplTest : public testing::Test { AccessLog::MockAccessLogManager log_manager_; }; -envoy::config::bootstrap::v2::Bootstrap parseBootstrapFromJson(const std::string& json_string) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; +envoy::api::v2::Bootstrap parseBootstrapFromJson(const std::string& json_string) { + envoy::api::v2::Bootstrap bootstrap; auto json_object_ptr = Json::Factory::loadFromString(json_string); Config::BootstrapJson::translateClusterManagerBootstrap(*json_object_ptr, bootstrap); return bootstrap; } -envoy::config::bootstrap::v2::Bootstrap parseBootstrapFromV2Yaml(const std::string& yaml) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; +envoy::api::v2::Bootstrap parseBootstrapFromV2Yaml(const std::string& yaml) { + envoy::api::v2::Bootstrap bootstrap; MessageUtil::loadFromYaml(yaml, bootstrap); return bootstrap; } @@ -376,11 +375,10 @@ TEST_F(ClusterManagerImplTest, SubsetLoadBalancerInitialization) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = parseBootstrapFromJson(json); - envoy::api::v2::cluster::Cluster::LbSubsetConfig* subset_config = + envoy::api::v2::Bootstrap bootstrap = parseBootstrapFromJson(json); + envoy::api::v2::Cluster::LbSubsetConfig* subset_config = bootstrap.mutable_static_resources()->mutable_clusters(0)->mutable_lb_subset_config(); - subset_config->set_fallback_policy( - envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT); + subset_config->set_fallback_policy(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT); subset_config->add_subset_selectors()->add_keys("x"); create(bootstrap); @@ -403,11 +401,10 @@ TEST_F(ClusterManagerImplTest, SubsetLoadBalancerRestriction) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = parseBootstrapFromJson(json); - envoy::api::v2::cluster::Cluster::LbSubsetConfig* subset_config = + envoy::api::v2::Bootstrap bootstrap = parseBootstrapFromJson(json); + envoy::api::v2::Cluster::LbSubsetConfig* subset_config = bootstrap.mutable_static_resources()->mutable_clusters(0)->mutable_lb_subset_config(); - subset_config->set_fallback_policy( - envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT); + subset_config->set_fallback_policy(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT); subset_config->add_subset_selectors()->add_keys("x"); EXPECT_THROW_WITH_MESSAGE( diff --git a/test/common/upstream/eds_test.cc b/test/common/upstream/eds_test.cc index afe64dd37b287..fda40b967b466 100644 --- a/test/common/upstream/eds_test.cc +++ b/test/common/upstream/eds_test.cc @@ -1,5 +1,3 @@ -#include "envoy/service/discovery/v2/eds.pb.h" - #include "common/config/utility.h" #include "common/upstream/eds.h" @@ -10,6 +8,7 @@ #include "test/mocks/upstream/mocks.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -54,7 +53,7 @@ class EdsTest : public testing::Test { Stats::IsolatedStoreImpl stats_; Ssl::MockContextManager ssl_context_manager_; - envoy::api::v2::cluster::Cluster eds_cluster_; + envoy::api::v2::Cluster eds_cluster_; NiceMock cm_; NiceMock dispatcher_; std::shared_ptr cluster_; @@ -65,14 +64,14 @@ class EdsTest : public testing::Test { // Negative test for protoc-gen-validate constraints. TEST_F(EdsTest, ValidateFail) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; resources.Add(); EXPECT_THROW(cluster_->onConfigUpdate(resources), ProtoValidationException); } // Validate that onConfigUpdate() with unexpected cluster names rejects config. TEST_F(EdsTest, OnConfigUpdateWrongName) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("wrong name"); bool initialized = false; @@ -93,7 +92,7 @@ TEST_F(EdsTest, OnConfigUpdateEmpty) { // Validate that onConfigUpdate() with unexpected cluster vector size rejects config. TEST_F(EdsTest, OnConfigUpdateWrongSize) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; bool initialized = false; cluster_->initialize([&initialized] { initialized = true; }); auto* cluster_load_assignment = resources.Add(); @@ -107,7 +106,7 @@ TEST_F(EdsTest, OnConfigUpdateWrongSize) { // Validate that onConfigUpdate() with the expected cluster accepts config. TEST_F(EdsTest, OnConfigUpdateSuccess) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); bool initialized = false; @@ -126,7 +125,7 @@ TEST_F(EdsTest, NoServiceNameOnSuccessConfigUpdate) { "lb_type": "round_robin" } )EOF"); - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("name"); bool initialized = false; @@ -137,7 +136,7 @@ TEST_F(EdsTest, NoServiceNameOnSuccessConfigUpdate) { // Validate that onConfigUpdate() updates the endpoint metadata. TEST_F(EdsTest, EndpointMetadata) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); auto* endpoints = cluster_load_assignment->add_endpoints(); @@ -191,7 +190,7 @@ TEST_F(EdsTest, EndpointMetadata) { // Validate that onConfigUpdate() updates the endpoint locality. TEST_F(EdsTest, EndpointLocality) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); auto* endpoints = cluster_load_assignment->add_endpoints(); @@ -234,7 +233,7 @@ TEST_F(EdsTest, EndpointLocality) { // Validate that onConfigUpdate() updates bins hosts per locality as expected. TEST_F(EdsTest, EndpointHostsPerLocality) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); uint32_t port = 1000; @@ -301,7 +300,7 @@ TEST_F(EdsTest, EndpointHostsPerLocality) { // Validate that onConfigUpdate() updates bins hosts per priority as expected. TEST_F(EdsTest, EndpointHostsPerPriority) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); uint32_t port = 1000; @@ -361,7 +360,7 @@ TEST_F(EdsTest, EndpointHostsPerPriority) { // Make sure config updates with P!=0 are rejected for the local cluster. TEST_F(EdsTest, NoPriorityForLocalCluster) { cm_.local_cluster_name_ = "fare"; - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); uint32_t port = 1000; @@ -397,7 +396,7 @@ TEST_F(EdsTest, NoPriorityForLocalCluster) { // Set up an EDS config with multiple priorities and localities and make sure // they are loaded and reloaded as expected. TEST_F(EdsTest, PriorityAndLocality) { - Protobuf::RepeatedPtrField resources; + Protobuf::RepeatedPtrField resources; auto* cluster_load_assignment = resources.Add(); cluster_load_assignment->set_cluster_name("fare"); uint32_t port = 1000; diff --git a/test/common/upstream/load_balancer_impl_test.cc b/test/common/upstream/load_balancer_impl_test.cc index ec17cd2667b7c..0839b67e0341d 100644 --- a/test/common/upstream/load_balancer_impl_test.cc +++ b/test/common/upstream/load_balancer_impl_test.cc @@ -831,12 +831,11 @@ TEST_P(RandomLoadBalancerTest, Normal) { INSTANTIATE_TEST_CASE_P(PrimaryOrFailover, RandomLoadBalancerTest, ::testing::Values(true, false)); TEST(LoadBalancerSubsetInfoImplTest, DefaultConfigIsDiabled) { - auto subset_info = LoadBalancerSubsetInfoImpl( - envoy::api::v2::cluster::Cluster::LbSubsetConfig::default_instance()); + auto subset_info = + LoadBalancerSubsetInfoImpl(envoy::api::v2::Cluster::LbSubsetConfig::default_instance()); EXPECT_FALSE(subset_info.isEnabled()); - EXPECT_TRUE(subset_info.fallbackPolicy() == - envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK); + EXPECT_TRUE(subset_info.fallbackPolicy() == envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK); EXPECT_EQ(subset_info.defaultSubset().fields_size(), 0); EXPECT_EQ(subset_info.subsetKeys().size(), 0); } @@ -845,9 +844,8 @@ TEST(LoadBalancerSubsetInfoImplTest, SubsetConfig) { auto subset_value = ProtobufWkt::Value(); subset_value.set_string_value("the value"); - auto subset_config = envoy::api::v2::cluster::Cluster::LbSubsetConfig::default_instance(); - subset_config.set_fallback_policy( - envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET); + auto subset_config = envoy::api::v2::Cluster::LbSubsetConfig::default_instance(); + subset_config.set_fallback_policy(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET); subset_config.mutable_default_subset()->mutable_fields()->insert({"key", subset_value}); auto subset_selector = subset_config.mutable_subset_selectors()->Add(); subset_selector->add_keys("selector_key"); @@ -856,7 +854,7 @@ TEST(LoadBalancerSubsetInfoImplTest, SubsetConfig) { EXPECT_TRUE(subset_info.isEnabled()); EXPECT_TRUE(subset_info.fallbackPolicy() == - envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET); + envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET); EXPECT_EQ(subset_info.defaultSubset().fields_size(), 1); EXPECT_EQ(subset_info.defaultSubset().fields().at("key").string_value(), std::string("the value")); diff --git a/test/common/upstream/load_stats_reporter_test.cc b/test/common/upstream/load_stats_reporter_test.cc index 3d9480dd56c13..6a22d075708ab 100644 --- a/test/common/upstream/load_stats_reporter_test.cc +++ b/test/common/upstream/load_stats_reporter_test.cc @@ -1,6 +1,3 @@ -#include "envoy/api/v2/endpoint/load_report.pb.h" -#include "envoy/service/discovery/v2/eds.pb.h" - #include "common/stats/stats_impl.h" #include "common/upstream/load_stats_reporter.h" @@ -9,6 +6,7 @@ #include "test/mocks/upstream/mocks.h" #include "test/test_common/utility.h" +#include "api/eds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -45,9 +43,8 @@ class LoadStatsReporterTest : public testing::Test { node_, cm_, stats_store_, Grpc::AsyncClientPtr(async_client_), dispatcher_)); } - void expectSendMessage( - const std::vector& expected_cluster_stats) { - envoy::service::load_stats::v2::LoadStatsRequest expected_request; + void expectSendMessage(const std::vector& expected_cluster_stats) { + envoy::api::v2::LoadStatsRequest expected_request; expected_request.mutable_node()->MergeFrom(node_); std::copy(expected_cluster_stats.begin(), expected_cluster_stats.end(), Protobuf::RepeatedPtrFieldBackInserter(expected_request.mutable_cluster_stats())); @@ -55,8 +52,8 @@ class LoadStatsReporterTest : public testing::Test { } void deliverLoadStatsResponse(const std::vector& cluster_names) { - std::unique_ptr response( - new envoy::service::load_stats::v2::LoadStatsResponse()); + std::unique_ptr response( + new envoy::api::v2::LoadStatsResponse()); response->mutable_load_reporting_interval()->set_seconds(42); std::copy(cluster_names.begin(), cluster_names.end(), Protobuf::RepeatedPtrFieldBackInserter(response->mutable_clusters())); diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index 5e4f6e6973853..d4c2e00963d39 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -92,7 +92,7 @@ class OutlierDetectorImplTest : public testing::Test { CallbackChecker checker_; MockMonotonicTimeSource time_source_; std::shared_ptr event_logger_{new MockEventLogger()}; - envoy::api::v2::cluster::OutlierDetection empty_outlier_detection_; + envoy::api::v2::Cluster::OutlierDetection empty_outlier_detection_; }; TEST_F(OutlierDetectorImplTest, DetectorStaticConfig) { @@ -110,7 +110,7 @@ TEST_F(OutlierDetectorImplTest, DetectorStaticConfig) { } )EOF"; - envoy::api::v2::cluster::OutlierDetection outlier_detection; + envoy::api::v2::Cluster::OutlierDetection outlier_detection; Json::ObjectSharedPtr custom_config = Json::Factory::loadFromString(json); Config::CdsJson::translateOutlierDetection(*custom_config, outlier_detection); EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100))); diff --git a/test/common/upstream/ring_hash_lb_test.cc b/test/common/upstream/ring_hash_lb_test.cc index a5409480e1877..343e6cdd70eb6 100644 --- a/test/common/upstream/ring_hash_lb_test.cc +++ b/test/common/upstream/ring_hash_lb_test.cc @@ -53,7 +53,7 @@ class RingHashLoadBalancerTest : public ::testing::TestWithParam { std::shared_ptr info_{new NiceMock()}; Stats::IsolatedStoreImpl stats_store_; ClusterStats stats_; - Optional config_; + Optional config_; NiceMock runtime_; NiceMock random_; std::unique_ptr lb_; @@ -79,7 +79,7 @@ TEST_P(RingHashLoadBalancerTest, Basic) { hostSet().healthy_hosts_ = hostSet().hosts_; hostSet().runCallbacks({}, {}); - config_.value(envoy::api::v2::cluster::Cluster::RingHashLbConfig()); + config_.value(envoy::api::v2::Cluster::RingHashLbConfig()); config_.value().mutable_minimum_ring_size()->set_value(12); config_.value().mutable_deprecated_v1()->mutable_use_std_hash()->set_value(false); @@ -146,7 +146,7 @@ TEST_P(RingHashFailoverTest, BasicFailover) { failover_host_set_.healthy_hosts_ = {makeTestHost(info_, "tcp://127.0.0.1:82")}; failover_host_set_.hosts_ = failover_host_set_.healthy_hosts_; - config_.value(envoy::api::v2::cluster::Cluster::RingHashLbConfig()); + config_.value(envoy::api::v2::Cluster::RingHashLbConfig()); config_.value().mutable_minimum_ring_size()->set_value(12); config_.value().mutable_deprecated_v1()->mutable_use_std_hash()->set_value(false); init(); @@ -191,7 +191,7 @@ TEST_P(RingHashLoadBalancerTest, BasicWithStdHash) { hostSet().runCallbacks({}, {}); // use_std_hash defaults to true so don't set it here. - config_.value(envoy::api::v2::cluster::Cluster::RingHashLbConfig()); + config_.value(envoy::api::v2::Cluster::RingHashLbConfig()); config_.value().mutable_minimum_ring_size()->set_value(12); init(); @@ -239,7 +239,7 @@ TEST_P(RingHashLoadBalancerTest, UnevenHosts) { hostSet().healthy_hosts_ = hostSet().hosts_; hostSet().runCallbacks({}, {}); - config_.value(envoy::api::v2::cluster::Cluster::RingHashLbConfig()); + config_.value(envoy::api::v2::Cluster::RingHashLbConfig()); config_.value().mutable_minimum_ring_size()->set_value(3); config_.value().mutable_deprecated_v1()->mutable_use_std_hash()->set_value(false); init(); @@ -317,7 +317,7 @@ TEST_P(DISABLED_RingHashLoadBalancerTest, DetermineSpread) { host_set_.healthy_hosts_ = host_set_.hosts_; host_set_.runCallbacks({}, {}); - config_.value(envoy::api::v2::cluster::Cluster::RingHashLbConfig()); + config_.value(envoy::api::v2::Cluster::RingHashLbConfig()); config_.value().mutable_minimum_ring_size()->set_value(min_ring_size); config_.value().mutable_deprecated_v1()->mutable_use_std_hash()->set_value(false); RingHashLoadBalancer thread_aware_lb{priority_set_, stats_, runtime_, random_, config_}; diff --git a/test/common/upstream/sds_test.cc b/test/common/upstream/sds_test.cc index 20e66dd0a2639..b2bb7606ab8ac 100644 --- a/test/common/upstream/sds_test.cc +++ b/test/common/upstream/sds_test.cc @@ -4,8 +4,6 @@ #include #include -#include "envoy/api/v2/base.pb.h" - #include "common/config/utility.h" #include "common/filesystem/filesystem_impl.h" #include "common/http/message_impl.h" @@ -22,6 +20,7 @@ #include "test/test_common/printers.h" #include "test/test_common/utility.h" +#include "api/base.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -109,7 +108,7 @@ class SdsTest : public testing::Test { Stats::IsolatedStoreImpl stats_; Ssl::MockContextManager ssl_context_manager_; - envoy::api::v2::cluster::Cluster sds_cluster_; + envoy::api::v2::Cluster sds_cluster_; NiceMock cm_; Event::MockDispatcher dispatcher_; std::shared_ptr cluster_; diff --git a/test/common/upstream/subset_lb_test.cc b/test/common/upstream/subset_lb_test.cc index 86f86f2d08198..5968432ccb0a0 100644 --- a/test/common/upstream/subset_lb_test.cc +++ b/test/common/upstream/subset_lb_test.cc @@ -5,7 +5,6 @@ #include #include -#include "envoy/api/v2/cluster/cluster.pb.h" #include "envoy/common/optional.h" #include "common/config/metadata.h" @@ -16,6 +15,7 @@ #include "test/mocks/runtime/mocks.h" #include "test/mocks/upstream/mocks.h" +#include "api/cds.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -273,7 +273,7 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { void doLbTypeTest(LoadBalancerType type) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); lb_type_ = type; init({{"tcp://127.0.0.1:80", {{"version", "1.0"}}}}); @@ -291,7 +291,7 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { MockHostSet& host_set_ = *priority_set_.getMockHostSet(0); NiceMock subset_info_; std::shared_ptr info_{new NiceMock()}; - envoy::api::v2::cluster::Cluster::RingHashLbConfig ring_hash_lb_config_; + envoy::api::v2::Cluster::RingHashLbConfig ring_hash_lb_config_; NiceMock runtime_; NiceMock random_; Stats::IsolatedStoreImpl stats_store_; @@ -304,7 +304,7 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { TEST_F(SubsetLoadBalancerTest, NoFallback) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); init(); @@ -315,7 +315,7 @@ TEST_F(SubsetLoadBalancerTest, NoFallback) { TEST_P(SubsetLoadBalancerTest, NoFallbackAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); init(); @@ -328,7 +328,7 @@ TEST_P(SubsetLoadBalancerTest, NoFallbackAfterUpdate) { TEST_F(SubsetLoadBalancerTest, FallbackAnyEndpoint) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); init(); @@ -339,7 +339,7 @@ TEST_F(SubsetLoadBalancerTest, FallbackAnyEndpoint) { TEST_P(SubsetLoadBalancerTest, FallbackAnyEndpointAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); init(); @@ -353,7 +353,7 @@ TEST_P(SubsetLoadBalancerTest, FallbackAnyEndpointAfterUpdate) { TEST_F(SubsetLoadBalancerTest, FallbackDefaultSubset) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); const ProtobufWkt::Struct default_subset = makeDefaultSubset({{"version", "default"}}); EXPECT_CALL(subset_info_, defaultSubset()).WillRepeatedly(ReturnRef(default_subset)); @@ -370,7 +370,7 @@ TEST_F(SubsetLoadBalancerTest, FallbackDefaultSubset) { TEST_P(SubsetLoadBalancerTest, FallbackDefaultSubsetAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); const ProtobufWkt::Struct default_subset = makeDefaultSubset({{"version", "default"}}); EXPECT_CALL(subset_info_, defaultSubset()).WillRepeatedly(ReturnRef(default_subset)); @@ -392,7 +392,7 @@ TEST_P(SubsetLoadBalancerTest, FallbackDefaultSubsetAfterUpdate) { TEST_F(SubsetLoadBalancerTest, FallbackEmptyDefaultSubsetConvertsToAnyEndpoint) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); EXPECT_CALL(subset_info_, defaultSubset()) .WillRepeatedly(ReturnRef(ProtobufWkt::Struct::default_instance())); @@ -407,7 +407,7 @@ TEST_F(SubsetLoadBalancerTest, FallbackEmptyDefaultSubsetConvertsToAnyEndpoint) TEST_F(SubsetLoadBalancerTest, FallbackOnUnknownMetadata) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); init(); @@ -420,7 +420,7 @@ TEST_F(SubsetLoadBalancerTest, FallbackOnUnknownMetadata) { TEST_F(SubsetLoadBalancerTest, BalancesSubset) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -445,7 +445,7 @@ TEST_F(SubsetLoadBalancerTest, BalancesSubset) { TEST_P(SubsetLoadBalancerTest, BalancesSubsetAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -483,7 +483,7 @@ TEST_P(SubsetLoadBalancerTest, BalancesSubsetAfterUpdate) { // Test that adding backends to a failover group causes no problems. TEST_P(SubsetLoadBalancerTest, UpdateFailover) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -509,7 +509,7 @@ TEST_P(SubsetLoadBalancerTest, UpdateFailover) { TEST_P(SubsetLoadBalancerTest, UpdateRemovingLastSubsetHost) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -542,7 +542,7 @@ TEST_P(SubsetLoadBalancerTest, UpdateRemovingLastSubsetHost) { TEST_P(SubsetLoadBalancerTest, UpdateRemovingUnknownHost) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"stage", "version"}, {"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -564,7 +564,7 @@ TEST_P(SubsetLoadBalancerTest, UpdateRemovingUnknownHost) { TEST_F(SubsetLoadBalancerTest, BalancesDisjointSubsets) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}, {"hardware"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -587,7 +587,7 @@ TEST_F(SubsetLoadBalancerTest, BalancesDisjointSubsets) { TEST_F(SubsetLoadBalancerTest, BalancesOverlappingSubsets) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = { {"stage", "version"}, @@ -624,7 +624,7 @@ TEST_F(SubsetLoadBalancerTest, BalancesOverlappingSubsets) { TEST_F(SubsetLoadBalancerTest, BalancesNestedSubsets) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = { {"stage", "version"}, @@ -659,7 +659,7 @@ TEST_F(SubsetLoadBalancerTest, BalancesNestedSubsets) { TEST_F(SubsetLoadBalancerTest, IgnoresUnselectedMetadata) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -682,7 +682,7 @@ TEST_F(SubsetLoadBalancerTest, IgnoresUnselectedMetadata) { TEST_F(SubsetLoadBalancerTest, IgnoresHostsWithoutMetadata) { EXPECT_CALL(subset_info_, isEnabled()).WillRepeatedly(Return(true)); EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -725,7 +725,7 @@ TEST_P(SubsetLoadBalancerTest, LoadBalancerTypesRingHash) { TEST_F(SubsetLoadBalancerTest, ZoneAwareFallback) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); std::vector> subset_keys = {{"x"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -768,7 +768,7 @@ TEST_F(SubsetLoadBalancerTest, ZoneAwareFallback) { TEST_P(SubsetLoadBalancerTest, ZoneAwareFallbackAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); std::vector> subset_keys = {{"x"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -824,7 +824,7 @@ TEST_P(SubsetLoadBalancerTest, ZoneAwareFallbackAfterUpdate) { TEST_F(SubsetLoadBalancerTest, ZoneAwareFallbackDefaultSubset) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); const ProtobufWkt::Struct default_subset = makeDefaultSubset({{"version", "default"}}); EXPECT_CALL(subset_info_, defaultSubset()).WillRepeatedly(ReturnRef(default_subset)); @@ -878,7 +878,7 @@ TEST_F(SubsetLoadBalancerTest, ZoneAwareFallbackDefaultSubset) { TEST_P(SubsetLoadBalancerTest, ZoneAwareFallbackDefaultSubsetAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET)); const ProtobufWkt::Struct default_subset = makeDefaultSubset({{"version", "default"}}); EXPECT_CALL(subset_info_, defaultSubset()).WillRepeatedly(ReturnRef(default_subset)); @@ -945,7 +945,7 @@ TEST_P(SubsetLoadBalancerTest, ZoneAwareFallbackDefaultSubsetAfterUpdate) { TEST_F(SubsetLoadBalancerTest, ZoneAwareBalancesSubsets) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); @@ -998,7 +998,7 @@ TEST_F(SubsetLoadBalancerTest, ZoneAwareBalancesSubsets) { TEST_P(SubsetLoadBalancerTest, ZoneAwareBalancesSubsetsAfterUpdate) { EXPECT_CALL(subset_info_, fallbackPolicy()) - .WillRepeatedly(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::NO_FALLBACK)); + .WillRepeatedly(Return(envoy::api::v2::Cluster::LbSubsetConfig::NO_FALLBACK)); std::vector> subset_keys = {{"version"}}; EXPECT_CALL(subset_info_, subsetKeys()).WillRepeatedly(ReturnRef(subset_keys)); diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 4a8c3b07ae6d9..6f76c473b4488 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -625,7 +625,7 @@ TEST(StaticClusterImplTest, SourceAddressPriority) { Stats::IsolatedStoreImpl stats; Ssl::MockContextManager ssl_context_manager; NiceMock runtime; - envoy::api::v2::cluster::Cluster config; + envoy::api::v2::Cluster config; config.set_name("staticcluster"); config.mutable_connect_timeout(); diff --git a/test/common/upstream/utility.h b/test/common/upstream/utility.h index e631429538cbc..feacd33352682 100644 --- a/test/common/upstream/utility.h +++ b/test/common/upstream/utility.h @@ -43,28 +43,28 @@ inline std::string clustersJson(const std::vector& clusters) { return fmt::sprintf("\"clusters\": [%s]", StringUtil::join(clusters, ",")); } -inline envoy::api::v2::cluster::Cluster parseClusterFromJson(const std::string& json_string) { - envoy::api::v2::cluster::Cluster cluster; +inline envoy::api::v2::Cluster parseClusterFromJson(const std::string& json_string) { + envoy::api::v2::Cluster cluster; auto json_object_ptr = Json::Factory::loadFromString(json_string); Config::CdsJson::translateCluster(*json_object_ptr, Optional(), cluster); return cluster; } -inline envoy::api::v2::cluster::Cluster parseClusterFromV2Yaml(const std::string& yaml) { - envoy::api::v2::cluster::Cluster cluster; +inline envoy::api::v2::Cluster parseClusterFromV2Yaml(const std::string& yaml) { + envoy::api::v2::Cluster cluster; MessageUtil::loadFromYaml(yaml, cluster); return cluster; } -inline envoy::api::v2::cluster::Cluster defaultStaticCluster(const std::string& name) { +inline envoy::api::v2::Cluster defaultStaticCluster(const std::string& name) { return parseClusterFromJson(defaultStaticClusterJson(name)); } -inline envoy::api::v2::cluster::Cluster +inline envoy::api::v2::Cluster parseSdsClusterFromJson(const std::string& json_string, const envoy::api::v2::ConfigSource eds_config) { - envoy::api::v2::cluster::Cluster cluster; + envoy::api::v2::Cluster cluster; auto json_object_ptr = Json::Factory::loadFromString(json_string); Config::CdsJson::translateCluster(*json_object_ptr, eds_config, cluster); return cluster; diff --git a/test/config/BUILD b/test/config/BUILD index e7b7d1089235f..9b5e14c095c4c 100644 --- a/test/config/BUILD +++ b/test/config/BUILD @@ -19,12 +19,12 @@ envoy_cc_test_library( hdrs = [ "utility.h", ], + external_deps = ["envoy_bootstrap"], deps = [ "//source/common/network:address_lib", "//source/common/protobuf:utility_lib", "//test/test_common:environment_lib", "//test/test_common:network_utility_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) diff --git a/test/config/integration/server_xds.cds.yaml b/test/config/integration/server_xds.cds.yaml index f553bcb6b6b31..144818c11c83a 100644 --- a/test/config/integration/server_xds.cds.yaml +++ b/test/config/integration/server_xds.cds.yaml @@ -1,6 +1,6 @@ version_info: "0" resources: -- "@type": type.googleapis.com/envoy.api.v2.cluster.Cluster +- "@type": type.googleapis.com/envoy.api.v2.Cluster name: cluster_1 connect_timeout: { seconds: 5 } type: EDS diff --git a/test/config/integration/server_xds.eds.yaml b/test/config/integration/server_xds.eds.yaml index 26cdb1fa282a8..0833784c26c75 100644 --- a/test/config/integration/server_xds.eds.yaml +++ b/test/config/integration/server_xds.eds.yaml @@ -1,6 +1,6 @@ version_info: "0" resources: -- "@type": type.googleapis.com/envoy.service.discovery.v2.ClusterLoadAssignment +- "@type": type.googleapis.com/envoy.api.v2.ClusterLoadAssignment cluster_name: cluster_1 endpoints: - lb_endpoints: diff --git a/test/config/integration/server_xds.lds.yaml b/test/config/integration/server_xds.lds.yaml index 896d67d2c6527..c23cff5ffcf44 100644 --- a/test/config/integration/server_xds.lds.yaml +++ b/test/config/integration/server_xds.lds.yaml @@ -1,6 +1,6 @@ version_info: "0" resources: -- "@type": type.googleapis.com/envoy.api.v2.listener.Listener +- "@type": type.googleapis.com/envoy.api.v2.Listener name: listener_0 address: socket_address: diff --git a/test/config/integration/server_xds.rds.yaml b/test/config/integration/server_xds.rds.yaml index 6cbab598d981d..35040a3886292 100644 --- a/test/config/integration/server_xds.rds.yaml +++ b/test/config/integration/server_xds.rds.yaml @@ -1,6 +1,6 @@ version_info: "0" resources: -- "@type": type.googleapis.com/envoy.api.v2.route.RouteConfiguration +- "@type": type.googleapis.com/envoy.api.v2.RouteConfiguration name: route_config_0 virtual_hosts: - name: integration diff --git a/test/config/utility.cc b/test/config/utility.cc index 93439ae3350a7..8932cd6530e3a 100644 --- a/test/config/utility.cc +++ b/test/config/utility.cc @@ -1,6 +1,5 @@ #include "test/config/utility.h" -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" #include "envoy/http/codec.h" #include "common/common/assert.h" @@ -9,6 +8,8 @@ #include "test/test_common/environment.h" #include "test/test_common/network_utility.h" +#include "api/filter/network/http_connection_manager.pb.h" + namespace Envoy { const std::string ConfigHelper::BASE_CONFIG = R"EOF( @@ -206,8 +207,8 @@ void ConfigHelper::setConnectTimeout(std::chrono::milliseconds timeout) { void ConfigHelper::addRoute(const std::string& domains, const std::string& prefix, const std::string& cluster, bool validate_clusters, - envoy::api::v2::route::RouteAction::ClusterNotFoundResponseCode code, - envoy::api::v2::route::VirtualHost::TlsRequirementType type) { + envoy::api::v2::RouteAction::ClusterNotFoundResponseCode code, + envoy::api::v2::VirtualHost::TlsRequirementType type) { RELEASE_ASSERT(!finalized_); envoy::api::v2::filter::network::HttpConnectionManager hcm_config; loadHttpConnectionManager(hcm_config); @@ -276,7 +277,7 @@ void ConfigHelper::addSslConfig() { TestEnvironment::runfilesPath("/test/config/integration/certs/serverkey.pem")); } -envoy::api::v2::listener::Filter* ConfigHelper::getFilterFromListener() { +envoy::api::v2::Filter* ConfigHelper::getFilterFromListener() { RELEASE_ASSERT(!finalized_); if (bootstrap_.mutable_static_resources()->listeners_size() == 0) { return nullptr; @@ -317,7 +318,7 @@ void ConfigHelper::addConfigModifier(ConfigModifierFunction function) { } void ConfigHelper::addConfigModifier(HttpModifierFunction function) { - addConfigModifier([function, this](envoy::config::bootstrap::v2::Bootstrap&) -> void { + addConfigModifier([function, this](envoy::api::v2::Bootstrap&) -> void { envoy::api::v2::filter::network::HttpConnectionManager hcm_config; loadHttpConnectionManager(hcm_config); function(hcm_config); diff --git a/test/config/utility.h b/test/config/utility.h index 05302a6086c64..2547ac7c2d790 100644 --- a/test/config/utility.h +++ b/test/config/utility.h @@ -5,16 +5,17 @@ #include #include -#include "envoy/api/v2/base.pb.h" -#include "envoy/api/v2/cluster/cluster.pb.h" -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" -#include "envoy/api/v2/protocol.pb.h" -#include "envoy/api/v2/route/route.pb.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/http/codes.h" #include "common/network/address_impl.h" +#include "api/base.pb.h" +#include "api/bootstrap.pb.h" +#include "api/cds.pb.h" +#include "api/filter/network/http_connection_manager.pb.h" +#include "api/protocol.pb.h" +#include "api/rds.pb.h" + namespace Envoy { class ConfigHelper { @@ -27,7 +28,7 @@ class ConfigHelper { ConfigHelper(const Network::Address::IpVersion version, const std::string& config = HTTP_PROXY_CONFIG); - typedef std::function ConfigModifierFunction; + typedef std::function ConfigModifierFunction; typedef std::function HttpModifierFunction; @@ -63,11 +64,10 @@ class ConfigHelper { void setConnectTimeout(std::chrono::milliseconds timeout); // Add an additional route to the configuration. - void addRoute(const std::string& host, const std::string& route, const std::string& cluster, - bool validate_clusters, - envoy::api::v2::route::RouteAction::ClusterNotFoundResponseCode code, - envoy::api::v2::route::VirtualHost::TlsRequirementType type = - envoy::api::v2::route::VirtualHost::NONE); + void addRoute( + const std::string& host, const std::string& route, const std::string& cluster, + bool validate_clusters, envoy::api::v2::RouteAction::ClusterNotFoundResponseCode code, + envoy::api::v2::VirtualHost::TlsRequirementType type = envoy::api::v2::VirtualHost::NONE); // Add an HTTP filter prior to existing filters. void addFilter(const std::string& filter_yaml); @@ -87,7 +87,7 @@ class ConfigHelper { void addConfigModifier(HttpModifierFunction function); // Return the bootstrap configuration for hand-off to Envoy. - const envoy::config::bootstrap::v2::Bootstrap& bootstrap() { return bootstrap_; } + const envoy::api::v2::Bootstrap& bootstrap() { return bootstrap_; } private: // Load the first HCM struct from the first listener into a parsed proto. @@ -98,10 +98,10 @@ class ConfigHelper { storeHttpConnectionManager(const envoy::api::v2::filter::network::HttpConnectionManager& hcm); // Snags the first filter from the first filter chain from the first listener. - envoy::api::v2::listener::Filter* getFilterFromListener(); + envoy::api::v2::Filter* getFilterFromListener(); // The bootstrap proto Envoy will start up with. - envoy::config::bootstrap::v2::Bootstrap bootstrap_; + envoy::api::v2::Bootstrap bootstrap_; // The config modifiers added via addConfigModifier() which will be applied in finalize() std::vector config_modifiers_; diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index fd3eac263bbf2..282ee33445a5a 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -35,7 +35,7 @@ class ConfigTest { ON_CALL(server_.api_, fileReadToEnd("lightstep_access_token")) .WillByDefault(Return("access_token")); - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; Server::InstanceUtil::loadBootstrapConfig(bootstrap, options_.configPath(), options_.v2ConfigOnly()); Server::Configuration::InitialImpl initial_config(bootstrap); @@ -50,18 +50,17 @@ class ConfigTest { })); ON_CALL(server_, listenerManager()).WillByDefault(ReturnRef(listener_manager_)); ON_CALL(component_factory_, createNetworkFilterFactoryList(_, _)) + .WillByDefault(Invoke([&](const Protobuf::RepeatedPtrField& filters, + Server::Configuration::FactoryContext& context) + -> std::vector { + return Server::ProdListenerComponentFactory::createNetworkFilterFactoryList_(filters, + context); + })); + ON_CALL(component_factory_, createListenerFilterFactoryList(_, _)) .WillByDefault( - Invoke([&](const Protobuf::RepeatedPtrField& filters, + Invoke([&](const Protobuf::RepeatedPtrField& filters, Server::Configuration::FactoryContext& context) - -> std::vector { - return Server::ProdListenerComponentFactory::createNetworkFilterFactoryList_(filters, - context); - })); - ON_CALL(component_factory_, createListenerFilterFactoryList(_, _)) - .WillByDefault(Invoke( - [&](const Protobuf::RepeatedPtrField& filters, - Server::Configuration::FactoryContext& context) - -> std::vector { + -> std::vector { return Server::ProdListenerComponentFactory::createListenerFilterFactoryList_( filters, context); })); diff --git a/test/integration/BUILD b/test/integration/BUILD index dc7beaa4d3a23..38649bea3f0c3 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -27,6 +27,13 @@ envoy_cc_test( name = "ads_integration_test", srcs = ["ads_integration_test.cc"], data = ["//test/config/integration:server_ads.yaml"], + external_deps = [ + "envoy_cds", + "envoy_discovery", + "envoy_eds", + "envoy_lds", + "envoy_rds", + ], deps = [ ":http_integration_lib", "//source/common/config:resources_lib", @@ -34,12 +41,6 @@ envoy_cc_test( "//test/common/grpc:grpc_client_integration_lib", "//test/test_common:network_utility_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:ads_cc", - "@envoy_api//envoy/service/discovery/v2:cds_cc", - "@envoy_api//envoy/service/discovery/v2:common_cc", - "@envoy_api//envoy/service/discovery/v2:eds_cc", - "@envoy_api//envoy/service/discovery/v2:lds_cc", - "@envoy_api//envoy/service/discovery/v2:rds_cc", ], ) @@ -104,10 +105,10 @@ envoy_cc_test( srcs = [ "header_integration_test.cc", ], + external_deps = ["envoy_filter_network_http_connection_manager"], deps = [ ":http_integration_lib", "//source/common/protobuf", - "@envoy_api//envoy/api/v2/filter/network:http_connection_manager_cc", ], ) @@ -331,28 +332,31 @@ envoy_cc_test( envoy_cc_test( name = "stats_integration_test", srcs = ["stats_integration_test.cc"], + external_deps = [ + "envoy_bootstrap", + "envoy_stats", + ], deps = [ ":integration_lib", "//test/test_common:network_utility_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", - "@envoy_api//envoy/config/metrics/v2:stats_cc", ], ) envoy_cc_test( name = "load_stats_integration_test", srcs = ["load_stats_integration_test.cc"], + external_deps = ["envoy_eds"], deps = [ ":http_integration_lib", "//source/common/config:resources_lib", "//test/test_common:network_utility_lib", - "@envoy_api//envoy/service/discovery/v2:eds_cc", ], ) envoy_cc_test( name = "metrics_service_integration_test", srcs = ["metrics_service_integration_test.cc"], + external_deps = ["envoy_metrics"], deps = [ ":http_integration_lib", "//source/common/buffer:zero_copy_input_stream_lib", @@ -360,7 +364,6 @@ envoy_cc_test( "//source/common/grpc:common_lib", "//source/server/config/stats:metrics_service_lib", "//test/common/grpc:grpc_client_integration_lib", - "@envoy_api//envoy/service/metrics/v2:metrics_service_cc", ], ) diff --git a/test/integration/README.md b/test/integration/README.md index e8bc49942b1a2..408abe4817fe3 100644 --- a/test/integration/README.md +++ b/test/integration/README.md @@ -70,7 +70,7 @@ config, and then change the first `HttpConnectionManager` to be different from t An example of modifying the bootstrap proto to overwrite runtime defaults: ```c++ TestEnvironment::writeStringToFileForTest("runtime/ssl.alt_alpn", "100"); -config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { +config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { bootstrap.mutable_runtime()->set_symlink_root(TestEnvironment::temporaryPath("runtime"); }); ``` @@ -86,7 +86,7 @@ config_helper_.addConfigModifier([&](envoy::api::v2::filter::HttpConnectionManag An example of modifying `HttpConnectionManager` to add an additional upstream cluster: ```c++ - config_helper_.addConfigModifier([](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([](envoy::api::v2::Bootstrap& bootstrap) { bootstrap.mutable_rate_limit_service()->set_cluster_name("ratelimit"); auto* ratelimit_cluster = bootstrap.mutable_static_resources()->add_clusters(); ratelimit_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); diff --git a/test/integration/access_log_integration_test.cc b/test/integration/access_log_integration_test.cc index 1fe5a89dffb61..dbd1c48c99e91 100644 --- a/test/integration/access_log_integration_test.cc +++ b/test/integration/access_log_integration_test.cc @@ -1,6 +1,3 @@ -#include "envoy/config/accesslog/v2/als.pb.h" -#include "envoy/service/accesslog/v2/als.pb.h" - #include "common/buffer/zero_copy_input_stream_impl.h" #include "common/common/version.h" #include "common/grpc/codec.h" @@ -25,7 +22,7 @@ class AccessLogIntegrationTest : public HttpIntegrationTest, } void initialize() override { - config_helper_.addConfigModifier([](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([](envoy::api::v2::Bootstrap& bootstrap) { auto* accesslog_cluster = bootstrap.mutable_static_resources()->add_clusters(); accesslog_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); accesslog_cluster->set_name("accesslog"); @@ -37,7 +34,7 @@ class AccessLogIntegrationTest : public HttpIntegrationTest, auto* access_log = hcm.add_access_log(); access_log->set_name("envoy.http_grpc_access_log"); - envoy::config::accesslog::v2::HttpGrpcAccessLogConfig config; + envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig config; auto* common_config = config.mutable_common_config(); common_config->set_log_name("foo"); setGrpcService(*common_config->mutable_grpc_service(), "accesslog", @@ -57,14 +54,14 @@ class AccessLogIntegrationTest : public HttpIntegrationTest, } void waitForAccessLogRequest(const std::string& expected_request_msg_yaml) { - envoy::service::accesslog::v2::StreamAccessLogsMessage request_msg; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage request_msg; access_log_request_->waitForGrpcMessage(*dispatcher_, request_msg); EXPECT_STREQ("POST", access_log_request_->headers().Method()->value().c_str()); - EXPECT_STREQ("/envoy.service.accesslog.v2.AccessLogService/StreamAccessLogs", + EXPECT_STREQ("/envoy.api.v2.filter.accesslog.AccessLogService/StreamAccessLogs", access_log_request_->headers().Path()->value().c_str()); EXPECT_STREQ("application/grpc", access_log_request_->headers().ContentType()->value().c_str()); - envoy::service::accesslog::v2::StreamAccessLogsMessage expected_request_msg; + envoy::api::v2::filter::accesslog::StreamAccessLogsMessage expected_request_msg; MessageUtil::loadFromYaml(expected_request_msg_yaml, expected_request_msg); // Clear fields which are not deterministic. @@ -146,7 +143,7 @@ TEST_P(AccessLogIntegrationTest, BasicAccessLogFlow) { // Send an empty response and end the stream. This should never happen but make sure nothing // breaks and we make a new stream on a follow up request. access_log_request_->startGrpcStream(); - envoy::service::accesslog::v2::StreamAccessLogsResponse response_msg; + envoy::api::v2::filter::accesslog::StreamAccessLogsResponse response_msg; access_log_request_->sendGrpcMessage(response_msg); access_log_request_->finishGrpcStream(Grpc::Status::Ok); test_server_->waitForGaugeEq("cluster.accesslog.upstream_rq_active", 0); diff --git a/test/integration/ads_integration_test.cc b/test/integration/ads_integration_test.cc index 621b178327e50..1fdb5649454e0 100644 --- a/test/integration/ads_integration_test.cc +++ b/test/integration/ads_integration_test.cc @@ -1,11 +1,3 @@ -#include "envoy/api/v2/route/route.pb.h" -#include "envoy/service/discovery/v2/ads.pb.h" -#include "envoy/service/discovery/v2/cds.pb.h" -#include "envoy/service/discovery/v2/common.pb.h" -#include "envoy/service/discovery/v2/eds.pb.h" -#include "envoy/service/discovery/v2/lds.pb.h" -#include "envoy/service/discovery/v2/rds.pb.h" - #include "common/config/resources.h" #include "common/protobuf/utility.h" @@ -15,6 +7,11 @@ #include "test/test_common/network_utility.h" #include "test/test_common/utility.h" +#include "api/cds.pb.h" +#include "api/discovery.pb.h" +#include "api/eds.pb.h" +#include "api/lds.pb.h" +#include "api/rds.pb.h" #include "gtest/gtest.h" using testing::AssertionFailure; @@ -61,7 +58,7 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn AssertionResult compareDiscoveryRequest(const std::string& expected_type_url, const std::string& expected_version, const std::vector& expected_resource_names) { - envoy::service::discovery::v2::DiscoveryRequest discovery_request; + envoy::api::v2::DiscoveryRequest discovery_request; ads_stream_->waitForGrpcMessage(*dispatcher_, discovery_request); // TODO(PiotrSikora): Remove this hack once fixed internally. if (!(expected_type_url == discovery_request.type_url())) { @@ -89,7 +86,7 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn template void sendDiscoveryResponse(const std::string& type_url, const std::vector& messages, const std::string& version) { - envoy::service::discovery::v2::DiscoveryResponse discovery_response; + envoy::api::v2::DiscoveryResponse discovery_response; discovery_response.set_version_info(version); discovery_response.set_type_url(type_url); for (const auto& message : messages) { @@ -98,8 +95,8 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn ads_stream_->sendGrpcMessage(discovery_response); } - envoy::api::v2::cluster::Cluster buildCluster(const std::string& name) { - return TestUtility::parseYaml(fmt::format(R"EOF( + envoy::api::v2::Cluster buildCluster(const std::string& name) { + return TestUtility::parseYaml(fmt::format(R"EOF( name: {} connect_timeout: 5s type: EDS @@ -107,12 +104,11 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn lb_policy: ROUND_ROBIN http2_protocol_options: {{}} )EOF", - name)); + name)); } - envoy::service::discovery::v2::ClusterLoadAssignment - buildClusterLoadAssignment(const std::string& name) { - return TestUtility::parseYaml( + envoy::api::v2::ClusterLoadAssignment buildClusterLoadAssignment(const std::string& name) { + return TestUtility::parseYaml( fmt::format(R"EOF( cluster_name: {} endpoints: @@ -127,9 +123,8 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn fake_upstreams_[0]->localAddress()->ip()->port())); } - envoy::api::v2::listener::Listener buildListener(const std::string& name, - const std::string& route_config) { - return TestUtility::parseYaml( + envoy::api::v2::Listener buildListener(const std::string& name, const std::string& route_config) { + return TestUtility::parseYaml( fmt::format(R"EOF( name: {} address: @@ -150,9 +145,9 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn name, Network::Test::getLoopbackAddressString(ipVersion()), route_config)); } - envoy::api::v2::route::RouteConfiguration buildRouteConfig(const std::string& name, - const std::string& cluster) { - return TestUtility::parseYaml(fmt::format(R"EOF( + envoy::api::v2::RouteConfiguration buildRouteConfig(const std::string& name, + const std::string& cluster) { + return TestUtility::parseYaml(fmt::format(R"EOF( name: {} virtual_hosts: - name: integration @@ -161,8 +156,7 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn - match: {{ prefix: "/" }} route: {{ cluster: {} }} )EOF", - name, - cluster)); + name, cluster)); } void makeSingleRequest() { @@ -173,7 +167,7 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn } void initialize() override { - config_helper_.addConfigModifier([this](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([this](envoy::api::v2::Bootstrap& bootstrap) { setGrpcService( *bootstrap.mutable_dynamic_resources()->mutable_ads_config()->add_grpc_services(), "ads_cluster", fake_upstreams_.back()->localAddress()); @@ -183,7 +177,6 @@ class AdsIntegrationTest : public HttpIntegrationTest, public Grpc::GrpcClientIn ads_connection_ = fake_upstreams_[0]->waitForHttpConnection(*dispatcher_); ads_stream_ = ads_connection_->waitForNewStream(*dispatcher_); ads_stream_->startGrpcStream(); - envoy::service::discovery::v2::AdsDummy dummy; } FakeHttpConnectionPtr ads_connection_; @@ -198,24 +191,24 @@ TEST_P(AdsIntegrationTest, Basic) { // Send initial configuration, validate we can process a request. EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Cluster, "", {})); - sendDiscoveryResponse(Config::TypeUrl::get().Cluster, - {buildCluster("cluster_0")}, "1"); + sendDiscoveryResponse(Config::TypeUrl::get().Cluster, + {buildCluster("cluster_0")}, "1"); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "", {"cluster_0"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().ClusterLoadAssignment, {buildClusterLoadAssignment("cluster_0")}, "1"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Cluster, "1", {})); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Listener, "", {})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().Listener, {buildListener("listener_0", "route_config_0")}, "1"); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "1", {"cluster_0"})); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().RouteConfiguration, "", {"route_config_0"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().RouteConfiguration, {buildRouteConfig("route_config_0", "cluster_0")}, "1"); @@ -227,9 +220,9 @@ TEST_P(AdsIntegrationTest, Basic) { makeSingleRequest(); // Upgrade RDS/CDS/EDS to a newer config, validate we can process a request. - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().Cluster, {buildCluster("cluster_1"), buildCluster("cluster_2")}, "2"); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().ClusterLoadAssignment, {buildClusterLoadAssignment("cluster_1"), buildClusterLoadAssignment("cluster_2")}, "2"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "1", @@ -237,7 +230,7 @@ TEST_P(AdsIntegrationTest, Basic) { EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Cluster, "2", {})); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "2", {"cluster_2", "cluster_1"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().RouteConfiguration, {buildRouteConfig("route_config_0", "cluster_1")}, "2"); EXPECT_TRUE( @@ -246,17 +239,16 @@ TEST_P(AdsIntegrationTest, Basic) { makeSingleRequest(); // Upgrade LDS/RDS, validate we can process a request. - sendDiscoveryResponse( - Config::TypeUrl::get().Listener, - {buildListener("listener_1", "route_config_1"), - buildListener("listener_2", "route_config_2")}, - "2"); + sendDiscoveryResponse(Config::TypeUrl::get().Listener, + {buildListener("listener_1", "route_config_1"), + buildListener("listener_2", "route_config_2")}, + "2"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().RouteConfiguration, "2", {"route_config_2", "route_config_1", "route_config_0"})); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Listener, "2", {})); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().RouteConfiguration, "2", {"route_config_2", "route_config_1"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().RouteConfiguration, {buildRouteConfig("route_config_1", "cluster_1"), buildRouteConfig("route_config_2", "cluster_1")}, @@ -275,45 +267,45 @@ TEST_P(AdsIntegrationTest, Failure) { // Send initial configuration, failing each xDS once (via a type mismatch), validate we can // process a request. EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Cluster, "", {})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().Cluster, {buildClusterLoadAssignment("cluster_0")}, "1"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Listener, "", {})); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Cluster, "", {})); - sendDiscoveryResponse(Config::TypeUrl::get().Cluster, - {buildCluster("cluster_0")}, "1"); + sendDiscoveryResponse(Config::TypeUrl::get().Cluster, + {buildCluster("cluster_0")}, "1"); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "", {"cluster_0"})); - sendDiscoveryResponse( - Config::TypeUrl::get().ClusterLoadAssignment, {buildCluster("cluster_0")}, "1"); + sendDiscoveryResponse(Config::TypeUrl::get().ClusterLoadAssignment, + {buildCluster("cluster_0")}, "1"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Cluster, "1", {})); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "", {"cluster_0"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().ClusterLoadAssignment, {buildClusterLoadAssignment("cluster_0")}, "1"); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().ClusterLoadAssignment, "1", {"cluster_0"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().Listener, {buildRouteConfig("listener_0", "route_config_0")}, "1"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Listener, "", {})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().Listener, {buildListener("listener_0", "route_config_0")}, "1"); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().RouteConfiguration, "", {"route_config_0"})); - sendDiscoveryResponse( - Config::TypeUrl::get().RouteConfiguration, {buildListener("route_config_0", "cluster_0")}, - "1"); + sendDiscoveryResponse(Config::TypeUrl::get().RouteConfiguration, + {buildListener("route_config_0", "cluster_0")}, + "1"); EXPECT_TRUE(compareDiscoveryRequest(Config::TypeUrl::get().Listener, "1", {})); EXPECT_TRUE( compareDiscoveryRequest(Config::TypeUrl::get().RouteConfiguration, "", {"route_config_0"})); - sendDiscoveryResponse( + sendDiscoveryResponse( Config::TypeUrl::get().RouteConfiguration, {buildRouteConfig("route_config_0", "cluster_0")}, "1"); diff --git a/test/integration/header_integration_test.cc b/test/integration/header_integration_test.cc index 6844c7a04cb46..5e3d84496d4eb 100644 --- a/test/integration/header_integration_test.cc +++ b/test/integration/header_integration_test.cc @@ -1,6 +1,3 @@ -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" -#include "envoy/service/discovery/v2/eds.pb.h" - #include "common/config/metadata.h" #include "common/config/resources.h" #include "common/protobuf/protobuf.h" @@ -8,6 +5,8 @@ #include "test/integration/http_integration.h" #include "test/test_common/network_utility.h" +#include "api/eds.pb.h" +#include "api/filter/network/http_connection_manager.pb.h" #include "gtest/gtest.h" namespace Envoy { @@ -101,12 +100,12 @@ class HeaderIntegrationTest : public HttpIntegrationTest, } void prepareEDS() { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) { auto* static_resources = bootstrap.mutable_static_resources(); ASSERT(static_resources->clusters_size() == 1); static_resources->mutable_clusters(0)->CopyFrom( - TestUtility::parseYaml( + TestUtility::parseYaml( R"EOF( name: cluster_0 type: EDS @@ -123,7 +122,7 @@ class HeaderIntegrationTest : public HttpIntegrationTest, // host must come before the eds-cluster's host to keep the upstreams and ports in the same // order. static_resources->add_clusters()->CopyFrom( - TestUtility::parseYaml(fmt::format( + TestUtility::parseYaml(fmt::format( R"EOF( name: unused-cluster type: STATIC @@ -136,7 +135,7 @@ class HeaderIntegrationTest : public HttpIntegrationTest, Network::Test::getLoopbackAddressString(version_)))); static_resources->add_clusters()->CopyFrom( - TestUtility::parseYaml(fmt::format( + TestUtility::parseYaml(fmt::format( R"EOF( name: eds-cluster type: STATIC @@ -230,17 +229,16 @@ class HeaderIntegrationTest : public HttpIntegrationTest, eds_stream_ = eds_connection_->waitForNewStream(*dispatcher_); eds_stream_->startGrpcStream(); - envoy::service::discovery::v2::DiscoveryRequest discovery_request; + envoy::api::v2::DiscoveryRequest discovery_request; eds_stream_->waitForGrpcMessage(*dispatcher_, discovery_request); - envoy::service::discovery::v2::DiscoveryResponse discovery_response; + envoy::api::v2::DiscoveryResponse discovery_response; discovery_response.set_version_info("1"); discovery_response.set_type_url(Config::TypeUrl::get().ClusterLoadAssignment); - envoy::service::discovery::v2::ClusterLoadAssignment cluster_load_assignment = - TestUtility::parseYaml( - fmt::format( - R"EOF( + envoy::api::v2::ClusterLoadAssignment cluster_load_assignment = + TestUtility::parseYaml(fmt::format( + R"EOF( cluster_name: cluster_0 endpoints: - lb_endpoints: @@ -254,8 +252,8 @@ class HeaderIntegrationTest : public HttpIntegrationTest, test.namespace: key: metadata-value )EOF", - Network::Test::getLoopbackAddressString(GetParam()), - fake_upstreams_[0]->localAddress()->ip()->port())); + Network::Test::getLoopbackAddressString(GetParam()), + fake_upstreams_[0]->localAddress()->ip()->port())); discovery_response.add_resources()->PackFrom(cluster_load_assignment); eds_stream_->sendGrpcMessage(discovery_response); diff --git a/test/integration/http2_integration_test.cc b/test/integration/http2_integration_test.cc index 183fe81bfe791..39078a973c78c 100644 --- a/test/integration/http2_integration_test.cc +++ b/test/integration/http2_integration_test.cc @@ -260,10 +260,10 @@ TEST_P(Http2IntegrationTest, SimultaneousRequestWithBufferLimits) { } Http2RingHashIntegrationTest::Http2RingHashIntegrationTest() { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); cluster->clear_hosts(); - cluster->set_lb_policy(envoy::api::v2::cluster::Cluster_LbPolicy_RING_HASH); + cluster->set_lb_policy(envoy::api::v2::Cluster_LbPolicy_RING_HASH); for (int i = 0; i < num_upstreams_; i++) { auto* socket = cluster->add_hosts()->mutable_socket_address(); socket->set_address(Network::Test::getLoopbackAddressString(version_)); diff --git a/test/integration/http_integration.cc b/test/integration/http_integration.cc index e58880ee0220c..d7f6ea65c1d2a 100644 --- a/test/integration/http_integration.cc +++ b/test/integration/http_integration.cc @@ -293,8 +293,8 @@ void HttpIntegrationTest::testRouterNotFoundWithBody() { // Add a route that uses unknown cluster (expect 404 Not Found). void HttpIntegrationTest::testRouterClusterNotFound404() { config_helper_.addRoute("foo.com", "/unknown", "unknown_cluster", false, - envoy::api::v2::route::RouteAction::NOT_FOUND, - envoy::api::v2::route::VirtualHost::NONE); + envoy::api::v2::RouteAction::NOT_FOUND, + envoy::api::v2::VirtualHost::NONE); initialize(); BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest( @@ -306,8 +306,8 @@ void HttpIntegrationTest::testRouterClusterNotFound404() { // Add a route that uses unknown cluster (expect 503 Service Unavailable). void HttpIntegrationTest::testRouterClusterNotFound503() { config_helper_.addRoute("foo.com", "/unknown", "unknown_cluster", false, - envoy::api::v2::route::RouteAction::SERVICE_UNAVAILABLE, - envoy::api::v2::route::VirtualHost::NONE); + envoy::api::v2::RouteAction::SERVICE_UNAVAILABLE, + envoy::api::v2::VirtualHost::NONE); initialize(); BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest( @@ -319,8 +319,8 @@ void HttpIntegrationTest::testRouterClusterNotFound503() { // Add a route which redirects HTTP to HTTPS, and verify Envoy sends a 301 void HttpIntegrationTest::testRouterRedirect() { config_helper_.addRoute("www.redirect.com", "/", "cluster_0", true, - envoy::api::v2::route::RouteAction::SERVICE_UNAVAILABLE, - envoy::api::v2::route::VirtualHost::ALL); + envoy::api::v2::RouteAction::SERVICE_UNAVAILABLE, + envoy::api::v2::VirtualHost::ALL); initialize(); BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest( @@ -805,8 +805,8 @@ void HttpIntegrationTest::testAbsolutePath() { // Configure www.redirect.com to send a redirect, and ensure the redirect is // encountered via absolute URL. config_helper_.addRoute("www.redirect.com", "/", "cluster_0", true, - envoy::api::v2::route::RouteAction::SERVICE_UNAVAILABLE, - envoy::api::v2::route::VirtualHost::ALL); + envoy::api::v2::RouteAction::SERVICE_UNAVAILABLE, + envoy::api::v2::VirtualHost::ALL); config_helper_.addConfigModifier(&setAllowAbsoluteUrl); initialize(); @@ -828,8 +828,8 @@ void HttpIntegrationTest::testAbsolutePathWithPort() { // Configure www.namewithport.com:1234 to send a redirect, and ensure the redirect is // encountered via absolute URL with a port. config_helper_.addRoute("www.namewithport.com:1234", "/", "cluster_0", true, - envoy::api::v2::route::RouteAction::SERVICE_UNAVAILABLE, - envoy::api::v2::route::VirtualHost::ALL); + envoy::api::v2::RouteAction::SERVICE_UNAVAILABLE, + envoy::api::v2::VirtualHost::ALL); config_helper_.addConfigModifier(&setAllowAbsoluteUrl); initialize(); Buffer::OwnedImpl buffer("GET http://www.namewithport.com:1234 HTTP/1.1\r\nHost: host\r\n\r\n"); @@ -851,8 +851,8 @@ void HttpIntegrationTest::testAbsolutePathWithoutPort() { config_helper_.setDefaultHostAndRoute("foo.com", "/found"); // Set a matcher for namewithport:1234 and verify http://namewithport does not match config_helper_.addRoute("www.namewithport.com:1234", "/", "cluster_0", true, - envoy::api::v2::route::RouteAction::SERVICE_UNAVAILABLE, - envoy::api::v2::route::VirtualHost::ALL); + envoy::api::v2::RouteAction::SERVICE_UNAVAILABLE, + envoy::api::v2::VirtualHost::ALL); config_helper_.addConfigModifier(&setAllowAbsoluteUrl); initialize(); Buffer::OwnedImpl buffer("GET http://www.namewithport.com HTTP/1.1\r\nHost: host\r\n\r\n"); @@ -881,7 +881,7 @@ void HttpIntegrationTest::testConnect() { } void HttpIntegrationTest::testEquivalent(const std::string& request) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { // Clone the whole listener. auto static_resources = bootstrap.mutable_static_resources(); auto* old_listener = static_resources->mutable_listeners(0); diff --git a/test/integration/integration.cc b/test/integration/integration.cc index 942606f62b2c0..950091cf29038 100644 --- a/test/integration/integration.cc +++ b/test/integration/integration.cc @@ -235,12 +235,11 @@ void BaseIntegrationTest::createEnvoy() { void BaseIntegrationTest::setUpstreamProtocol(FakeHttpConnection::Type protocol) { upstream_protocol_ = protocol; if (upstream_protocol_ == FakeHttpConnection::Type::HTTP2) { - config_helper_.addConfigModifier( - [&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { - RELEASE_ASSERT(bootstrap.mutable_static_resources()->clusters_size() == 1); - auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->mutable_http2_protocol_options(); - }); + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { + RELEASE_ASSERT(bootstrap.mutable_static_resources()->clusters_size() == 1); + auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); + cluster->mutable_http2_protocol_options(); + }); } else { RELEASE_ASSERT(protocol == FakeHttpConnection::Type::HTTP1); } diff --git a/test/integration/integration_admin_test.cc b/test/integration/integration_admin_test.cc index 3f065b6b8e268..46416a710abb9 100644 --- a/test/integration/integration_admin_test.cc +++ b/test/integration/integration_admin_test.cc @@ -248,7 +248,7 @@ TEST_P(IntegrationAdminTest, Admin) { #ifdef TCMALLOC TEST_P(IntegrationAdminTest, AdminCpuProfilerStart) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { auto* admin = bootstrap.mutable_admin(); admin->set_profile_path(TestEnvironment::temporaryPath("/envoy.prof")); }); @@ -272,13 +272,11 @@ class IntegrationAdminIpv4Ipv6Test : public HttpIntegrationTest, public testing: : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, Network::Address::IpVersion::v4) {} void initialize() override { - config_helper_.addConfigModifier( - [&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { - auto* socket_address = - bootstrap.mutable_admin()->mutable_address()->mutable_socket_address(); - socket_address->set_ipv4_compat(true); - socket_address->set_address("::"); - }); + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { + auto* socket_address = bootstrap.mutable_admin()->mutable_address()->mutable_socket_address(); + socket_address->set_ipv4_compat(true); + socket_address->set_address("::"); + }); HttpIntegrationTest::initialize(); } }; diff --git a/test/integration/load_stats_integration_test.cc b/test/integration/load_stats_integration_test.cc index c2b3070fc9ec8..b9234d82708cc 100644 --- a/test/integration/load_stats_integration_test.cc +++ b/test/integration/load_stats_integration_test.cc @@ -1,13 +1,9 @@ -#include "envoy/api/v2/endpoint/endpoint.pb.h" -#include "envoy/api/v2/endpoint/load_report.pb.h" -#include "envoy/service/discovery/v2/eds.pb.h" -#include "envoy/service/load_stats/v2/lrs.pb.h" - #include "common/config/resources.h" #include "test/integration/http_integration.h" #include "test/test_common/network_utility.h" +#include "api/eds.pb.h" #include "gtest/gtest.h" namespace Envoy { @@ -18,8 +14,8 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, public: LoadStatsIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {} - void addEndpoint(envoy::api::v2::endpoint::LocalityLbEndpoints& locality_lb_endpoints, - uint32_t index, uint32_t& num_endpoints) { + void addEndpoint(envoy::api::v2::LocalityLbEndpoints& locality_lb_endpoints, uint32_t index, + uint32_t& num_endpoints) { auto* socket_address = locality_lb_endpoints.add_lb_endpoints() ->mutable_endpoint() ->mutable_address() @@ -36,7 +32,7 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, const std::vector& p1_winter_upstreams, const std::vector& p1_dragon_upstreams) { uint32_t num_endpoints = 0; - envoy::service::discovery::v2::ClusterLoadAssignment cluster_load_assignment; + envoy::api::v2::ClusterLoadAssignment cluster_load_assignment; cluster_load_assignment.set_cluster_name("cluster_0"); auto* winter = cluster_load_assignment.add_endpoints(); @@ -74,7 +70,7 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, } // Write to file the DiscoveryResponse and trigger inotify watch. - envoy::service::discovery::v2::DiscoveryResponse eds_response; + envoy::api::v2::DiscoveryResponse eds_response; eds_response.set_version_info(std::to_string(eds_version_++)); eds_response.set_type_url(Config::TypeUrl::get().ClusterLoadAssignment); eds_response.add_resources()->PackFrom(cluster_load_assignment); @@ -106,7 +102,7 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, void initialize() override { updateClusterLoadAssignment({}, {}, {}, {}); - config_helper_.addConfigModifier([this](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([this](envoy::api::v2::Bootstrap& bootstrap) { // Setup load reporting and corresponding gRPC cluster. auto* loadstats_config = bootstrap.mutable_cluster_manager()->mutable_load_stats_config(); loadstats_config->set_api_type(envoy::api::v2::ApiConfigSource::GRPC); @@ -125,7 +121,7 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, // Switch predefined cluster_0 to EDS filesystem sourcing. auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); cluster_0->mutable_hosts()->Clear(); - cluster_0->set_type(envoy::api::v2::cluster::Cluster::EDS); + cluster_0->set_type(envoy::api::v2::Cluster::EDS); auto* eds_cluster_config = cluster_0->mutable_eds_cluster_config(); eds_cluster_config->mutable_eds_config()->set_path(eds_path_); }); @@ -152,9 +148,8 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, loadstats_stream_ = fake_loadstats_connection_->waitForNewStream(*dispatcher_); } - void - mergeLoadStats(envoy::service::load_stats::v2::LoadStatsRequest& loadstats_request, - const envoy::service::load_stats::v2::LoadStatsRequest& local_loadstats_request) { + void mergeLoadStats(envoy::api::v2::LoadStatsRequest& loadstats_request, + const envoy::api::v2::LoadStatsRequest& local_loadstats_request) { ASSERT(loadstats_request.cluster_stats_size() <= 1); ASSERT(local_loadstats_request.cluster_stats_size() <= 1); @@ -200,9 +195,9 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, } void waitForLoadStatsRequest( - const std::vector& expected_locality_stats, + const std::vector& expected_locality_stats, uint64_t dropped = 0) { - Protobuf::RepeatedPtrField expected_cluster_stats; + Protobuf::RepeatedPtrField expected_cluster_stats; if (!expected_locality_stats.empty() || dropped != 0) { auto* cluster_stats = expected_cluster_stats.Add(); cluster_stats->set_cluster_name("cluster_0"); @@ -214,17 +209,17 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, Protobuf::RepeatedPtrFieldBackInserter(cluster_stats->mutable_upstream_locality_stats())); } - envoy::service::load_stats::v2::LoadStatsRequest loadstats_request; + envoy::api::v2::LoadStatsRequest loadstats_request; // Because multiple load stats may be sent while load in being sent (on slow machines), loop and // merge until all the expected load has been reported. do { - envoy::service::load_stats::v2::LoadStatsRequest local_loadstats_request; + envoy::api::v2::LoadStatsRequest local_loadstats_request; loadstats_stream_->waitForGrpcMessage(*dispatcher_, local_loadstats_request); mergeLoadStats(loadstats_request, local_loadstats_request); EXPECT_STREQ("POST", loadstats_stream_->headers().Method()->value().c_str()); - EXPECT_STREQ("/envoy.service.load_stats.v2.LoadReportingService/StreamLoadStats", + EXPECT_STREQ("/envoy.api.v2.EndpointDiscoveryService/StreamLoadStats", loadstats_stream_->headers().Path()->value().c_str()); EXPECT_STREQ("application/grpc", loadstats_stream_->headers().ContentType()->value().c_str()); } while (!TestUtility::assertRepeatedPtrFieldEqual(expected_cluster_stats, @@ -252,7 +247,7 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, } void requestLoadStatsResponse(const std::vector& clusters) { - envoy::service::load_stats::v2::LoadStatsResponse loadstats_response; + envoy::api::v2::LoadStatsResponse loadstats_response; loadstats_response.mutable_load_reporting_interval()->set_nanos(500000000); // 500ms for (const auto& cluster : clusters) { loadstats_response.add_clusters(cluster); @@ -262,11 +257,10 @@ class LoadStatsIntegrationTest : public HttpIntegrationTest, test_server_->waitForCounterGe("load_reporter.requests", ++load_requests_); } - envoy::api::v2::endpoint::UpstreamLocalityStats localityStats(const std::string& sub_zone, - uint64_t success, uint64_t error, - uint64_t active, - uint32_t priority = 0) { - envoy::api::v2::endpoint::UpstreamLocalityStats locality_stats; + envoy::api::v2::UpstreamLocalityStats localityStats(const std::string& sub_zone, uint64_t success, + uint64_t error, uint64_t active, + uint32_t priority = 0) { + envoy::api::v2::UpstreamLocalityStats locality_stats; auto* locality = locality_stats.mutable_locality(); locality->set_region("some_region"); locality->set_zone("zone_name"); @@ -456,7 +450,7 @@ TEST_P(LoadStatsIntegrationTest, InProgress) { // Validate the load reports for dropped requests make sense. TEST_P(LoadStatsIntegrationTest, Dropped) { - config_helper_.addConfigModifier([](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([](envoy::api::v2::Bootstrap& bootstrap) { auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); auto* thresholds = cluster_0->mutable_circuit_breakers()->add_thresholds(); thresholds->mutable_max_pending_requests()->set_value(0); diff --git a/test/integration/lua_integration_test.cc b/test/integration/lua_integration_test.cc index a1594fb91bcfe..f401c5fa8fe35 100644 --- a/test/integration/lua_integration_test.cc +++ b/test/integration/lua_integration_test.cc @@ -18,7 +18,7 @@ class LuaIntegrationTest : public HttpIntegrationTest, void initializeFilter(const std::string& filter_config) { config_helper_.addFilter(filter_config); - config_helper_.addConfigModifier([](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([](envoy::api::v2::Bootstrap& bootstrap) { auto* lua_cluster = bootstrap.mutable_static_resources()->add_clusters(); lua_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); lua_cluster->set_name("lua_cluster"); diff --git a/test/integration/metrics_service_integration_test.cc b/test/integration/metrics_service_integration_test.cc index 05faba3877e02..da114e126c0b2 100644 --- a/test/integration/metrics_service_integration_test.cc +++ b/test/integration/metrics_service_integration_test.cc @@ -1,12 +1,10 @@ -#include "envoy/config/metrics/v2/metrics_service.pb.h" -#include "envoy/service/metrics/v2/metrics_service.pb.h" - #include "common/common/version.h" #include "common/grpc/codec.h" #include "common/grpc/common.h" #include "test/integration/http_integration.h" +#include "api/metrics_service.pb.h" #include "gtest/gtest.h" namespace Envoy { @@ -27,7 +25,7 @@ class MetricsServiceIntegrationTest : public HttpIntegrationTest, } void initialize() override { - config_helper_.addConfigModifier([](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([](envoy::api::v2::Bootstrap& bootstrap) { auto* metrics_service_cluster = bootstrap.mutable_static_resources()->add_clusters(); metrics_service_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); metrics_service_cluster->set_name("metrics_service"); @@ -35,7 +33,7 @@ class MetricsServiceIntegrationTest : public HttpIntegrationTest, auto* metrics_sink = bootstrap.add_stats_sinks(); metrics_sink->set_name("envoy.metrics_service"); - envoy::config::metrics::v2::MetricsServiceConfig config; + envoy::api::v2::MetricsServiceConfig config; config.mutable_grpc_service()->mutable_envoy_grpc()->set_cluster_name("metrics_service"); MessageUtil::jsonConvert(config, *metrics_sink->mutable_config()); }); @@ -53,10 +51,10 @@ class MetricsServiceIntegrationTest : public HttpIntegrationTest, } void waitForMetricsRequest() { - envoy::service::metrics::v2::StreamMetricsMessage request_msg; + envoy::api::v2::StreamMetricsMessage request_msg; metrics_service_request_->waitForGrpcMessage(*dispatcher_, request_msg); EXPECT_STREQ("POST", metrics_service_request_->headers().Method()->value().c_str()); - EXPECT_STREQ("/envoy.service.metrics.v2.MetricsService/StreamMetrics", + EXPECT_STREQ("/envoy.api.v2.MetricsService/StreamMetrics", metrics_service_request_->headers().Path()->value().c_str()); EXPECT_STREQ("application/grpc", metrics_service_request_->headers().ContentType()->value().c_str()); @@ -107,7 +105,7 @@ TEST_P(MetricsServiceIntegrationTest, BasicFlow) { // Send an empty response and end the stream. This should never happen but make sure nothing // breaks and we make a new stream on a follow up request. metrics_service_request_->startGrpcStream(); - envoy::service::metrics::v2::StreamMetricsResponse response_msg; + envoy::api::v2::StreamMetricsResponse response_msg; metrics_service_request_->sendGrpcMessage(response_msg); metrics_service_request_->finishGrpcStream(Grpc::Status::Ok); test_server_->waitForGaugeEq("cluster.metrics_service.upstream_rq_active", 0); diff --git a/test/integration/proxy_proto_integration_test.h b/test/integration/proxy_proto_integration_test.h index 1d91bdb4ef79a..e62aa22ac9c1b 100644 --- a/test/integration/proxy_proto_integration_test.h +++ b/test/integration/proxy_proto_integration_test.h @@ -14,12 +14,11 @@ class ProxyProtoIntegrationTest : public HttpIntegrationTest, public testing::TestWithParam { public: ProxyProtoIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) { - config_helper_.addConfigModifier( - [&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { - auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0); - auto* filter_chain = listener->mutable_filter_chains(0); - filter_chain->mutable_use_proxy_proto()->set_value(true); - }); + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { + auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0); + auto* filter_chain = listener->mutable_filter_chains(0); + filter_chain->mutable_use_proxy_proto()->set_value(true); + }); } }; } // namespace Envoy diff --git a/test/integration/ratelimit_integration_test.cc b/test/integration/ratelimit_integration_test.cc index b155b58a49000..b106b28c872b5 100644 --- a/test/integration/ratelimit_integration_test.cc +++ b/test/integration/ratelimit_integration_test.cc @@ -27,7 +27,7 @@ class RatelimitIntegrationTest : public HttpIntegrationTest, void initialize() override { config_helper_.addFilter( "{ name: envoy.rate_limit, config: { domain: some_domain, timeout: 0.5s } }"); - config_helper_.addConfigModifier([this](envoy::config::bootstrap::v2::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([this](envoy::api::v2::Bootstrap& bootstrap) { auto* ratelimit_cluster = bootstrap.mutable_static_resources()->add_clusters(); ratelimit_cluster->MergeFrom(bootstrap.static_resources().clusters()[0]); ratelimit_cluster->set_name("ratelimit"); diff --git a/test/integration/ssl_integration_test.cc b/test/integration/ssl_integration_test.cc index 6d73741f79618..fa3c18d9c21bb 100644 --- a/test/integration/ssl_integration_test.cc +++ b/test/integration/ssl_integration_test.cc @@ -178,7 +178,7 @@ TEST_P(SslIntegrationTest, AdminCertEndpoint) { TEST_P(SslIntegrationTest, AltAlpn) { // Write the runtime file to turn alt_alpn on. TestEnvironment::writeStringToFileForTest("runtime/ssl.alt_alpn", "100"); - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { // Configure the runtime directory. bootstrap.mutable_runtime()->set_symlink_root(TestEnvironment::temporaryPath("runtime")); }); diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc index 682622828f605..1b53d210e16eb 100644 --- a/test/integration/stats_integration_test.cc +++ b/test/integration/stats_integration_test.cc @@ -1,9 +1,8 @@ -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" -#include "envoy/config/metrics/v2/stats.pb.h" - #include "test/integration/integration.h" #include "test/test_common/network_utility.h" +#include "api/bootstrap.pb.h" +#include "api/stats.pb.h" #include "gtest/gtest.h" namespace Envoy { @@ -39,7 +38,7 @@ TEST_P(StatsIntegrationTest, WithDefaultConfig) { } TEST_P(StatsIntegrationTest, WithoutDefaultTagExtractors) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { bootstrap.mutable_stats_config()->mutable_use_all_default_tags()->set_value(false); }); initialize(); @@ -49,7 +48,7 @@ TEST_P(StatsIntegrationTest, WithoutDefaultTagExtractors) { } TEST_P(StatsIntegrationTest, WithDefaultTagExtractors) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { bootstrap.mutable_stats_config()->mutable_use_all_default_tags()->set_value(true); }); initialize(); @@ -67,7 +66,7 @@ TEST_P(StatsIntegrationTest, WithDefaultTagExtractors) { // specifier having use defined regex. TEST_P(StatsIntegrationTest, WithDefaultTagExtractorNameWithUserDefinedRegex) { std::string tag_name = Config::TagNames::get().HTTP_CONN_MANAGER_PREFIX; - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { bootstrap.mutable_stats_config()->mutable_use_all_default_tags()->set_value(false); auto tag_specifier = bootstrap.mutable_stats_config()->mutable_stats_tags()->Add(); tag_specifier->set_tag_name(tag_name); @@ -82,7 +81,7 @@ TEST_P(StatsIntegrationTest, WithDefaultTagExtractorNameWithUserDefinedRegex) { } TEST_P(StatsIntegrationTest, WithTagSpecifierMissingTagValue) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { bootstrap.mutable_stats_config()->mutable_use_all_default_tags()->set_value(false); auto tag_specifier = bootstrap.mutable_stats_config()->mutable_stats_tags()->Add(); tag_specifier->set_tag_name("envoy.http_conn_manager_prefix"); @@ -96,7 +95,7 @@ TEST_P(StatsIntegrationTest, WithTagSpecifierMissingTagValue) { } TEST_P(StatsIntegrationTest, WithTagSpecifierWithRegex) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { bootstrap.mutable_stats_config()->mutable_use_all_default_tags()->set_value(false); auto tag_specifier = bootstrap.mutable_stats_config()->mutable_stats_tags()->Add(); tag_specifier->set_tag_name("my.http_conn_manager_prefix"); @@ -111,7 +110,7 @@ TEST_P(StatsIntegrationTest, WithTagSpecifierWithRegex) { } TEST_P(StatsIntegrationTest, WithTagSpecifierWithFixedValue) { - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { auto tag_specifier = bootstrap.mutable_stats_config()->mutable_stats_tags()->Add(); tag_specifier->set_tag_name("test.x"); tag_specifier->set_fixed_value("xxx"); diff --git a/test/integration/tcp_proxy_integration_test.cc b/test/integration/tcp_proxy_integration_test.cc index d944ce5f8688f..78f64195401cd 100644 --- a/test/integration/tcp_proxy_integration_test.cc +++ b/test/integration/tcp_proxy_integration_test.cc @@ -1,7 +1,5 @@ #include "test/integration/tcp_proxy_integration_test.h" -#include "envoy/api/v2/filter/accesslog/accesslog.pb.h" - #include "common/filesystem/filesystem_impl.h" #include "common/network/utility.h" #include "common/ssl/context_manager_impl.h" @@ -10,6 +8,7 @@ #include "test/integration/utility.h" #include "test/mocks/runtime/mocks.h" +#include "api/filter/accesslog/accesslog.pb.h" #include "gtest/gtest.h" using testing::Invoke; @@ -177,7 +176,7 @@ TEST_P(TcpProxyIntegrationTest, LargeBidirectionalTlsWrites) { TEST_P(TcpProxyIntegrationTest, AccessLog) { std::string access_log_path = TestEnvironment::temporaryPath( fmt::format("access_log{}.txt", GetParam() == Network::Address::IpVersion::v4 ? "v4" : "v6")); - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0); auto* filter_chain = listener->mutable_filter_chains(0); auto* config_blob = filter_chain->mutable_filters(0)->mutable_config(); diff --git a/test/integration/uds_integration_test.h b/test/integration/uds_integration_test.h index 4557de425390e..bf29bb8967af2 100644 --- a/test/integration/uds_integration_test.h +++ b/test/integration/uds_integration_test.h @@ -20,18 +20,17 @@ class UdsIntegrationTest : public HttpIntegrationTest, fake_upstreams_.emplace_back(new FakeUpstream( TestEnvironment::unixDomainSocketPath("udstest.1.sock"), FakeHttpConnection::Type::HTTP1)); - config_helper_.addConfigModifier( - [&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { - auto* static_resources = bootstrap.mutable_static_resources(); - for (int i = 0; i < static_resources->clusters_size(); ++i) { - auto* cluster = static_resources->mutable_clusters(i); - for (int j = 0; j < cluster->hosts_size(); ++j) { - cluster->mutable_hosts(j)->clear_socket_address(); - cluster->mutable_hosts(j)->mutable_pipe()->set_path( - TestEnvironment::unixDomainSocketPath("udstest.1.sock")); - } - } - }); + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { + auto* static_resources = bootstrap.mutable_static_resources(); + for (int i = 0; i < static_resources->clusters_size(); ++i) { + auto* cluster = static_resources->mutable_clusters(i); + for (int j = 0; j < cluster->hosts_size(); ++j) { + cluster->mutable_hosts(j)->clear_socket_address(); + cluster->mutable_hosts(j)->mutable_pipe()->set_path( + TestEnvironment::unixDomainSocketPath("udstest.1.sock")); + } + } + }); } }; } // namespace Envoy diff --git a/test/integration/xfcc_integration_test.cc b/test/integration/xfcc_integration_test.cc index 905036e50baa8..358b506a0a808 100644 --- a/test/integration/xfcc_integration_test.cc +++ b/test/integration/xfcc_integration_test.cc @@ -3,8 +3,6 @@ #include #include -#include "envoy/api/v2/filter/network/http_connection_manager.pb.h" - #include "common/event/dispatcher_impl.h" #include "common/http/header_map_impl.h" #include "common/network/utility.h" @@ -16,6 +14,7 @@ #include "test/test_common/printers.h" #include "test/test_common/utility.h" +#include "api/filter/network/http_connection_manager.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "integration.h" @@ -107,7 +106,7 @@ void XfccIntegrationTest::initialize() { hcm.mutable_set_current_client_cert_details()->CopyFrom(sccd_); }); - config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { + config_helper_.addConfigModifier([&](envoy::api::v2::Bootstrap& bootstrap) -> void { auto context = bootstrap.mutable_static_resources()->mutable_clusters(0)->mutable_tls_context(); auto* validation_context = context->mutable_common_tls_context()->mutable_validation_context(); validation_context->mutable_trusted_ca()->set_filename( diff --git a/test/mocks/server/mocks.h b/test/mocks/server/mocks.h index b56d7590bd899..5bdcd460c7450 100644 --- a/test/mocks/server/mocks.h +++ b/test/mocks/server/mocks.h @@ -142,24 +142,22 @@ class MockListenerComponentFactory : public ListenerComponentFactory { MockListenerComponentFactory(); ~MockListenerComponentFactory(); - DrainManagerPtr - createDrainManager(envoy::api::v2::listener::Listener::DrainType drain_type) override { + DrainManagerPtr createDrainManager(envoy::api::v2::Listener::DrainType drain_type) override { return DrainManagerPtr{createDrainManager_(drain_type)}; } MOCK_METHOD2(createNetworkFilterFactoryList, std::vector( - const Protobuf::RepeatedPtrField& filters, + const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context)); MOCK_METHOD2(createListenerFilterFactoryList, std::vector( - const Protobuf::RepeatedPtrField&, + const Protobuf::RepeatedPtrField&, Configuration::FactoryContext& context)); MOCK_METHOD2(createListenSocket, Network::ListenSocketSharedPtr(Network::Address::InstanceConstSharedPtr address, bool bind_to_port)); - MOCK_METHOD1(createDrainManager_, - DrainManager*(envoy::api::v2::listener::Listener::DrainType drain_type)); + MOCK_METHOD1(createDrainManager_, DrainManager*(envoy::api::v2::Listener::DrainType drain_type)); MOCK_METHOD0(nextListenerTag, uint64_t()); std::shared_ptr socket_; @@ -170,8 +168,7 @@ class MockListenerManager : public ListenerManager { MockListenerManager(); ~MockListenerManager(); - MOCK_METHOD2(addOrUpdateListener, - bool(const envoy::api::v2::listener::Listener& config, bool modifiable)); + MOCK_METHOD2(addOrUpdateListener, bool(const envoy::api::v2::Listener& config, bool modifiable)); MOCK_METHOD0(listeners, std::vector>()); MOCK_METHOD0(numConnections, uint64_t()); MOCK_METHOD1(removeListener, bool(const std::string& listener_name)); diff --git a/test/mocks/upstream/cluster_info.cc b/test/mocks/upstream/cluster_info.cc index ae6f984e86851..c2f916f645004 100644 --- a/test/mocks/upstream/cluster_info.cc +++ b/test/mocks/upstream/cluster_info.cc @@ -15,7 +15,7 @@ namespace Upstream { MockLoadBalancerSubsetInfo::MockLoadBalancerSubsetInfo() { ON_CALL(*this, isEnabled()).WillByDefault(Return(false)); ON_CALL(*this, fallbackPolicy()) - .WillByDefault(Return(envoy::api::v2::cluster::Cluster::LbSubsetConfig::ANY_ENDPOINT)); + .WillByDefault(Return(envoy::api::v2::Cluster::LbSubsetConfig::ANY_ENDPOINT)); ON_CALL(*this, defaultSubset()).WillByDefault(ReturnRef(ProtobufWkt::Struct::default_instance())); ON_CALL(*this, subsetKeys()).WillByDefault(ReturnRef(subset_keys_)); } diff --git a/test/mocks/upstream/cluster_info.h b/test/mocks/upstream/cluster_info.h index 3ec0123726ccd..7969eda598964 100644 --- a/test/mocks/upstream/cluster_info.h +++ b/test/mocks/upstream/cluster_info.h @@ -27,7 +27,7 @@ class MockLoadBalancerSubsetInfo : public LoadBalancerSubsetInfo { // Upstream::LoadBalancerSubsetInfo MOCK_CONST_METHOD0(isEnabled, bool()); MOCK_CONST_METHOD0(fallbackPolicy, - envoy::api::v2::cluster::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy()); + envoy::api::v2::Cluster::LbSubsetConfig::LbSubsetFallbackPolicy()); MOCK_CONST_METHOD0(defaultSubset, const ProtobufWkt::Struct&()); MOCK_CONST_METHOD0(subsetKeys, const std::vector>&()); @@ -46,9 +46,9 @@ class MockClusterInfo : public ClusterInfo { MOCK_CONST_METHOD0(features, uint64_t()); MOCK_CONST_METHOD0(http2Settings, const Http::Http2Settings&()); MOCK_CONST_METHOD0(lbType, LoadBalancerType()); - MOCK_CONST_METHOD0(type, envoy::api::v2::cluster::Cluster::DiscoveryType()); + MOCK_CONST_METHOD0(type, envoy::api::v2::Cluster::DiscoveryType()); MOCK_CONST_METHOD0(lbRingHashConfig, - const Optional&()); + const Optional&()); MOCK_CONST_METHOD0(maintenanceMode, bool()); MOCK_CONST_METHOD0(maxRequestsPerConnection, uint64_t()); MOCK_CONST_METHOD0(name, const std::string&()); @@ -73,10 +73,9 @@ class MockClusterInfo : public ClusterInfo { std::unique_ptr resource_manager_; Network::Address::InstanceConstSharedPtr source_address_; LoadBalancerType lb_type_{LoadBalancerType::RoundRobin}; - envoy::api::v2::cluster::Cluster::DiscoveryType type_{ - envoy::api::v2::cluster::Cluster::STRICT_DNS}; + envoy::api::v2::Cluster::DiscoveryType type_{envoy::api::v2::Cluster::STRICT_DNS}; NiceMock lb_subset_; - Optional lb_ring_hash_config_; + Optional lb_ring_hash_config_; }; } // namespace Upstream diff --git a/test/mocks/upstream/mocks.h b/test/mocks/upstream/mocks.h index e0d20983fbcf7..b2d2e02133a6a 100644 --- a/test/mocks/upstream/mocks.h +++ b/test/mocks/upstream/mocks.h @@ -150,7 +150,7 @@ class MockClusterManager : public ClusterManager { } // Upstream::ClusterManager - MOCK_METHOD1(addOrUpdatePrimaryCluster, bool(const envoy::api::v2::cluster::Cluster& cluster)); + MOCK_METHOD1(addOrUpdatePrimaryCluster, bool(const envoy::api::v2::Cluster& cluster)); MOCK_METHOD1(setInitializedCb, void(std::function)); MOCK_METHOD0(clusters, ClusterInfoMap()); MOCK_METHOD1(get, ThreadLocalCluster*(const std::string& cluster)); diff --git a/test/proto/BUILD b/test/proto/BUILD index afaf499e04185..7e8947a233f47 100644 --- a/test/proto/BUILD +++ b/test/proto/BUILD @@ -20,8 +20,8 @@ envoy_proto_library( name = "bookstore_proto", srcs = [":bookstore.proto"], external_deps = [ - "well_known_protos", "http_api_protos", + "well_known_protos", ], ) diff --git a/test/server/BUILD b/test/server/BUILD index 1003a8a28d1a6..23d919ae66692 100644 --- a/test/server/BUILD +++ b/test/server/BUILD @@ -114,7 +114,6 @@ envoy_cc_test( "//test/mocks/server:server_mocks", "//test/test_common:environment_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/service/discovery/v2:lds_cc", ], ) diff --git a/test/server/config/access_log/config_test.cc b/test/server/config/access_log/config_test.cc index c8224708dff00..223a65e877f9d 100644 --- a/test/server/config/access_log/config_test.cc +++ b/test/server/config/access_log/config_test.cc @@ -40,7 +40,7 @@ class HttpGrpcAccessLogConfigTest : public testing::Test { AccessLog::FilterPtr filter_; NiceMock context_; - envoy::config::accesslog::v2::HttpGrpcAccessLogConfig http_grpc_access_log_; + envoy::api::v2::filter::accesslog::HttpGrpcAccessLogConfig http_grpc_access_log_; ProtobufTypes::MessagePtr message_; AccessLogInstanceFactory* factory_{}; }; diff --git a/test/server/config/http/config_test.cc b/test/server/config/http/config_test.cc index 0cf205e045018..ebd3daa8976b5 100644 --- a/test/server/config/http/config_test.cc +++ b/test/server/config/http/config_test.cc @@ -1,6 +1,5 @@ #include -#include "envoy/api/v2/filter/http/router.pb.h" #include "envoy/registry/registry.h" #include "common/config/filter_json.h" @@ -27,6 +26,7 @@ #include "test/mocks/server/mocks.h" #include "test/test_common/utility.h" +#include "api/filter/http/router.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/test/server/config/network/mongo_proxy_test.cc b/test/server/config/network/mongo_proxy_test.cc index ab0853dfc6985..1824d7f28340c 100644 --- a/test/server/config/network/mongo_proxy_test.cc +++ b/test/server/config/network/mongo_proxy_test.cc @@ -1,12 +1,11 @@ #include -#include "envoy/api/v2/filter/network/mongo_proxy.pb.h" - #include "server/config/network/mongo_proxy.h" #include "test/mocks/server/mocks.h" #include "test/test_common/utility.h" +#include "api/filter/network/mongo_proxy.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" diff --git a/test/server/config/stats/BUILD b/test/server/config/stats/BUILD index 2ae08d70a799b..663be08290140 100644 --- a/test/server/config/stats/BUILD +++ b/test/server/config/stats/BUILD @@ -11,6 +11,9 @@ envoy_package() envoy_cc_test( name = "config_test", srcs = ["config_test.cc"], + external_deps = [ + "envoy_bootstrap", + ], deps = [ "//include/envoy/registry", "//source/common/config:well_known_names", @@ -22,6 +25,5 @@ envoy_cc_test( "//test/test_common:environment_lib", "//test/test_common:network_utility_lib", "//test/test_common:utility_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) diff --git a/test/server/config/stats/config_test.cc b/test/server/config/stats/config_test.cc index ecfb8b13142ac..7481614edaa2c 100644 --- a/test/server/config/stats/config_test.cc +++ b/test/server/config/stats/config_test.cc @@ -1,6 +1,5 @@ #include -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/registry/registry.h" #include "common/config/well_known_names.h" @@ -15,6 +14,7 @@ #include "test/test_common/network_utility.h" #include "test/test_common/utility.h" +#include "api/bootstrap.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -30,7 +30,7 @@ namespace Configuration { TEST(StatsConfigTest, ValidTcpStatsd) { const std::string name = Config::StatsSinkNames::get().STATSD; - envoy::config::metrics::v2::StatsdSink sink_config; + envoy::api::v2::StatsdSink sink_config; sink_config.set_tcp_cluster_name("fake_cluster"); StatsSinkFactory* factory = Registry::FactoryRegistry::getFactory(name); @@ -52,7 +52,7 @@ INSTANTIATE_TEST_CASE_P(IpVersions, StatsConfigLoopbackTest, TEST_P(StatsConfigLoopbackTest, ValidUdpIpStatsd) { const std::string name = Config::StatsSinkNames::get().STATSD; - envoy::config::metrics::v2::StatsdSink sink_config; + envoy::api::v2::StatsdSink sink_config; envoy::api::v2::Address& address = *sink_config.mutable_address(); envoy::api::v2::SocketAddress& socket_address = *address.mutable_socket_address(); socket_address.set_protocol(envoy::api::v2::SocketAddress::UDP); @@ -76,9 +76,8 @@ TEST_P(StatsConfigLoopbackTest, ValidUdpIpStatsd) { // Negative test for protoc-gen-validate constraints for statsd. TEST(StatsdConfigTest, ValidateFail) { NiceMock server; - EXPECT_THROW( - StatsdSinkFactory().createStatsSink(envoy::config::metrics::v2::StatsdSink(), server), - ProtoValidationException); + EXPECT_THROW(StatsdSinkFactory().createStatsSink(envoy::api::v2::StatsdSink(), server), + ProtoValidationException); } class DogStatsdConfigLoopbackTest : public testing::TestWithParam {}; @@ -88,7 +87,7 @@ INSTANTIATE_TEST_CASE_P(IpVersions, DogStatsdConfigLoopbackTest, TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) { const std::string name = Config::StatsSinkNames::get().DOG_STATSD; - envoy::config::metrics::v2::DogStatsdSink sink_config; + envoy::api::v2::DogStatsdSink sink_config; envoy::api::v2::Address& address = *sink_config.mutable_address(); envoy::api::v2::SocketAddress& socket_address = *address.mutable_socket_address(); socket_address.set_protocol(envoy::api::v2::SocketAddress::UDP); @@ -112,9 +111,8 @@ TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) { // Negative test for protoc-gen-validate constraints for dog_statsd. TEST(DogStatsdConfigTest, ValidateFail) { NiceMock server; - EXPECT_THROW( - DogStatsdSinkFactory().createStatsSink(envoy::config::metrics::v2::DogStatsdSink(), server), - ProtoValidationException); + EXPECT_THROW(DogStatsdSinkFactory().createStatsSink(envoy::api::v2::DogStatsdSink(), server), + ProtoValidationException); } } // namespace Configuration diff --git a/test/server/config_validation/cluster_manager_test.cc b/test/server/config_validation/cluster_manager_test.cc index 583564223ea26..8ebf7b1745279 100644 --- a/test/server/config_validation/cluster_manager_test.cc +++ b/test/server/config_validation/cluster_manager_test.cc @@ -33,7 +33,7 @@ TEST(ValidationClusterManagerTest, MockedMethods) { ssl_context_manager, dispatcher, local_info); AccessLog::MockAccessLogManager log_manager; - const envoy::config::bootstrap::v2::Bootstrap bootstrap; + const envoy::api::v2::Bootstrap bootstrap; ClusterManagerPtr cluster_manager = factory.clusterManagerFromProto( bootstrap, stats, tls, runtime, random, local_info, log_manager); EXPECT_EQ(nullptr, cluster_manager->httpConnPoolForCluster("cluster", ResourcePriority::Default, diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index f03ef6c98e866..3251e6039a176 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -56,7 +56,7 @@ class ConfigurationImplTest : public testing::Test { }; TEST_F(ConfigurationImplTest, DefaultStatsFlushInterval) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; + envoy::api::v2::Bootstrap bootstrap; MainImpl config; config.initialize(bootstrap, server_, cluster_manager_factory_); @@ -79,7 +79,7 @@ TEST_F(ConfigurationImplTest, CustomStatsFlushInterval) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); MainImpl config; config.initialize(bootstrap, server_, cluster_manager_factory_); @@ -109,7 +109,7 @@ TEST_F(ConfigurationImplTest, SetUpstreamClusterPerConnectionBufferLimit) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); MainImpl config; config.initialize(bootstrap, server_, cluster_manager_factory_); @@ -151,7 +151,7 @@ TEST_F(ConfigurationImplTest, ServiceClusterNotSetWhenLSTracing) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); server_.local_info_.node_.set_cluster(""); MainImpl config; @@ -174,7 +174,7 @@ TEST_F(ConfigurationImplTest, NullTracerSetWhenTracingConfigurationAbsent) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); server_.local_info_.node_.set_cluster(""); MainImpl config; @@ -210,7 +210,7 @@ TEST_F(ConfigurationImplTest, NullTracerSetWhenHttpKeyAbsentFromTracerConfigurat } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); server_.local_info_.node_.set_cluster(""); MainImpl config; @@ -246,7 +246,7 @@ TEST_F(ConfigurationImplTest, ConfigurationFailsWhenInvalidTracerSpecified) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); bootstrap.mutable_tracing()->mutable_http()->set_name("invalid"); MainImpl config; EXPECT_THROW_WITH_MESSAGE(config.initialize(bootstrap, server_, cluster_manager_factory_), @@ -267,7 +267,7 @@ TEST_F(ConfigurationImplTest, ProtoSpecifiedStatsSink) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); auto& sink = *bootstrap.mutable_stats_sinks()->Add(); sink.set_name(Config::StatsSinkNames::get().STATSD); @@ -293,9 +293,9 @@ TEST_F(ConfigurationImplTest, StatsSinkWithInvalidName) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); - envoy::config::metrics::v2::StatsSink& sink = *bootstrap.mutable_stats_sinks()->Add(); + envoy::api::v2::StatsSink& sink = *bootstrap.mutable_stats_sinks()->Add(); sink.set_name("envoy.invalid"); auto& field_map = *sink.mutable_config()->mutable_fields(); field_map["tcp_cluster_name"].set_string_value("fake_cluster"); @@ -319,7 +319,7 @@ TEST_F(ConfigurationImplTest, StatsSinkWithNoName) { } )EOF"; - envoy::config::bootstrap::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); + envoy::api::v2::Bootstrap bootstrap = TestUtility::parseBootstrapFromJson(json); auto& sink = *bootstrap.mutable_stats_sinks()->Add(); auto& field_map = *sink.mutable_config()->mutable_fields(); diff --git a/test/server/drain_manager_impl_test.cc b/test/server/drain_manager_impl_test.cc index 0b4624801ea60..207e3d6debaff 100644 --- a/test/server/drain_manager_impl_test.cc +++ b/test/server/drain_manager_impl_test.cc @@ -28,7 +28,7 @@ class DrainManagerImplTest : public testing::Test { TEST_F(DrainManagerImplTest, Default) { InSequence s; - DrainManagerImpl drain_manager(server_, envoy::api::v2::listener::Listener_DrainType_DEFAULT); + DrainManagerImpl drain_manager(server_, envoy::api::v2::Listener_DrainType_DEFAULT); // Test parent shutdown. Event::MockTimer* shutdown_timer = new Event::MockTimer(&server_.dispatcher_); @@ -66,7 +66,7 @@ TEST_F(DrainManagerImplTest, Default) { TEST_F(DrainManagerImplTest, ModifyOnly) { InSequence s; - DrainManagerImpl drain_manager(server_, envoy::api::v2::listener::Listener_DrainType_MODIFY_ONLY); + DrainManagerImpl drain_manager(server_, envoy::api::v2::Listener_DrainType_MODIFY_ONLY); EXPECT_CALL(server_, healthCheckFailed()).Times(0); EXPECT_FALSE(drain_manager.drainClose()); diff --git a/test/server/lds_api_test.cc b/test/server/lds_api_test.cc index aa661894171a0..4c37b2b21f92d 100644 --- a/test/server/lds_api_test.cc +++ b/test/server/lds_api_test.cc @@ -1,5 +1,3 @@ -#include "envoy/service/discovery/v2/lds.pb.h" - #include "common/config/utility.h" #include "common/http/message_impl.h" @@ -57,11 +55,11 @@ class LdsApiTest : public testing::Test { void expectAdd(const std::string& listener_name, bool updated) { EXPECT_CALL(listener_manager_, addOrUpdateListener(_, true)) - .WillOnce(Invoke([listener_name, updated](const envoy::api::v2::listener::Listener& config, - bool) -> bool { - EXPECT_EQ(listener_name, config.name()); - return updated; - })); + .WillOnce( + Invoke([listener_name, updated](const envoy::api::v2::Listener& config, bool) -> bool { + EXPECT_EQ(listener_name, config.name()); + return updated; + })); } void expectRequest() { @@ -115,7 +113,7 @@ TEST_F(LdsApiTest, ValidateFail) { setup(true); - Protobuf::RepeatedPtrField listeners; + Protobuf::RepeatedPtrField listeners; listeners.Add(); EXPECT_THROW(lds_->onConfigUpdate(listeners), ProtoValidationException); diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index 3da1244d12410..50e0b7dcb3752 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -52,24 +52,24 @@ class ListenerManagerImplTest : public testing::Test { * 3) Stores the factory context for later use. * 4) Creates a mock local drain manager for the listener. */ - ListenerHandle* expectListenerCreate(bool need_init, - envoy::api::v2::listener::Listener::DrainType drain_type = - envoy::api::v2::listener::Listener_DrainType_DEFAULT) { + ListenerHandle* expectListenerCreate( + bool need_init, + envoy::api::v2::Listener::DrainType drain_type = envoy::api::v2::Listener_DrainType_DEFAULT) { ListenerHandle* raw_listener = new ListenerHandle(); EXPECT_CALL(listener_factory_, createDrainManager_(drain_type)) .WillOnce(Return(raw_listener->drain_manager_)); EXPECT_CALL(listener_factory_, createNetworkFilterFactoryList(_, _)) - .WillOnce(Invoke([raw_listener, need_init]( - const Protobuf::RepeatedPtrField&, - Configuration::FactoryContext& context) - -> std::vector { - std::shared_ptr notifier(raw_listener); - raw_listener->context_ = &context; - if (need_init) { - context.initManager().registerTarget(notifier->target_); - } - return {[notifier](Network::FilterManager&) -> void {}}; - })); + .WillOnce(Invoke( + [raw_listener, need_init](const Protobuf::RepeatedPtrField&, + Configuration::FactoryContext& context) + -> std::vector { + std::shared_ptr notifier(raw_listener); + raw_listener->context_ = &context; + if (need_init) { + context.initManager().registerTarget(notifier->target_); + } + return {[notifier](Network::FilterManager&) -> void {}}; + })); return raw_listener; } @@ -100,18 +100,16 @@ class ListenerManagerImplWithRealFiltersTest : public ListenerManagerImplTest { ListenerManagerImplWithRealFiltersTest() { // Use real filter loading by default. ON_CALL(listener_factory_, createNetworkFilterFactoryList(_, _)) + .WillByDefault(Invoke([](const Protobuf::RepeatedPtrField& filters, + Configuration::FactoryContext& context) + -> std::vector { + return ProdListenerComponentFactory::createNetworkFilterFactoryList_(filters, context); + })); + ON_CALL(listener_factory_, createListenerFilterFactoryList(_, _)) .WillByDefault( - Invoke([](const Protobuf::RepeatedPtrField& filters, + Invoke([](const Protobuf::RepeatedPtrField& filters, Configuration::FactoryContext& context) - -> std::vector { - return ProdListenerComponentFactory::createNetworkFilterFactoryList_(filters, - context); - })); - ON_CALL(listener_factory_, createListenerFilterFactoryList(_, _)) - .WillByDefault(Invoke( - [](const Protobuf::RepeatedPtrField& filters, - Configuration::FactoryContext& context) - -> std::vector { + -> std::vector { return ProdListenerComponentFactory::createListenerFilterFactoryList_(filters, context); })); @@ -280,7 +278,7 @@ TEST_F(ListenerManagerImplTest, ModifyOnlyDrainType) { )EOF"; ListenerHandle* listener_foo = - expectListenerCreate(false, envoy::api::v2::listener::Listener_DrainType_MODIFY_ONLY); + expectListenerCreate(false, envoy::api::v2::Listener_DrainType_MODIFY_ONLY); EXPECT_CALL(listener_factory_, createListenSocket(_, true)); EXPECT_TRUE(manager_->addOrUpdateListener(parseListenerFromV2Yaml(listener_foo_yaml), true)); checkStats(1, 0, 0, 0, 1, 0); @@ -317,7 +315,7 @@ TEST_F(ListenerManagerImplTest, AddListenerAddressNotMatching) { )EOF"; ListenerHandle* listener_foo_different_address = - expectListenerCreate(false, envoy::api::v2::listener::Listener_DrainType_MODIFY_ONLY); + expectListenerCreate(false, envoy::api::v2::Listener_DrainType_MODIFY_ONLY); EXPECT_CALL(*listener_foo_different_address, onDestroy()); EXPECT_THROW_WITH_MESSAGE(manager_->addOrUpdateListener( parseListenerFromJson(listener_foo_different_address_json), true), diff --git a/test/server/utility.h b/test/server/utility.h index 73374ebc03f4c..9f9376e62cb1c 100644 --- a/test/server/utility.h +++ b/test/server/utility.h @@ -7,15 +7,15 @@ namespace Envoy { namespace Server { namespace { -inline envoy::api::v2::listener::Listener parseListenerFromJson(const std::string& json_string) { - envoy::api::v2::listener::Listener listener; +inline envoy::api::v2::Listener parseListenerFromJson(const std::string& json_string) { + envoy::api::v2::Listener listener; auto json_object_ptr = Json::Factory::loadFromString(json_string); Config::LdsJson::translateListener(*json_object_ptr, listener); return listener; } -inline envoy::api::v2::listener::Listener parseListenerFromV2Yaml(const std::string& yaml) { - envoy::api::v2::listener::Listener listener; +inline envoy::api::v2::Listener parseListenerFromV2Yaml(const std::string& yaml) { + envoy::api::v2::Listener listener; MessageUtil::loadFromYaml(yaml, listener); return listener; } diff --git a/test/test_common/BUILD b/test/test_common/BUILD index 67bf3b5307c58..a1fe219e283f2 100644 --- a/test/test_common/BUILD +++ b/test/test_common/BUILD @@ -70,6 +70,7 @@ envoy_cc_test_library( srcs = ["utility.cc"], hdrs = ["utility.h"], external_deps = [ + "envoy_bootstrap", "abseil_strings", ], deps = [ @@ -84,7 +85,6 @@ envoy_cc_test_library( "//source/common/network:address_lib", "//source/common/network:utility_lib", "//source/common/protobuf:utility_lib", - "@envoy_api//envoy/config/bootstrap/v2:bootstrap_cc", ], ) diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index 380b326a7a318..ed6d9c0556b46 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -151,9 +151,8 @@ std::vector TestUtility::listFiles(const std::string& path, bool re return file_names; } -envoy::config::bootstrap::v2::Bootstrap -TestUtility::parseBootstrapFromJson(const std::string& json_string) { - envoy::config::bootstrap::v2::Bootstrap bootstrap; +envoy::api::v2::Bootstrap TestUtility::parseBootstrapFromJson(const std::string& json_string) { + envoy::api::v2::Bootstrap bootstrap; auto json_object_ptr = Json::Factory::loadFromString(json_string); Config::BootstrapJson::translateBootstrap(*json_object_ptr, bootstrap); return bootstrap; diff --git a/test/test_common/utility.h b/test/test_common/utility.h index dac429f9bcf8c..9faa4ec4616b9 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -10,7 +10,6 @@ #include #include "envoy/buffer/buffer.h" -#include "envoy/config/bootstrap/v2/bootstrap.pb.h" #include "envoy/network/address.h" #include "envoy/stats/stats.h" @@ -19,6 +18,7 @@ #include "test/test_common/printers.h" +#include "api/bootstrap.pb.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -192,10 +192,9 @@ class TestUtility { /** * Parse bootstrap config from v1 JSON static config string. * @param json_string source v1 JSON static config string. - * @return envoy::config::bootstrap::v2::Bootstrap. + * @return envoy::api::v2::Bootstrap. */ - static envoy::config::bootstrap::v2::Bootstrap - parseBootstrapFromJson(const std::string& json_string); + static envoy::api::v2::Bootstrap parseBootstrapFromJson(const std::string& json_string); /** * Returns a "novel" IPv4 loopback address, if available. diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index 1f88ffe1c1bad..785ad9b075667 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -42,7 +42,7 @@ ToolConfig::ToolConfig(std::unique_ptr headers, int ran RouterCheckTool RouterCheckTool::create(const std::string& router_config_json) { // TODO(hennna): Allow users to load a full config and extract the route configuration from it. Json::ObjectSharedPtr loader = Json::Factory::loadFromFile(router_config_json); - envoy::api::v2::route::RouteConfiguration route_config; + envoy::api::v2::RouteConfiguration route_config; Config::RdsJson::translateRouteConfiguration(*loader, route_config); std::unique_ptr> runtime(new NiceMock()); diff --git a/test/tools/schema_validator/validator.cc b/test/tools/schema_validator/validator.cc index 352e4d5d9ee3c..4121b3af678b8 100644 --- a/test/tools/schema_validator/validator.cc +++ b/test/tools/schema_validator/validator.cc @@ -52,9 +52,9 @@ void Validator::validate(const std::string& json_path, Schema::Type schema_type) case Schema::Type::Route: { Runtime::MockLoader runtime; Upstream::MockClusterManager cm; - // Construct a envoy::api::v2::route::RouteConfiguration to validate the Route configuration and - // ignore the output since nothing will consume it. - envoy::api::v2::route::RouteConfiguration route_config; + // Construct a envoy::api::v2::RouteConfiguration to validate the Route configuration and ignore + // the output since nothing will consume it. + envoy::api::v2::RouteConfiguration route_config; Config::RdsJson::translateRouteConfiguration(*loader, route_config); break; }