Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/envoy/upstream/locality.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ProtobufTypes::String&, const ProtobufTypes::String&,
const ProtobufTypes::String&>;
using LocalityTuple = std::tuple<const std::string&, const std::string&, const std::string&>;
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;
Expand Down
4 changes: 2 additions & 2 deletions source/common/access_log/access_log_formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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()) {
Expand Down
7 changes: 3 additions & 4 deletions source/common/config/http_subscription_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ void HttpSubscriptionImpl::start(const std::set<std::string>& resources,
init_fetch_timeout_timer_->enableTimer(init_fetch_timeout_);
}

Protobuf::RepeatedPtrField<ProtobufTypes::String> resources_vector(resources.begin(),
resources.end());
Protobuf::RepeatedPtrField<std::string> resources_vector(resources.begin(), resources.end());
request_.mutable_resource_names()->Swap(&resources_vector);
callbacks_ = &callbacks;
initialize();
}

void HttpSubscriptionImpl::updateResources(const std::set<std::string>& update_to_these_names) {
Protobuf::RepeatedPtrField<ProtobufTypes::String> resources_vector(update_to_these_names.begin(),
update_to_these_names.end());
Protobuf::RepeatedPtrField<std::string> resources_vector(update_to_these_names.begin(),
update_to_these_names.end());
request_.mutable_resource_names()->Swap(&resources_vector);
}

Expand Down
2 changes: 1 addition & 1 deletion source/common/config/http_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class HttpSubscriptionImpl : public Http::RestApiFetcher,
void disableInitFetchTimeoutTimer();

