From 0da67d5f12705a2ccff9ffed9b13ebb38f2e3c46 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 9 May 2019 09:43:19 -0400 Subject: [PATCH] string == string! Signed-off-by: Alyssa Wilk --- include/envoy/upstream/locality.h | 3 +-- source/common/access_log/access_log_formatter.cc | 4 ++-- source/common/config/http_subscription_impl.cc | 7 +++---- source/common/config/http_subscription_impl.h | 2 +- source/common/config/utility.h | 2 +- source/common/protobuf/protobuf.h | 6 ++---- source/common/protobuf/utility.cc | 4 ++-- source/common/protobuf/utility.h | 6 +++--- source/common/router/config_impl.cc | 4 ++-- source/common/router/config_impl.h | 4 ++-- source/common/router/header_parser.cc | 2 +- source/common/router/header_parser.h | 2 +- .../http_grpc/grpc_access_log_impl.cc | 9 +++------ .../common/ext_authz/check_request_utils.cc | 8 +++----- .../common/ext_authz/check_request_utils.h | 10 +++++----- source/extensions/filters/common/lua/wrappers.cc | 5 ++--- source/extensions/filters/common/lua/wrappers.h | 7 +++---- .../filters/http/ext_authz/ext_authz.cc | 2 +- .../filters/http/ext_authz/ext_authz.h | 2 +- .../json_transcoder_filter.cc | 12 +++++------- .../json_transcoder_filter.h | 4 ++-- .../extensions/filters/http/gzip/gzip_filter.cc | 4 ++-- .../extensions/filters/http/gzip/gzip_filter.h | 2 +- .../header_to_metadata_filter.cc | 2 +- .../filters/http/jwt_authn/verifier.cc | 16 ++++++++-------- .../extensions/filters/http/jwt_authn/verifier.h | 11 +++++------ source/extensions/filters/http/lua/wrappers.h | 2 +- .../filters/network/dubbo_proxy/config.cc | 2 +- .../network/http_connection_manager/config.cc | 2 +- .../filters/network/thrift_proxy/config.cc | 2 +- source/server/listener_manager_impl.cc | 4 ++-- test/common/protobuf/utility_test.cc | 2 +- test/common/stream_info/stream_info_impl_test.cc | 2 +- .../common/ext_authz/check_request_utils_test.cc | 12 +++++------- .../filters/common/rbac/matchers_test.cc | 4 ++-- .../json_transcoder_filter_test.cc | 4 ++-- .../filters/http/lua/lua_integration_test.cc | 3 +-- .../filters/http/rbac/rbac_filter_test.cc | 4 ++-- .../filters/network/rbac/filter_test.cc | 4 ++-- .../extensions/stats_sinks/statsd/config_test.cc | 2 +- test/server/options_impl_test.cc | 4 +--- tools/check_format.py | 3 --- 42 files changed, 87 insertions(+), 109 deletions(-) diff --git a/include/envoy/upstream/locality.h b/include/envoy/upstream/locality.h index 95c30cc121044..f4ff0948cfbd7 100644 --- a/include/envoy/upstream/locality.h +++ b/include/envoy/upstream/locality.h @@ -24,8 +24,7 @@ struct LocalityEqualTo { struct LocalityLess { bool operator()(const envoy::api::v2::core::Locality& lhs, const envoy::api::v2::core::Locality& rhs) const { - using LocalityTuple = std::tuple; + using LocalityTuple = std::tuple; const LocalityTuple lhs_tuple = LocalityTuple(lhs.region(), lhs.zone(), lhs.sub_zone()); const LocalityTuple rhs_tuple = LocalityTuple(rhs.region(), rhs.zone(), rhs.sub_zone()); return lhs_tuple < rhs_tuple; diff --git a/source/common/access_log/access_log_formatter.cc b/source/common/access_log/access_log_formatter.cc index a995349f02a01..78f862e7bcee7 100644 --- a/source/common/access_log/access_log_formatter.cc +++ b/source/common/access_log/access_log_formatter.cc @@ -112,7 +112,7 @@ std::string JsonFormatterImpl::format(const Http::HeaderMap& request_headers, (*output_struct.mutable_fields())[pair.first] = string_value; } - ProtobufTypes::String log_line; + std::string log_line; const auto conversion_status = Protobuf::util::MessageToJsonString(output_struct, &log_line); if (!conversion_status.ok()) { log_line = @@ -504,7 +504,7 @@ std::string MetadataFormatter::format(const envoy::api::v2::core::Metadata& meta } data = &val; } - ProtobufTypes::String json; + std::string json; const auto status = Protobuf::util::MessageToJsonString(*data, &json); RELEASE_ASSERT(status.ok(), ""); if (max_length_ && json.length() > max_length_.value()) { diff --git a/source/common/config/http_subscription_impl.cc b/source/common/config/http_subscription_impl.cc index 4e71401a95280..971d342e8c4e4 100644 --- a/source/common/config/http_subscription_impl.cc +++ b/source/common/config/http_subscription_impl.cc @@ -44,16 +44,15 @@ void HttpSubscriptionImpl::start(const std::set& resources, init_fetch_timeout_timer_->enableTimer(init_fetch_timeout_); } - Protobuf::RepeatedPtrField resources_vector(resources.begin(), - resources.end()); + Protobuf::RepeatedPtrField resources_vector(resources.begin(), resources.end()); request_.mutable_resource_names()->Swap(&resources_vector); callbacks_ = &callbacks; initialize(); } void HttpSubscriptionImpl::updateResources(const std::set& update_to_these_names) { - Protobuf::RepeatedPtrField resources_vector(update_to_these_names.begin(), - update_to_these_names.end()); + Protobuf::RepeatedPtrField resources_vector(update_to_these_names.begin(), + update_to_these_names.end()); request_.mutable_resource_names()->Swap(&resources_vector); } diff --git a/source/common/config/http_subscription_impl.h b/source/common/config/http_subscription_impl.h index 8a210e08f154f..97612b3897153 100644 --- a/source/common/config/http_subscription_impl.h +++ b/source/common/config/http_subscription_impl.h @@ -43,7 +43,7 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher, void disableInitFetchTimeoutTimer(); std::string path_; - Protobuf::RepeatedPtrField resources_; + Protobuf::RepeatedPtrField resources_; Config::SubscriptionCallbacks* callbacks_{}; envoy::api::v2::DiscoveryRequest request_; SubscriptionStats stats_; diff --git a/source/common/config/utility.h b/source/common/config/utility.h index 04220ea3c2503..4e4861994d456 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -236,7 +236,7 @@ class Utility { * @param name string identifier for the particular implementation. Note: this is a proto string * because it is assumed that this value will be pulled directly from the configuration proto. */ - template static Factory& getAndCheckFactory(const ProtobufTypes::String& name) { + template static Factory& getAndCheckFactory(const std::string& name) { if (name.empty()) { throw EnvoyException("Provided name for static registration lookup was empty."); } diff --git a/source/common/protobuf/protobuf.h b/source/common/protobuf/protobuf.h index c258e322909b9..fbeffd9dcb4b4 100644 --- a/source/common/protobuf/protobuf.h +++ b/source/common/protobuf/protobuf.h @@ -40,14 +40,12 @@ namespace ProtobufUtil = google::protobuf::util; // namespace. namespace ProtobufWkt = google::protobuf; -// Alternative protobuf implementations might not use std::string as a string -// type. Below we provide wrappers to facilitate remapping of the type during -// import. +// Alternative protobuf implementations might not have the same basic types. +// Below we provide wrappers to facilitate remapping of the type during import. namespace ProtobufTypes { typedef std::unique_ptr MessagePtr; -typedef std::string String; typedef int64_t Int64; } // namespace ProtobufTypes diff --git a/source/common/protobuf/utility.cc b/source/common/protobuf/utility.cc index 36270ec5611b9..d5f23308f6261 100644 --- a/source/common/protobuf/utility.cc +++ b/source/common/protobuf/utility.cc @@ -225,7 +225,7 @@ std::string MessageUtil::getJsonStringFromMessage(const Protobuf::Message& messa if (always_print_primitive_fields) { json_options.always_print_primitive_fields = true; } - ProtobufTypes::String json; + std::string json; const auto status = Protobuf::util::MessageToJsonString(message, &json, json_options); // This should always succeed unless something crash-worthy such as out-of-memory. RELEASE_ASSERT(status.ok(), ""); @@ -236,7 +236,7 @@ void MessageUtil::jsonConvert(const Protobuf::Message& source, Protobuf::Message // TODO(htuch): Consolidate with the inflight cleanups here. Protobuf::util::JsonPrintOptions json_options; json_options.preserve_proto_field_names = true; - ProtobufTypes::String json; + std::string json; const auto status = Protobuf::util::MessageToJsonString(source, &json, json_options); if (!status.ok()) { throw EnvoyException(fmt::format("Unable to convert protobuf message to JSON string: {} {}", diff --git a/source/common/protobuf/utility.h b/source/common/protobuf/utility.h index 769ea6e14af84..4225048cbe6a7 100644 --- a/source/common/protobuf/utility.h +++ b/source/common/protobuf/utility.h @@ -104,7 +104,7 @@ class MissingFieldException : public EnvoyException { class RepeatedPtrUtil { public: - static std::string join(const Protobuf::RepeatedPtrField& source, + static std::string join(const Protobuf::RepeatedPtrField& source, const std::string& delimiter) { return StringUtil::join(std::vector(source.begin(), source.end()), delimiter); } @@ -126,7 +126,7 @@ class RepeatedPtrUtil { static std::size_t hash(const Protobuf::RepeatedPtrField& source) { // Use Protobuf::io::CodedOutputStream to force deterministic serialization, so that the same // message doesn't hash to different values. - ProtobufTypes::String text; + std::string text; { // For memory safety, the StringOutputStream needs to be destroyed before // we read the string. @@ -172,7 +172,7 @@ class MessageUtil { static std::size_t hash(const Protobuf::Message& message) { // Use Protobuf::io::CodedOutputStream to force deterministic serialization, so that the same // message doesn't hash to different values. - ProtobufTypes::String text; + std::string text; { // For memory safety, the StringOutputStream needs to be destroyed before // we read the string. diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 29f06492dc124..c1b3ed8d3c86e 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -1146,8 +1146,8 @@ createRouteSpecificFilterConfig(const std::string& name, const ProtobufWkt::Any& } // namespace PerFilterConfigs::PerFilterConfigs( - const Protobuf::Map& typed_configs, - const Protobuf::Map& configs, + const Protobuf::Map& typed_configs, + const Protobuf::Map& configs, Server::Configuration::FactoryContext& factory_context) { if (!typed_configs.empty() && !configs.empty()) { throw EnvoyException("Only one of typed_configs or configs can be specified"); diff --git a/source/common/router/config_impl.h b/source/common/router/config_impl.h index 2cf26dbbf3f1b..bdc0b6db9086c 100644 --- a/source/common/router/config_impl.h +++ b/source/common/router/config_impl.h @@ -50,8 +50,8 @@ class Matchable { class PerFilterConfigs { public: - PerFilterConfigs(const Protobuf::Map& typed_configs, - const Protobuf::Map& configs, + PerFilterConfigs(const Protobuf::Map& typed_configs, + const Protobuf::Map& configs, Server::Configuration::FactoryContext& factory_context); const RouteSpecificFilterConfig* get(const std::string& name) const; diff --git a/source/common/router/header_parser.cc b/source/common/router/header_parser.cc index cf547422bcde0..05022605347c2 100644 --- a/source/common/router/header_parser.cc +++ b/source/common/router/header_parser.cc @@ -236,7 +236,7 @@ HeaderParserPtr HeaderParser::configure( HeaderParserPtr HeaderParser::configure( const Protobuf::RepeatedPtrField& headers_to_add, - const Protobuf::RepeatedPtrField& headers_to_remove) { + const Protobuf::RepeatedPtrField& headers_to_remove) { HeaderParserPtr header_parser = configure(headers_to_add); for (const auto& header : headers_to_remove) { diff --git a/source/common/router/header_parser.h b/source/common/router/header_parser.h index aaeacf4152acd..147574c43abd1 100644 --- a/source/common/router/header_parser.h +++ b/source/common/router/header_parser.h @@ -37,7 +37,7 @@ class HeaderParser { */ static HeaderParserPtr configure( const Protobuf::RepeatedPtrField& headers_to_add, - const Protobuf::RepeatedPtrField& headers_to_remove); + const Protobuf::RepeatedPtrField& headers_to_remove); void evaluateHeaders(Http::HeaderMap& headers, const StreamInfo::StreamInfo& stream_info) const; diff --git a/source/extensions/access_loggers/http_grpc/grpc_access_log_impl.cc b/source/extensions/access_loggers/http_grpc/grpc_access_log_impl.cc index 8bbea843f71e8..32df710bac18d 100644 --- a/source/extensions/access_loggers/http_grpc/grpc_access_log_impl.cc +++ b/source/extensions/access_loggers/http_grpc/grpc_access_log_impl.cc @@ -350,8 +350,7 @@ void HttpGrpcAccessLog::log(const Http::HeaderMap* request_headers, for (const auto& header : request_headers_to_log_) { const Http::HeaderEntry* entry = request_headers->get(header); if (entry != nullptr) { - logged_headers->insert( - {header.get(), ProtobufTypes::String(entry->value().getStringView())}); + logged_headers->insert({header.get(), std::string(entry->value().getStringView())}); } } } @@ -372,8 +371,7 @@ void HttpGrpcAccessLog::log(const Http::HeaderMap* request_headers, for (const auto& header : response_headers_to_log_) { const Http::HeaderEntry* entry = response_headers->get(header); if (entry != nullptr) { - logged_headers->insert( - {header.get(), ProtobufTypes::String(entry->value().getStringView())}); + logged_headers->insert({header.get(), std::string(entry->value().getStringView())}); } } } @@ -384,8 +382,7 @@ void HttpGrpcAccessLog::log(const Http::HeaderMap* request_headers, for (const auto& header : response_trailers_to_log_) { const Http::HeaderEntry* entry = response_trailers->get(header); if (entry != nullptr) { - logged_headers->insert( - {header.get(), ProtobufTypes::String(entry->value().getStringView())}); + logged_headers->insert({header.get(), std::string(entry->value().getStringView())}); } } } diff --git a/source/extensions/filters/common/ext_authz/check_request_utils.cc b/source/extensions/filters/common/ext_authz/check_request_utils.cc index e9b45bf17d9ea..d243e04c5978f 100644 --- a/source/extensions/filters/common/ext_authz/check_request_utils.cc +++ b/source/extensions/filters/common/ext_authz/check_request_utils.cc @@ -109,10 +109,8 @@ void CheckRequestUtils::setHttpRequest( [](const Envoy::Http::HeaderEntry& e, void* ctx) { // Skip any client EnvoyAuthPartialBody header, which could interfere with internal use. if (e.key().getStringView() != Http::Headers::get().EnvoyAuthPartialBody.get()) { - Envoy::Protobuf::Map* - mutable_headers = - static_cast*>(ctx); + Envoy::Protobuf::Map* mutable_headers = + static_cast*>(ctx); (*mutable_headers)[std::string(e.key().getStringView())] = std::string(e.value().getStringView()); } @@ -144,7 +142,7 @@ void CheckRequestUtils::setAttrContextRequest( void CheckRequestUtils::createHttpCheck( const Envoy::Http::StreamDecoderFilterCallbacks* callbacks, const Envoy::Http::HeaderMap& headers, - Protobuf::Map&& context_extensions, + Protobuf::Map&& context_extensions, envoy::service::auth::v2::CheckRequest& request, uint64_t max_request_bytes) { auto attrs = request.mutable_attributes(); diff --git a/source/extensions/filters/common/ext_authz/check_request_utils.h b/source/extensions/filters/common/ext_authz/check_request_utils.h index da89fe72fe4e7..5fa997c80a522 100644 --- a/source/extensions/filters/common/ext_authz/check_request_utils.h +++ b/source/extensions/filters/common/ext_authz/check_request_utils.h @@ -45,11 +45,11 @@ class CheckRequestUtils { * @param request is the reference to the check request that will be filled up. * @param with_request_body when true, will add the request body to the check request. */ - static void - createHttpCheck(const Envoy::Http::StreamDecoderFilterCallbacks* callbacks, - const Envoy::Http::HeaderMap& headers, - Protobuf::Map&& context_extensions, - envoy::service::auth::v2::CheckRequest& request, uint64_t max_request_bytes); + static void createHttpCheck(const Envoy::Http::StreamDecoderFilterCallbacks* callbacks, + const Envoy::Http::HeaderMap& headers, + Protobuf::Map&& context_extensions, + envoy::service::auth::v2::CheckRequest& request, + uint64_t max_request_bytes); /** * createTcpCheck is used to extract the attributes from the network layer and fill them up diff --git a/source/extensions/filters/common/lua/wrappers.cc b/source/extensions/filters/common/lua/wrappers.cc index efb522fe18a92..399155a253e36 100644 --- a/source/extensions/filters/common/lua/wrappers.cc +++ b/source/extensions/filters/common/lua/wrappers.cc @@ -76,9 +76,8 @@ void MetadataMapHelper::setValue(lua_State* state, const ProtobufWkt::Value& val } } -void MetadataMapHelper::createTable( - lua_State* state, - const Protobuf::Map& fields) { +void MetadataMapHelper::createTable(lua_State* state, + const Protobuf::Map& fields) { lua_createtable(state, 0, fields.size()); for (const auto& field : fields) { int top = lua_gettop(state); diff --git a/source/extensions/filters/common/lua/wrappers.h b/source/extensions/filters/common/lua/wrappers.h index 7d8eeebed844a..5ac8ff217c3fb 100644 --- a/source/extensions/filters/common/lua/wrappers.h +++ b/source/extensions/filters/common/lua/wrappers.h @@ -44,9 +44,8 @@ class MetadataMapWrapper; struct MetadataMapHelper { static void setValue(lua_State* state, const ProtobufWkt::Value& value); - static void - createTable(lua_State* state, - const Protobuf::Map& fields); + static void createTable(lua_State* state, + const Protobuf::Map& fields); }; /** @@ -62,7 +61,7 @@ class MetadataMapIterator : public BaseLuaObject { private: MetadataMapWrapper& parent_; - Protobuf::Map::const_iterator current_; + Protobuf::Map::const_iterator current_; }; /** diff --git a/source/extensions/filters/http/ext_authz/ext_authz.cc b/source/extensions/filters/http/ext_authz/ext_authz.cc index 203ab4bd5f6c1..b04818436a01d 100644 --- a/source/extensions/filters/http/ext_authz/ext_authz.cc +++ b/source/extensions/filters/http/ext_authz/ext_authz.cc @@ -50,7 +50,7 @@ void Filter::initiateCall(const Http::HeaderMap& headers) { cfg_base.merge(cfg); }); - Protobuf::Map context_extensions; + Protobuf::Map context_extensions; if (maybe_merged_per_route_config) { context_extensions = maybe_merged_per_route_config.value().takeContextExtensions(); } diff --git a/source/extensions/filters/http/ext_authz/ext_authz.h b/source/extensions/filters/http/ext_authz/ext_authz.h index 4133aea2d1813..e32bea814b3c6 100644 --- a/source/extensions/filters/http/ext_authz/ext_authz.h +++ b/source/extensions/filters/http/ext_authz/ext_authz.h @@ -82,7 +82,7 @@ typedef std::shared_ptr FilterConfigSharedPtr; */ class FilterConfigPerRoute : public Router::RouteSpecificFilterConfig { public: - using ContextExtensionsMap = Protobuf::Map; + using ContextExtensionsMap = Protobuf::Map; FilterConfigPerRoute(const envoy::config::filter::http::ext_authz::v2::ExtAuthzPerRoute& config) : context_extensions_(config.has_check_settings() diff --git a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc index 8d0e16aeb62e8..c455dfc563f8c 100644 --- a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc +++ b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc @@ -107,7 +107,7 @@ JsonTranscoderConfig::JsonTranscoderConfig( } PathMatcherBuilder pmb; - std::unordered_set ignored_query_parameters; + std::unordered_set ignored_query_parameters; for (const auto& query_param : proto_config.ignored_query_parameters()) { ignored_query_parameters.insert(query_param); } @@ -165,9 +165,9 @@ ProtobufUtil::Status JsonTranscoderConfig::createTranscoder( return ProtobufUtil::Status(Code::INVALID_ARGUMENT, "Request headers has application/grpc content-type"); } - const ProtobufTypes::String method(headers.Method()->value().getStringView()); - ProtobufTypes::String path(headers.Path()->value().getStringView()); - ProtobufTypes::String args; + const std::string method(headers.Method()->value().getStringView()); + std::string path(headers.Path()->value().getStringView()); + std::string args; const size_t pos = path.find('?'); if (pos != std::string::npos) { @@ -473,9 +473,7 @@ void JsonTranscoderFilter::buildResponseFromHttpBodyOutput(Http::HeaderMap& resp http_body.ParseFromZeroCopyStream(&stream); const auto& body = http_body.data(); - // TODO(mrice32): This string conversion is currently required because body has a different - // type within Google. Remove when the string types merge. - data.add(ProtobufTypes::String(body)); + data.add(body); response_headers.insertContentType().value(http_body.content_type()); response_headers.insertContentLength().value(body.size()); diff --git a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h index c9eeb59791d04..48b91b922bda3 100644 --- a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h +++ b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h @@ -35,9 +35,9 @@ struct VariableBinding { // The location of the field in the protobuf message, where the value // needs to be inserted, e.g. "shelf.theme" would mean the "theme" field // of the nested "shelf" message of the request protobuf message. - std::vector field_path; + std::vector field_path; // The value to be inserted. - ProtobufTypes::String value; + std::string value; }; /** diff --git a/source/extensions/filters/http/gzip/gzip_filter.cc b/source/extensions/filters/http/gzip/gzip_filter.cc index 54c8178c8c4ed..883cf928e6410 100644 --- a/source/extensions/filters/http/gzip/gzip_filter.cc +++ b/source/extensions/filters/http/gzip/gzip_filter.cc @@ -83,8 +83,8 @@ Compressor::ZlibCompressorImpl::CompressionStrategy GzipFilterConfig::compressio } } -StringUtil::CaseUnorderedSet GzipFilterConfig::contentTypeSet( - const Protobuf::RepeatedPtrField& types) { +StringUtil::CaseUnorderedSet +GzipFilterConfig::contentTypeSet(const Protobuf::RepeatedPtrField& types) { return types.empty() ? StringUtil::CaseUnorderedSet(defaultContentEncoding().begin(), defaultContentEncoding().end()) : StringUtil::CaseUnorderedSet(types.cbegin(), types.cend()); diff --git a/source/extensions/filters/http/gzip/gzip_filter.h b/source/extensions/filters/http/gzip/gzip_filter.h index 9fdcab98a9d33..d60f0b16d77be 100644 --- a/source/extensions/filters/http/gzip/gzip_filter.h +++ b/source/extensions/filters/http/gzip/gzip_filter.h @@ -84,7 +84,7 @@ class GzipFilterConfig { static Compressor::ZlibCompressorImpl::CompressionStrategy compressionStrategyEnum( envoy::config::filter::http::gzip::v2::Gzip_CompressionStrategy compression_strategy); static StringUtil::CaseUnorderedSet - contentTypeSet(const Protobuf::RepeatedPtrField& types); + contentTypeSet(const Protobuf::RepeatedPtrField& types); static uint64_t contentLengthUint(Protobuf::uint32 length); static uint64_t memoryLevelUint(Protobuf::uint32 level); diff --git a/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc b/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc index 05ce99cc98158..c7ccf19b54c14 100644 --- a/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc +++ b/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc @@ -101,7 +101,7 @@ bool HeaderToMetadataFilter::addMetadata(StructMap& map, const std::string& meta // Sane enough, add the key/value. switch (type) { case envoy::config::filter::http::header_to_metadata::v2::Config_ValueType_STRING: - val.set_string_value(ProtobufTypes::String(value)); + val.set_string_value(std::string(value)); break; case envoy::config::filter::http::header_to_metadata::v2::Config_ValueType_NUMBER: { double dval; diff --git a/source/extensions/filters/http/jwt_authn/verifier.cc b/source/extensions/filters/http/jwt_authn/verifier.cc index efa9b8548f828..6d3ec8aa971cd 100644 --- a/source/extensions/filters/http/jwt_authn/verifier.cc +++ b/source/extensions/filters/http/jwt_authn/verifier.cc @@ -182,7 +182,7 @@ class AllowFailedVerifierImpl : public BaseVerifierImpl { }; VerifierConstPtr innerCreate(const JwtRequirement& requirement, - const Protobuf::Map& providers, + const Protobuf::Map& providers, const AuthFactory& factory, const Extractor& extractor, const BaseVerifierImpl* parent); @@ -210,7 +210,7 @@ class BaseGroupVerifierImpl : public BaseVerifierImpl { class AnyVerifierImpl : public BaseGroupVerifierImpl { public: AnyVerifierImpl(const JwtRequirementOrList& or_list, const AuthFactory& factory, - const Protobuf::Map& providers, + const Protobuf::Map& providers, const Extractor& extractor_for_allow_fail, const BaseVerifierImpl* parent) : BaseGroupVerifierImpl(parent) { for (const auto& it : or_list.requirements()) { @@ -235,7 +235,7 @@ class AnyVerifierImpl : public BaseGroupVerifierImpl { class AllVerifierImpl : public BaseGroupVerifierImpl { public: AllVerifierImpl(const JwtRequirementAndList& and_list, const AuthFactory& factory, - const Protobuf::Map& providers, + const Protobuf::Map& providers, const Extractor& extractor_for_allow_fail, const BaseVerifierImpl* parent) : BaseGroupVerifierImpl(parent) { for (const auto& it : and_list.requirements()) { @@ -267,7 +267,7 @@ class AllowAllVerifierImpl : public BaseVerifierImpl { }; VerifierConstPtr innerCreate(const JwtRequirement& requirement, - const Protobuf::Map& providers, + const Protobuf::Map& providers, const AuthFactory& factory, const Extractor& extractor_for_allow_fail, const BaseVerifierImpl* parent) { std::string provider_name; @@ -313,10 +313,10 @@ ContextSharedPtr Verifier::createContext(Http::HeaderMap& headers, Callbacks* ca return std::make_shared(headers, callback); } -VerifierConstPtr -Verifier::create(const JwtRequirement& requirement, - const Protobuf::Map& providers, - const AuthFactory& factory, const Extractor& extractor_for_allow_fail) { +VerifierConstPtr Verifier::create(const JwtRequirement& requirement, + const Protobuf::Map& providers, + const AuthFactory& factory, + const Extractor& extractor_for_allow_fail) { return innerCreate(requirement, providers, factory, extractor_for_allow_fail, nullptr); } diff --git a/source/extensions/filters/http/jwt_authn/verifier.h b/source/extensions/filters/http/jwt_authn/verifier.h index 5ccca60c7c24d..d3a9575ad40e6 100644 --- a/source/extensions/filters/http/jwt_authn/verifier.h +++ b/source/extensions/filters/http/jwt_authn/verifier.h @@ -71,12 +71,11 @@ class Verifier { virtual void verify(ContextSharedPtr context) const PURE; // Factory method for creating verifiers. - static VerifierConstPtr - create(const ::envoy::config::filter::http::jwt_authn::v2alpha::JwtRequirement& requirement, - const Protobuf::Map& - providers, - const AuthFactory& factory, const Extractor& extractor_for_allow_fail); + static VerifierConstPtr create( + const ::envoy::config::filter::http::jwt_authn::v2alpha::JwtRequirement& requirement, + const Protobuf::Map< + std::string, ::envoy::config::filter::http::jwt_authn::v2alpha::JwtProvider>& providers, + const AuthFactory& factory, const Extractor& extractor_for_allow_fail); // Factory method for creating verifier contexts. static ContextSharedPtr createContext(Http::HeaderMap& headers, Callbacks* callback); diff --git a/source/extensions/filters/http/lua/wrappers.h b/source/extensions/filters/http/lua/wrappers.h index b8644afc3dda3..91f1a400f5b81 100644 --- a/source/extensions/filters/http/lua/wrappers.h +++ b/source/extensions/filters/http/lua/wrappers.h @@ -116,7 +116,7 @@ class DynamicMetadataMapIterator private: DynamicMetadataMapWrapper& parent_; - Protobuf::Map::const_iterator current_; + Protobuf::Map::const_iterator current_; }; /** diff --git a/source/extensions/filters/network/dubbo_proxy/config.cc b/source/extensions/filters/network/dubbo_proxy/config.cc index 0d83fc2852e70..9ad115c44e39b 100644 --- a/source/extensions/filters/network/dubbo_proxy/config.cc +++ b/source/extensions/filters/network/dubbo_proxy/config.cc @@ -113,7 +113,7 @@ DeserializerPtr ConfigImpl::createDeserializer() { } void ConfigImpl::registerFilter(const DubboFilterConfig& proto_config) { - const ProtobufTypes::String& string_name = proto_config.name(); + const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " dubbo filter #{}", filter_factories_.size()); ENVOY_LOG(debug, " name: {}", string_name); diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index a00c9e552e007..92cce54bd3092 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -301,7 +301,7 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig( void HttpConnectionManagerConfig::processFilter( const envoy::config::filter::network::http_connection_manager::v2::HttpFilter& proto_config, int i, absl::string_view prefix, std::list& filter_factories) { - const ProtobufTypes::String& string_name = proto_config.name(); + const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " {} filter #{}", prefix, i); ENVOY_LOG(debug, " name: {}", string_name); diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index ba5e8a7b04dba..50d8ab1359786 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -156,7 +156,7 @@ ProtocolPtr ConfigImpl::createProtocol() { void ConfigImpl::processFilter( const envoy::config::filter::network::thrift_proxy::v2alpha1::ThriftFilter& proto_config) { - const ProtobufTypes::String& string_name = proto_config.name(); + const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " thrift filter #{}", filter_factories_.size()); ENVOY_LOG(debug, " name: {}", string_name); diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index f323777a8e454..8e58b33241734 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -51,7 +51,7 @@ std::vector ProdListenerComponentFactory::createNetwor std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { const auto& proto_config = filters[i]; - const ProtobufTypes::String string_name = proto_config.name(); + const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " filter #{}:", i); ENVOY_LOG(debug, " name: {}", string_name); const Json::ObjectSharedPtr filter_config = @@ -81,7 +81,7 @@ ProdListenerComponentFactory::createListenerFilterFactoryList_( std::vector ret; for (ssize_t i = 0; i < filters.size(); i++) { const auto& proto_config = filters[i]; - const ProtobufTypes::String string_name = proto_config.name(); + const std::string& string_name = proto_config.name(); ENVOY_LOG(debug, " filter #{}:", i); ENVOY_LOG(debug, " name: {}", string_name); const Json::ObjectSharedPtr filter_config = diff --git a/test/common/protobuf/utility_test.cc b/test/common/protobuf/utility_test.cc index 3788aa7f0883b..53ec8b03e5c5f 100644 --- a/test/common/protobuf/utility_test.cc +++ b/test/common/protobuf/utility_test.cc @@ -162,7 +162,7 @@ TEST_F(ProtobufUtilityTest, LoadTextProtoFromFile) { ->mutable_source_address() ->set_address("1.1.1.1"); - ProtobufTypes::String bootstrap_text; + std::string bootstrap_text; ASSERT_TRUE(Protobuf::TextFormat::PrintToString(bootstrap, &bootstrap_text)); const std::string filename = TestEnvironment::writeStringToFileForTest("proto.pb_text", bootstrap_text); diff --git a/test/common/stream_info/stream_info_impl_test.cc b/test/common/stream_info/stream_info_impl_test.cc index df6c786116f33..fec622ddc8107 100644 --- a/test/common/stream_info/stream_info_impl_test.cc +++ b/test/common/stream_info/stream_info_impl_test.cc @@ -192,7 +192,7 @@ TEST_F(StreamInfoImplTest, DynamicMetadataTest) { EXPECT_EQ("test_value", Config::Metadata::metadataValue(stream_info.dynamicMetadata(), "com.test", "test_key") .string_value()); - ProtobufTypes::String json; + std::string json; const auto test_struct = stream_info.dynamicMetadata().filter_metadata().at("com.test"); const auto status = Protobuf::util::MessageToJsonString(test_struct, &json); EXPECT_TRUE(status.ok()); diff --git a/test/extensions/filters/common/ext_authz/check_request_utils_test.cc b/test/extensions/filters/common/ext_authz/check_request_utils_test.cc index be0d077cf7c66..791e019e6aa95 100644 --- a/test/extensions/filters/common/ext_authz/check_request_utils_test.cc +++ b/test/extensions/filters/common/ext_authz/check_request_utils_test.cc @@ -86,8 +86,7 @@ TEST_F(CheckRequestUtilsTest, BasicHttp) { ExpectBasicHttp(); CheckRequestUtils::createHttpCheck(&callbacks_, request_headers, - Protobuf::Map(), - request_, size); + Protobuf::Map(), request_, size); ASSERT_EQ(size, request_.attributes().request().http().body().size()); EXPECT_EQ(buffer_->toString().substr(0, size), request_.attributes().request().http().body()); EXPECT_EQ(request_.attributes().request().http().headers().end(), @@ -103,8 +102,7 @@ TEST_F(CheckRequestUtilsTest, BasicHttpWithPartialBody) { ExpectBasicHttp(); CheckRequestUtils::createHttpCheck(&callbacks_, headers_, - Protobuf::Map(), - request_, size); + Protobuf::Map(), request_, size); ASSERT_EQ(size, request_.attributes().request().http().body().size()); EXPECT_EQ(buffer_->toString().substr(0, size), request_.attributes().request().http().body()); EXPECT_EQ("true", request_.attributes().request().http().headers().at( @@ -118,8 +116,8 @@ TEST_F(CheckRequestUtilsTest, BasicHttpWithFullBody) { ExpectBasicHttp(); CheckRequestUtils::createHttpCheck(&callbacks_, headers_, - Protobuf::Map(), - request_, buffer_->length()); + Protobuf::Map(), request_, + buffer_->length()); ASSERT_EQ(buffer_->length(), request_.attributes().request().http().body().size()); EXPECT_EQ(buffer_->toString().substr(0, buffer_->length()), request_.attributes().request().http().body()); @@ -145,7 +143,7 @@ TEST_F(CheckRequestUtilsTest, CheckAttrContextPeer) { EXPECT_CALL(ssl_, uriSanLocalCertificate()) .WillOnce(Return(std::vector{"destination"})); - Protobuf::Map context_extensions; + Protobuf::Map context_extensions; context_extensions["key"] = "value"; CheckRequestUtils::createHttpCheck(&callbacks_, request_headers, std::move(context_extensions), diff --git a/test/extensions/filters/common/rbac/matchers_test.cc b/test/extensions/filters/common/rbac/matchers_test.cc index 52a51edb237df..65e182a99be6b 100644 --- a/test/extensions/filters/common/rbac/matchers_test.cc +++ b/test/extensions/filters/common/rbac/matchers_test.cc @@ -249,9 +249,9 @@ TEST(MetadataMatcher, MetadataMatcher) { auto label = MessageUtil::keyValueStruct("label", "prod"); envoy::api::v2::core::Metadata metadata; metadata.mutable_filter_metadata()->insert( - Protobuf::MapPair("other", label)); + Protobuf::MapPair("other", label)); metadata.mutable_filter_metadata()->insert( - Protobuf::MapPair("rbac", label)); + Protobuf::MapPair("rbac", label)); envoy::type::matcher::MetadataMatcher matcher; matcher.set_filter("rbac"); diff --git a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc index e548a9ea3c637..a3332e8c3c8e2 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc @@ -97,7 +97,7 @@ class GrpcJsonTranscoderConfigTest : public testing::Test, public GrpcJsonTransc } } - void stripImports(FileDescriptorSet& descriptor_set, const ProtobufTypes::String& file_name) { + void stripImports(FileDescriptorSet& descriptor_set, const std::string& file_name) { FileDescriptorProto file_descriptor; // filter down descriptor_set to only contain one proto specified as file_name but none of its // dependencies @@ -107,7 +107,7 @@ class GrpcJsonTranscoderConfigTest : public testing::Test, public GrpcJsonTransc // return whether file.name() ends with file_name return file.name().length() >= file_name.length() && 0 == file.name().compare(file.name().length() - file_name.length(), - ProtobufTypes::String::npos, file_name); + std::string::npos, file_name); }); RELEASE_ASSERT(file_itr != descriptor_set.file().end(), ""); file_descriptor = *file_itr; diff --git a/test/extensions/filters/http/lua/lua_integration_test.cc b/test/extensions/filters/http/lua/lua_integration_test.cc index 8e72a0aef4f6f..1f6e2e801a8df 100644 --- a/test/extensions/filters/http/lua/lua_integration_test.cc +++ b/test/extensions/filters/http/lua/lua_integration_test.cc @@ -64,8 +64,7 @@ class LuaIntegrationTest : public testing::TestWithParammutable_routes(0) ->mutable_metadata() ->mutable_filter_metadata() - ->insert( - Protobuf::MapPair(key, value)); + ->insert(Protobuf::MapPair(key, value)); }); initialize(); diff --git a/test/extensions/filters/http/rbac/rbac_filter_test.cc b/test/extensions/filters/http/rbac/rbac_filter_test.cc index bdeb72975287d..2313b8f9e0b8b 100644 --- a/test/extensions/filters/http/rbac/rbac_filter_test.cc +++ b/test/extensions/filters/http/rbac/rbac_filter_test.cc @@ -67,8 +67,8 @@ class RoleBasedAccessControlFilterTest : public testing::Test { ON_CALL(req_info_, setDynamicMetadata(HttpFilterNames::get().Rbac, _)) .WillByDefault(Invoke([this](const std::string&, const ProtobufWkt::Struct& obj) { req_info_.metadata_.mutable_filter_metadata()->insert( - Protobuf::MapPair( - HttpFilterNames::get().Rbac, obj)); + Protobuf::MapPair(HttpFilterNames::get().Rbac, + obj)); })); } diff --git a/test/extensions/filters/network/rbac/filter_test.cc b/test/extensions/filters/network/rbac/filter_test.cc index feb084d5714c6..53ffe7d139486 100644 --- a/test/extensions/filters/network/rbac/filter_test.cc +++ b/test/extensions/filters/network/rbac/filter_test.cc @@ -72,8 +72,8 @@ class RoleBasedAccessControlNetworkFilterTest : public testing::Test { ON_CALL(stream_info_, setDynamicMetadata(NetworkFilterNames::get().Rbac, _)) .WillByDefault(Invoke([this](const std::string&, const ProtobufWkt::Struct& obj) { stream_info_.metadata_.mutable_filter_metadata()->insert( - Protobuf::MapPair( - NetworkFilterNames::get().Rbac, obj)); + Protobuf::MapPair(NetworkFilterNames::get().Rbac, + obj)); })); } diff --git a/test/extensions/stats_sinks/statsd/config_test.cc b/test/extensions/stats_sinks/statsd/config_test.cc index 761be8570e46b..b739810f2c5f8 100644 --- a/test/extensions/stats_sinks/statsd/config_test.cc +++ b/test/extensions/stats_sinks/statsd/config_test.cc @@ -143,7 +143,7 @@ TEST(StatsConfigTest, TcpSinkCustomPrefix) { const std::string name = StatsSinkNames::get().Statsd; envoy::config::metrics::v2::StatsdSink sink_config; - ProtobufTypes::String prefix = "prefixTest"; + std::string prefix = "prefixTest"; sink_config.set_tcp_cluster_name("fake_cluster"); ASSERT_NE(sink_config.prefix(), prefix); sink_config.set_prefix(prefix); diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index 2fe7db220c2e3..9b3ae1f749373 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -159,9 +159,7 @@ TEST_F(OptionsImplTest, SetAll) { EXPECT_EQ(envoy::admin::v2alpha::CommandLineOptions::v6, command_line_options->local_address_ip_version()); EXPECT_EQ(options->drainTime().count(), command_line_options->drain_time().seconds()); - // The right hand side char* will be converted into fmt::string_view and then compare. - EXPECT_EQ(spdlog::level::to_string_view(options->logLevel()), - command_line_options->log_level().data()); + EXPECT_EQ(spdlog::level::to_string_view(options->logLevel()), command_line_options->log_level()); EXPECT_EQ(options->logFormat(), command_line_options->log_format()); EXPECT_EQ(options->logPath(), command_line_options->log_path()); EXPECT_EQ(options->parentShutdownTime().count(), diff --git a/tools/check_format.py b/tools/check_format.py index 98bb0fe6e2298..4d53d5e8f4acd 100755 --- a/tools/check_format.py +++ b/tools/check_format.py @@ -70,9 +70,6 @@ "Protobuf::Struct": "ProtobufWkt::Struct", "Protobuf::Value": "ProtobufWkt::Value", - # Maps including strings should use the protobuf string types. - "Protobuf::MapPair