std::string path_;
Protobuf::RepeatedPtrField<ProtobufTypes::String> resources_;
Protobuf::RepeatedPtrField<std::string> resources_;
Config::SubscriptionCallbacks* callbacks_{};
envoy::api::v2::DiscoveryRequest request_;
SubscriptionStats stats_;
Expand Down
2 changes: 1 addition & 1 deletion source/common/config/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class Factory> static Factory& getAndCheckFactory(const ProtobufTypes::String& name) {
template <class Factory> static Factory& getAndCheckFactory(const std::string& name) {
if (name.empty()) {
throw EnvoyException("Provided name for static registration lookup was empty.");
}
Expand Down
6 changes: 2 additions & 4 deletions source/common/protobuf/protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Protobuf::Message> MessagePtr;

typedef std::string String;
typedef int64_t Int64;

} // namespace ProtobufTypes
Expand Down
4 changes: 2 additions & 2 deletions source/common/protobuf/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(), "");
Expand All @@ -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: {} {}",
Expand Down
6 changes: 3 additions & 3 deletions source/common/protobuf/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MissingFieldException : public EnvoyException {

class RepeatedPtrUtil {
public:
static std::string join(const Protobuf::RepeatedPtrField<ProtobufTypes::String>& source,
static std::string join(const Protobuf::RepeatedPtrField<std::string>& source,
const std::string& delimiter) {
return StringUtil::join(std::vector<std::string>(source.begin(), source.end()), delimiter);
}
Expand All @@ -126,7 +126,7 @@ class RepeatedPtrUtil {
static std::size_t hash(const Protobuf::RepeatedPtrField<ProtoType>& 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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions source/common/router/config_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,8 @@ createRouteSpecificFilterConfig(const std::string& name, const ProtobufWkt::Any&
} // namespace

PerFilterConfigs::PerFilterConfigs(
const Protobuf::Map<ProtobufTypes::String, ProtobufWkt::Any>& typed_configs,
const Protobuf::Map<ProtobufTypes::String, ProtobufWkt::Struct>& configs,
const Protobuf::Map<std::string, ProtobufWkt::Any>& typed_configs,
const Protobuf::Map<std::string, ProtobufWkt::Struct>& configs,
Server::Configuration::FactoryContext& factory_context) {
if (!typed_configs.empty() && !configs.empty()) {
throw EnvoyException("Only one of typed_configs or configs can be specified");
Expand Down
4 changes: 2 additions & 2 deletions source/common/router/config_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class Matchable {

class PerFilterConfigs {
public:
PerFilterConfigs(const Protobuf::Map<ProtobufTypes::String, ProtobufWkt::Any>& typed_configs,
const Protobuf::Map<ProtobufTypes::String, ProtobufWkt::Struct>& configs,
PerFilterConfigs(const Protobuf::Map<std::string, ProtobufWkt::Any>& typed_configs,
const Protobuf::Map<std::string, ProtobufWkt::Struct>& configs,
Server::Configuration::FactoryContext& factory_context);

const RouteSpecificFilterConfig* get(const std::string& name) const;
Expand Down
2 changes: 1 addition & 1 deletion source/common/router/header_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ HeaderParserPtr HeaderParser::configure(

HeaderParserPtr HeaderParser::configure(
const Protobuf::RepeatedPtrField<envoy::api::v2::core::HeaderValueOption>& headers_to_add,
const Protobuf::RepeatedPtrField<ProtobufTypes::String>& headers_to_remove) {
const Protobuf::RepeatedPtrField<std::string>& headers_to_remove) {
HeaderParserPtr header_parser = configure(headers_to_add);

for (const auto& header : headers_to_remove) {
Expand Down
2 changes: 1 addition & 1 deletion source/common/router/header_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class HeaderParser {
*/
static HeaderParserPtr configure(
const Protobuf::RepeatedPtrField<envoy::api::v2::core::HeaderValueOption>& headers_to_add,
const Protobuf::RepeatedPtrField<ProtobufTypes::String>& headers_to_remove);
const Protobuf::RepeatedPtrField<std::string>& headers_to_remove);

void evaluateHeaders(Http::HeaderMap& headers, const StreamInfo::StreamInfo& stream_info) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())});
}
}
}
Expand All @@ -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())});
}
}
}
Expand All @@ -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())});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Envoy::ProtobufTypes::String, Envoy::ProtobufTypes::String>*
mutable_headers =
static_cast<Envoy::Protobuf::Map<Envoy::ProtobufTypes::String,
Envoy::ProtobufTypes::String>*>(ctx);
Envoy::Protobuf::Map<std::string, std::string>* mutable_headers =
static_cast<Envoy::Protobuf::Map<std::string, std::string>*>(ctx);
(*mutable_headers)[std::string(e.key().getStringView())] =
std::string(e.value().getStringView());
}
Expand Down Expand Up @@ -144,7 +142,7 @@ void CheckRequestUtils::setAttrContextRequest(
void CheckRequestUtils::createHttpCheck(
const Envoy::Http::StreamDecoderFilterCallbacks* callbacks,
const Envoy::Http::HeaderMap& headers,
Protobuf::Map<ProtobufTypes::String, ProtobufTypes::String>&& context_extensions,
Protobuf::Map<std::string, std::string>&& context_extensions,
envoy::service::auth::v2::CheckRequest& request, uint64_t max_request_bytes) {

auto attrs = request.mutable_attributes();
Expand Down
10 changes: 5 additions & 5 deletions source/extensions/filters/common/ext_authz/check_request_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProtobufTypes::String, ProtobufTypes::String>&& 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<std::string, std::string>&& 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
Expand Down
5 changes: 2 additions & 3 deletions source/extensions/filters/common/lua/wrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ void MetadataMapHelper::setValue(lua_State* state, const ProtobufWkt::Value& val
}
}

void MetadataMapHelper::createTable(
lua_State* state,
const Protobuf::Map<Envoy::ProtobufTypes::String, ProtobufWkt::Value>& fields) {
void MetadataMapHelper::createTable(lua_State* state,
const Protobuf::Map<std::string, ProtobufWkt::Value>& fields) {
lua_createtable(state, 0, fields.size());
for (const auto& field : fields) {
int top = lua_gettop(state);
Expand Down
7 changes: 3 additions & 4 deletions source/extensions/filters/common/lua/wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Envoy::ProtobufTypes::String, ProtobufWkt::Value>& fields);
static void createTable(lua_State* state,
const Protobuf::Map<std::string, ProtobufWkt::Value>& fields);
};

/**
Expand All @@ -62,7 +61,7 @@ class MetadataMapIterator : public BaseLuaObject<MetadataMapIterator> {

private:
MetadataMapWrapper& parent_;
Protobuf::Map<Envoy::ProtobufTypes::String, ProtobufWkt::Value>::const_iterator current_;
Protobuf::Map<std::string, ProtobufWkt::Value>::const_iterator current_;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/http/ext_authz/ext_authz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Filter::initiateCall(const Http::HeaderMap& headers) {
cfg_base.merge(cfg);
});

Protobuf::Map<ProtobufTypes::String, ProtobufTypes::String> context_extensions;
Protobuf::Map<std::string, std::string> context_extensions;
if (maybe_merged_per_route_config) {
context_extensions = maybe_merged_per_route_config.value().takeContextExtensions();
}
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/http/ext_authz/ext_authz.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ typedef std::shared_ptr<FilterConfig> FilterConfigSharedPtr;
*/
class FilterConfigPerRoute : public Router::RouteSpecificFilterConfig {
public:
using ContextExtensionsMap = Protobuf::Map<ProtobufTypes::String, ProtobufTypes::String>;
using ContextExtensionsMap = Protobuf::Map<std::string, std::string>;

FilterConfigPerRoute(const envoy::config::filter::http::ext_authz::v2::ExtAuthzPerRoute& config)
: context_extensions_(config.has_check_settings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ JsonTranscoderConfig::JsonTranscoderConfig(
}

PathMatcherBuilder<const Protobuf::MethodDescriptor*> pmb;
std::unordered_set<ProtobufTypes::String> ignored_query_parameters;
std::unordered_set<std::string> ignored_query_parameters;
for (const auto& query_param : proto_config.ignored_query_parameters()) {
ignored_query_parameters.insert(query_param);
}
Expand Down Expand Up @@ -175,9 +175,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) {
Expand Down Expand Up @@ -483,9 +483,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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProtobufTypes::String> field_path;
std::vector<std::string> field_path;
// The value to be inserted.
ProtobufTypes::String value;
std::string value;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions source/extensions/filters/http/gzip/gzip_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ Compressor::ZlibCompressorImpl::CompressionStrategy GzipFilterConfig::compressio
}
}

StringUtil::CaseUnorderedSet GzipFilterConfig::contentTypeSet(
const Protobuf::RepeatedPtrField<Envoy::ProtobufTypes::String>& types) {
StringUtil::CaseUnorderedSet
GzipFilterConfig::contentTypeSet(const Protobuf::RepeatedPtrField<std::string>& types) {
return types.empty() ? StringUtil::CaseUnorderedSet(defaultContentEncoding().begin(),
defaultContentEncoding().end())
: StringUtil::CaseUnorderedSet(types.cbegin(), types.cend());
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/http/gzip/gzip_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Envoy::ProtobufTypes::String>& types);
contentTypeSet(const Protobuf::RepeatedPtrField<std::string>& types);

static uint64_t contentLengthUint(Protobuf::uint32 length);
static uint64_t memoryLevelUint(Protobuf::uint32 level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading