From 61d0fddf201f7d9a1bcaf6d6255b4e090af19f94 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 10 Mar 2021 17:19:12 +0000 Subject: [PATCH 01/15] matching: add support for generic input, add environment input Signed-off-by: Snow Pettersen --- api/BUILD | 1 + .../generic_inputs/environment/v3/BUILD | 9 +++++ .../environment/v3/environment.proto | 22 +++++++++++ api/versioning/BUILD | 1 + bazel/envoy_library.bzl | 1 + .../common_messages/common_messages.rst | 1 + generated_api_shadow/BUILD | 1 + .../generic_inputs/environment/v3/BUILD | 9 +++++ .../environment/v3/environment.proto | 22 +++++++++++ include/envoy/matcher/matcher.h | 22 ++++++++++- source/common/matcher/matcher.h | 36 +++++++++++++++-- source/extensions/extensions_build_config.bzl | 6 +++ .../matching/generic_inputs/environment/BUILD | 34 ++++++++++++++++ .../generic_inputs/environment/config.cc | 30 ++++++++++++++ .../generic_inputs/environment/config.h | 35 +++++++++++++++++ .../generic_inputs/environment/input.h | 31 +++++++++++++++ test/common/matcher/matcher_test.cc | 35 +++++++++++++++++ test/common/matcher/test_utility.h | 30 +++++++++++++- .../matching/generic_inputs/environment/BUILD | 31 +++++++++++++++ .../generic_inputs/environment/config_test.cc | 39 +++++++++++++++++++ .../generic_inputs/environment/input_test.cc | 27 +++++++++++++ 21 files changed, 417 insertions(+), 6 deletions(-) create mode 100644 api/envoy/extensions/matching/generic_inputs/environment/v3/BUILD create mode 100644 api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto create mode 100644 generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/BUILD create mode 100644 generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto create mode 100644 source/extensions/matching/generic_inputs/environment/BUILD create mode 100644 source/extensions/matching/generic_inputs/environment/config.cc create mode 100644 source/extensions/matching/generic_inputs/environment/config.h create mode 100644 source/extensions/matching/generic_inputs/environment/input.h create mode 100644 test/extensions/matching/generic_inputs/environment/BUILD create mode 100644 test/extensions/matching/generic_inputs/environment/config_test.cc create mode 100644 test/extensions/matching/generic_inputs/environment/input_test.cc diff --git a/api/BUILD b/api/BUILD index e1ec17a81b94..383d2e5678f2 100644 --- a/api/BUILD +++ b/api/BUILD @@ -243,6 +243,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", + "//envoy/extensions/matching/generic_inputs/environment/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/api/envoy/extensions/matching/generic_inputs/environment/v3/BUILD b/api/envoy/extensions/matching/generic_inputs/environment/v3/BUILD new file mode 100644 index 000000000000..ee92fb652582 --- /dev/null +++ b/api/envoy/extensions/matching/generic_inputs/environment/v3/BUILD @@ -0,0 +1,9 @@ +# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. + +load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") + +licenses(["notice"]) # Apache 2 + +api_proto_package( + deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"], +) diff --git a/api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto b/api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto new file mode 100644 index 000000000000..85ead0f5693e --- /dev/null +++ b/api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package envoy.extensions.matching.generic_inputs.environment.v3; + +import "udpa/annotations/migrate.proto"; +import "udpa/annotations/status.proto"; +import "udpa/annotations/versioning.proto"; +import "validate/validate.proto"; + +option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment.v3"; +option java_outer_classname = "EnvironmentProto"; +option java_multiple_files = true; +option (udpa.annotations.file_status).package_version_status = ACTIVE; + +// [#protodoc-title: Environment Input] +// [#extension: envoy.matching.generic_inputs.environment] + +// Reads an environment variable to provide an input for matching. +message Environment { + // Name of the environment variable to read from. + string name = 1 [(validate.rules).string = {min_len: 1}]; +} diff --git a/api/versioning/BUILD b/api/versioning/BUILD index 7043b99a0faf..478f44282443 100644 --- a/api/versioning/BUILD +++ b/api/versioning/BUILD @@ -126,6 +126,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", + "//envoy/extensions/matching/generic_inputs/environment/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 75eb02258235..766051875663 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -82,6 +82,7 @@ EXTENSION_CATEGORIES = [ "envoy.health_checkers", "envoy.internal_redirect_predicates", "envoy.io_socket", + "envoy.matching.generic_inputs", "envoy.matching.input_matchers", "envoy.rate_limit_descriptors", "envoy.request_id", diff --git a/docs/root/api-v3/common_messages/common_messages.rst b/docs/root/api-v3/common_messages/common_messages.rst index d130b1c74585..10250637b835 100644 --- a/docs/root/api-v3/common_messages/common_messages.rst +++ b/docs/root/api-v3/common_messages/common_messages.rst @@ -25,3 +25,4 @@ Common messages ../extensions/filters/common/dependency/v3/dependency.proto ../extensions/filters/common/matcher/action/v3/skip_action.proto ../extensions/matching/input_matchers/consistent_hashing/v3/consistent_hashing.proto + ../extensions/matching/generic_inputs/environment/v3/environment.proto diff --git a/generated_api_shadow/BUILD b/generated_api_shadow/BUILD index e1ec17a81b94..383d2e5678f2 100644 --- a/generated_api_shadow/BUILD +++ b/generated_api_shadow/BUILD @@ -243,6 +243,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", + "//envoy/extensions/matching/generic_inputs/environment/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/BUILD b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/BUILD new file mode 100644 index 000000000000..ee92fb652582 --- /dev/null +++ b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/BUILD @@ -0,0 +1,9 @@ +# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. + +load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") + +licenses(["notice"]) # Apache 2 + +api_proto_package( + deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"], +) diff --git a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto new file mode 100644 index 000000000000..85ead0f5693e --- /dev/null +++ b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package envoy.extensions.matching.generic_inputs.environment.v3; + +import "udpa/annotations/migrate.proto"; +import "udpa/annotations/status.proto"; +import "udpa/annotations/versioning.proto"; +import "validate/validate.proto"; + +option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment.v3"; +option java_outer_classname = "EnvironmentProto"; +option java_multiple_files = true; +option (udpa.annotations.file_status).package_version_status = ACTIVE; + +// [#protodoc-title: Environment Input] +// [#extension: envoy.matching.generic_inputs.environment] + +// Reads an environment variable to provide an input for matching. +message Environment { + // Name of the environment variable to read from. + string name = 1 [(validate.rules).string = {min_len: 1}]; +} diff --git a/include/envoy/matcher/matcher.h b/include/envoy/matcher/matcher.h index 4c65305f5416..b7b7f9213361 100644 --- a/include/envoy/matcher/matcher.h +++ b/include/envoy/matcher/matcher.h @@ -201,7 +201,8 @@ struct DataInputGetResult { }; /** - * Interface for types providing a way to extract a string from the DataType to perform matching on. + * Interface for types providing a way to extract a string from the DataType to perform matching + * on. */ template class DataInput { public: @@ -236,5 +237,24 @@ template class DataInputFactory : public Config::TypedFactory { } }; +class GenericDataInput { +public: + virtual ~GenericDataInput() = default; + virtual absl::optional get() PURE; +}; +using GenericDataInputPtr = std::unique_ptr; + +class GenericDataInputFactory : public Config::TypedFactory { +public: + /** + * Creates a GenericDataInput from the provided config. + */ + virtual GenericDataInputPtr + createGenericDataInput(const Protobuf::Message& config, + Server::Configuration::FactoryContext& factory_context) PURE; + + std::string category() const override { return "envoy.matching.generic_inputs"; } +}; + } // namespace Matcher } // namespace Envoy \ No newline at end of file diff --git a/source/common/matcher/matcher.h b/source/common/matcher/matcher.h index 400da9d5386c..f9cedaec1af4 100644 --- a/source/common/matcher/matcher.h +++ b/source/common/matcher/matcher.h @@ -155,12 +155,40 @@ template class MatchTreeFactory { return absl::nullopt; } + // Wrapper around a GenericDataInput that allows it to be used as a DataInput. + class GenericDataInputWrapper : public DataInput { + public: + explicit GenericDataInputWrapper(GenericDataInputPtr&& generic_data_input) + : generic_data_input_(std::move(generic_data_input)) {} + + DataInputGetResult get(const DataType&) override { + return DataInputGetResult{DataInputGetResult::DataAvailability::AllDataAvailable, + generic_data_input_->get()}; + } + + private: + const GenericDataInputPtr generic_data_input_; + }; + DataInputPtr createDataInput(const envoy::config::core::v3::TypedExtensionConfig& config) { - auto& factory = Config::Utility::getAndCheckFactory>(config); - ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - config.typed_config(), factory_context_.messageValidationVisitor(), factory); - return factory.createDataInput(*message, factory_context_); + auto* factory = Config::Utility::getFactory>(config); + if (factory != nullptr) { + ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( + config.typed_config(), factory_context_.messageValidationVisitor(), *factory); + return factory->createDataInput(*message, factory_context_); + } + + auto* generic_factory = Config::Utility::getFactory(config); + if (generic_factory != nullptr) { + ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( + config.typed_config(), factory_context_.messageValidationVisitor(), *generic_factory); + return std::make_unique( + generic_factory->createGenericDataInput(*message, factory_context_)); + } + + throw EnvoyException( + fmt::format("Didn't find a registered implementation for name: '{}'", config.name())); } InputMatcherPtr createInputMatcher( diff --git a/source/extensions/extensions_build_config.bzl b/source/extensions/extensions_build_config.bzl index f0de0c7b7273..1e0e20ed0162 100644 --- a/source/extensions/extensions_build_config.bzl +++ b/source/extensions/extensions_build_config.bzl @@ -50,6 +50,12 @@ EXTENSIONS = { "envoy.matching.input_matchers.consistent_hashing": "//source/extensions/matching/input_matchers/consistent_hashing:config", + # + # Generic Inputs + # + + "envoy.matching.generic_inputs.environment": "//source/extensions/matching/generic_inputs/environment:config", + # # HTTP filters # diff --git a/source/extensions/matching/generic_inputs/environment/BUILD b/source/extensions/matching/generic_inputs/environment/BUILD new file mode 100644 index 000000000000..7a0104f85ce7 --- /dev/null +++ b/source/extensions/matching/generic_inputs/environment/BUILD @@ -0,0 +1,34 @@ +load( + "//bazel:envoy_build_system.bzl", + "envoy_cc_extension", + "envoy_cc_library", + "envoy_extension_package", +) + +licenses(["notice"]) # Apache 2 + +envoy_extension_package() + +envoy_cc_library( + name = "input_lib", + hdrs = ["input.h"], + deps = [ + "//include/envoy/matcher:matcher_interface", + "//source/common/common:hash_lib", + ], +) + +envoy_cc_extension( + name = "config", + srcs = ["config.cc"], + hdrs = ["config.h"], + category = "envoy.matching.generic_inputs", + security_posture = "robust_to_untrusted_downstream", + deps = [ + ":input_lib", + "//include/envoy/matcher:matcher_interface", + "//include/envoy/registry", + "//include/envoy/server:factory_context_interface", + "@envoy_api//envoy/extensions/matching/generic_inputs/environment/v3:pkg_cc_proto", + ], +) diff --git a/source/extensions/matching/generic_inputs/environment/config.cc b/source/extensions/matching/generic_inputs/environment/config.cc new file mode 100644 index 000000000000..8d8df3ec7dff --- /dev/null +++ b/source/extensions/matching/generic_inputs/environment/config.cc @@ -0,0 +1,30 @@ +#include "extensions/matching/generic_inputs/environment/config.h" + +#include "envoy/matcher/matcher.h" + +namespace Envoy { +namespace Extensions { +namespace Matching { +namespace GenericInputs { +namespace Environment { + +Envoy::Matcher::GenericDataInputPtr +Config::createGenericDataInput(const Protobuf::Message& config, + Server::Configuration::FactoryContext& factory_context) { + const auto& environment_config = MessageUtil::downcastAndValidate< + const envoy::extensions::matching::generic_inputs::environment::v3::Environment&>( + config, factory_context.messageValidationVisitor()); + + return std::make_unique(environment_config.name()); +} + +/** + * Static registration for the environment data input. @see RegisterFactory. + */ +REGISTER_FACTORY(Config, Envoy::Matcher::GenericDataInputFactory); + +} // namespace Environment +} // namespace GenericInputs +} // namespace Matching +} // namespace Extensions +} // namespace Envoy \ No newline at end of file diff --git a/source/extensions/matching/generic_inputs/environment/config.h b/source/extensions/matching/generic_inputs/environment/config.h new file mode 100644 index 000000000000..d8a609259600 --- /dev/null +++ b/source/extensions/matching/generic_inputs/environment/config.h @@ -0,0 +1,35 @@ +#pragma once + +#include "envoy/extensions/matching/generic_inputs/environment/v3/environment.pb.h" +#include "envoy/extensions/matching/generic_inputs/environment/v3/environment.pb.validate.h" +#include "envoy/matcher/matcher.h" +#include "envoy/server/factory_context.h" + +#include "common/protobuf/utility.h" + +#include "extensions/matching/generic_inputs/environment/input.h" + +namespace Envoy { +namespace Extensions { +namespace Matching { +namespace GenericInputs { +namespace Environment { + +class Config : public Envoy::Matcher::GenericDataInputFactory { +public: + Envoy::Matcher::GenericDataInputPtr + createGenericDataInput(const Protobuf::Message& config, + Server::Configuration::FactoryContext& factory_context) override; + + std::string name() const override { return "envoy.matching.generic_inputs.environment"; } + + ProtobufTypes::MessagePtr createEmptyConfigProto() override { + return std::make_unique< + envoy::extensions::matching::generic_inputs::environment::v3::Environment>(); + } +}; +} // namespace Environment +} // namespace GenericInputs +} // namespace Matching +} // namespace Extensions +} // namespace Envoy \ No newline at end of file diff --git a/source/extensions/matching/generic_inputs/environment/input.h b/source/extensions/matching/generic_inputs/environment/input.h new file mode 100644 index 000000000000..f95422246ece --- /dev/null +++ b/source/extensions/matching/generic_inputs/environment/input.h @@ -0,0 +1,31 @@ +#pragma once + +#include "envoy/matcher/matcher.h" + +namespace Envoy { +namespace Extensions { +namespace Matching { +namespace GenericInputs { +namespace Environment { + +class Input : public Envoy::Matcher::GenericDataInput { +public: + explicit Input(absl::string_view name) { + // We read the env variable at construction time to avoid repeat lookups. + // This assumes that the environment remains stable during the process lifetime. + auto* value = getenv(name.data()); + if (value != nullptr) { + storage_ = std::string(value); + } + } + + absl::optional get() override { return storage_; } + +private: + absl::optional storage_; +}; +} // namespace Environment +} // namespace GenericInputs +} // namespace Matching +} // namespace Extensions +} // namespace Envoy \ No newline at end of file diff --git a/test/common/matcher/matcher_test.cc b/test/common/matcher/matcher_test.cc index aa08a54812de..f5441864141e 100644 --- a/test/common/matcher/matcher_test.cc +++ b/test/common/matcher/matcher_test.cc @@ -75,6 +75,41 @@ TEST_F(MatcherTest, TestMatcher) { EXPECT_NE(result.on_match_->action_cb_, nullptr); } +TEST_F(MatcherTest, CustomGenericInput) { + const std::string yaml = R"EOF( +matcher_list: + matchers: + - on_match: + action: + name: test_action + typed_config: + "@type": type.googleapis.com/google.protobuf.StringValue + value: match!! + predicate: + single_predicate: + input: + name: generic + typed_config: + "@type": type.googleapis.com/google.protobuf.StringValue + value_match: + exact: foo + + )EOF"; + envoy::config::common::matcher::v3::Matcher matcher; + MessageUtil::loadFromYaml(yaml, matcher, ProtobufMessage::getStrictValidationVisitor()); + + TestUtility::validate(matcher); + MatchTreeFactory factory(factory_context_); + + auto generic_factory = TestGenericDataInputFactory("generic", "foo"); + auto match_tree = factory.create(matcher); + + const auto result = match_tree->match(TestData()); + EXPECT_EQ(result.match_state_, MatchState::MatchComplete); + EXPECT_TRUE(result.on_match_.has_value()); + EXPECT_NE(result.on_match_->action_cb_, nullptr); +} + TEST_F(MatcherTest, CustomMatcher) { const std::string yaml = R"EOF( matcher_list: diff --git a/test/common/matcher/test_utility.h b/test/common/matcher/test_utility.h index e919ce7ed0f2..64ad1f5f3631 100644 --- a/test/common/matcher/test_utility.h +++ b/test/common/matcher/test_utility.h @@ -16,6 +16,34 @@ struct TestData { static absl::string_view name() { return "test"; } }; +// A DataInput that returns the configured value every time. +struct GenericTestInput : public GenericDataInput { + explicit GenericTestInput(const std::string& data) : data_(data) {} + absl::optional get() override { return data_; } + + const std::string data_; +}; +class TestGenericDataInputFactory : public GenericDataInputFactory { +public: + TestGenericDataInputFactory(absl::string_view factory_name, absl::string_view data) + : factory_name_(std::string(factory_name)), value_(std::string(data)), injection_(*this) {} + + GenericDataInputPtr createGenericDataInput(const Protobuf::Message&, + Server::Configuration::FactoryContext&) override { + return std::make_unique(value_); + } + + ProtobufTypes::MessagePtr createEmptyConfigProto() override { + return std::make_unique(); + } + std::string name() const override { return factory_name_; } + +private: + const std::string factory_name_; + const std::string value_; + Registry::InjectFactory injection_; +}; + // A DataInput that returns the configured value every time. struct TestInput : public DataInput { explicit TestInput(DataInputGetResult result) : result_(result) {} @@ -144,4 +172,4 @@ template OnMatch stringOnMatch(absl::string_view value) { } } // namespace Matcher -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/test/extensions/matching/generic_inputs/environment/BUILD b/test/extensions/matching/generic_inputs/environment/BUILD new file mode 100644 index 000000000000..894aec954c9c --- /dev/null +++ b/test/extensions/matching/generic_inputs/environment/BUILD @@ -0,0 +1,31 @@ +load( + "//bazel:envoy_build_system.bzl", + "envoy_package", +) +load( + "//test/extensions:extensions_build_system.bzl", + "envoy_extension_cc_test", +) + +licenses(["notice"]) # Apache 2 + +envoy_package() + +envoy_extension_cc_test( + name = "config_test", + srcs = ["config_test.cc"], + extension_name = "envoy.matching.generic_inputs.environment", + deps = [ + "//source/extensions/matching/generic_inputs/environment:config", + "//test/mocks/server:factory_context_mocks", + ], +) + +envoy_extension_cc_test( + name = "input_test", + srcs = ["input_test.cc"], + extension_name = "envoy.matching.generic_inputs.environment", + deps = [ + "//source/extensions/matching/generic_inputs/environment:input_lib", + ], +) diff --git a/test/extensions/matching/generic_inputs/environment/config_test.cc b/test/extensions/matching/generic_inputs/environment/config_test.cc new file mode 100644 index 000000000000..b658d7291c0d --- /dev/null +++ b/test/extensions/matching/generic_inputs/environment/config_test.cc @@ -0,0 +1,39 @@ +#include "common/config/utility.h" + +#include "extensions/matching/generic_inputs/environment/config.h" + +#include "test/mocks/server/factory_context.h" + +#include "gtest/gtest.h" + +namespace Envoy { +namespace Extensions { +namespace Matching { +namespace GenericInputs { +namespace Environment { + +TEST(ConfigTest, TestConfig) { + NiceMock context; + + const std::string yaml_string = R"EOF( + name: hashing + typed_config: + "@type": type.googleapis.com/envoy.extensions.matching.generic_inputs.environment.v3.Environment + name: foo +)EOF"; + + envoy::config::core::v3::TypedExtensionConfig config; + TestUtility::loadFromYaml(yaml_string, config); + + Config factory; + auto message = Envoy::Config::Utility::translateAnyToFactoryConfig( + config.typed_config(), ProtobufMessage::getStrictValidationVisitor(), factory); + auto matcher = factory.createGenericDataInput(*message, context); + EXPECT_NE(nullptr, matcher); +} + +} // namespace Environment +} // namespace GenericInputs +} // namespace Matching +} // namespace Extensions +} // namespace Envoy \ No newline at end of file diff --git a/test/extensions/matching/generic_inputs/environment/input_test.cc b/test/extensions/matching/generic_inputs/environment/input_test.cc new file mode 100644 index 000000000000..5247709088ff --- /dev/null +++ b/test/extensions/matching/generic_inputs/environment/input_test.cc @@ -0,0 +1,27 @@ +#include "extensions/matching/generic_inputs/environment/input.h" + +#include "gtest/gtest.h" + +namespace Envoy { +namespace Extensions { +namespace Matching { +namespace GenericInputs { +namespace Environment { + +TEST(InputTest, BasicUsage) { + { + Input input("foo"); + EXPECT_FALSE(input.get().has_value()); + } + + setenv("foo", "bar", true); + Input input("foo"); + EXPECT_EQ("bar", input.get().value()); + + unsetenv("foo"); +} +} // namespace Environment +} // namespace GenericInputs +} // namespace Matching +} // namespace Extensions +} // namespace Envoy From 835cce7bbc6069120ea4f34e87b1abafb5a37478 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 10 Mar 2021 17:38:26 +0000 Subject: [PATCH 02/15] add reference to generic input Signed-off-by: Snow Pettersen --- api/envoy/config/common/matcher/v3/matcher.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/api/envoy/config/common/matcher/v3/matcher.proto b/api/envoy/config/common/matcher/v3/matcher.proto index aa49132ce990..175d36adefde 100644 --- a/api/envoy/config/common/matcher/v3/matcher.proto +++ b/api/envoy/config/common/matcher/v3/matcher.proto @@ -50,6 +50,7 @@ message Matcher { // Predicate for a single input field. message SinglePredicate { // Protocol-specific specification of input field to match on. + // [#extension-category: envoy.matching.generic_inputs] core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { From 3c8aefbf53b0a0ac8087c9765f4a518c2e6762ee Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 10 Mar 2021 17:39:27 +0000 Subject: [PATCH 03/15] add codeowners Signed-off-by: Snow Pettersen --- CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index e5dd0bcc16b1..67b42563c340 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -168,6 +168,8 @@ extensions/filters/http/oauth2 @rgs1 @derekargueta @snowp /*/extensions/rate_limit_descriptors/expr @kyessenov @lizan # hash input matcher /*/extensions/matching/input_matchers/consistent_hashing @snowp @donyu +# environment generic input +/*/extensions/matching/generic_inputs/environment @snowp @donyu # user space socket pair and event /*/extensions/io_socket/user_space @lambdai @antoniovicente # Default UUID4 request ID extension From bc4d426e7447dff240224c3c3aa178d8d0c1e42b Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 10 Mar 2021 17:42:41 +0000 Subject: [PATCH 04/15] fix lints Signed-off-by: Snow Pettersen --- api/envoy/config/common/matcher/v3/matcher.proto | 2 +- source/common/matcher/matcher.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/envoy/config/common/matcher/v3/matcher.proto b/api/envoy/config/common/matcher/v3/matcher.proto index 175d36adefde..25d74883ab80 100644 --- a/api/envoy/config/common/matcher/v3/matcher.proto +++ b/api/envoy/config/common/matcher/v3/matcher.proto @@ -50,7 +50,7 @@ message Matcher { // Predicate for a single input field. message SinglePredicate { // Protocol-specific specification of input field to match on. - // [#extension-category: envoy.matching.generic_inputs] + // [#extension-category: envoy.matching.generic_inputs] core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/source/common/matcher/matcher.h b/source/common/matcher/matcher.h index f9cedaec1af4..bac703faab61 100644 --- a/source/common/matcher/matcher.h +++ b/source/common/matcher/matcher.h @@ -187,7 +187,7 @@ template class MatchTreeFactory { generic_factory->createGenericDataInput(*message, factory_context_)); } - throw EnvoyException( + ExceptionUtil::throwEnvoyException( fmt::format("Didn't find a registered implementation for name: '{}'", config.name())); } From 6f0b84782ae5fbb917cc53cc97b8d60f6d3a9355 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 10 Mar 2021 17:45:39 +0000 Subject: [PATCH 05/15] update proto Signed-off-by: Snow Pettersen --- api/envoy/config/common/matcher/v4alpha/matcher.proto | 1 + .../envoy/config/common/matcher/v3/matcher.proto | 1 + .../envoy/config/common/matcher/v4alpha/matcher.proto | 1 + 3 files changed, 3 insertions(+) diff --git a/api/envoy/config/common/matcher/v4alpha/matcher.proto b/api/envoy/config/common/matcher/v4alpha/matcher.proto index 586a4a920154..be56a2e99c69 100644 --- a/api/envoy/config/common/matcher/v4alpha/matcher.proto +++ b/api/envoy/config/common/matcher/v4alpha/matcher.proto @@ -66,6 +66,7 @@ message Matcher { "envoy.config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate"; // Protocol-specific specification of input field to match on. + // [#extension-category: envoy.matching.generic_inputs] core.v4alpha.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto b/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto index aa49132ce990..25d74883ab80 100644 --- a/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto +++ b/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto @@ -50,6 +50,7 @@ message Matcher { // Predicate for a single input field. message SinglePredicate { // Protocol-specific specification of input field to match on. + // [#extension-category: envoy.matching.generic_inputs] core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto b/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto index 586a4a920154..be56a2e99c69 100644 --- a/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto +++ b/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto @@ -66,6 +66,7 @@ message Matcher { "envoy.config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate"; // Protocol-specific specification of input field to match on. + // [#extension-category: envoy.matching.generic_inputs] core.v4alpha.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { From f7baa1f8724e69f06291b41b1c94fa09a7ee0a01 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 10 Mar 2021 21:50:31 +0000 Subject: [PATCH 06/15] coverage Signed-off-by: Snow Pettersen --- source/common/matcher/matcher.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/source/common/matcher/matcher.h b/source/common/matcher/matcher.h index bac703faab61..6cea1e3da154 100644 --- a/source/common/matcher/matcher.h +++ b/source/common/matcher/matcher.h @@ -179,16 +179,12 @@ template class MatchTreeFactory { return factory->createDataInput(*message, factory_context_); } - auto* generic_factory = Config::Utility::getFactory(config); - if (generic_factory != nullptr) { - ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - config.typed_config(), factory_context_.messageValidationVisitor(), *generic_factory); - return std::make_unique( - generic_factory->createGenericDataInput(*message, factory_context_)); - } - - ExceptionUtil::throwEnvoyException( - fmt::format("Didn't find a registered implementation for name: '{}'", config.name())); + // If the provided config doesn't match a typed input, assume that this is a generic input. + auto& generic_factory = Config::Utility::getAndCheckFactory(config); + ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( + config.typed_config(), factory_context_.messageValidationVisitor(), generic_factory); + return std::make_unique( + generic_factory.createGenericDataInput(*message, factory_context_)); } InputMatcherPtr createInputMatcher( From 815a4fa3ce66a4247ab1498fecb079fce30587a1 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Thu, 11 Mar 2021 15:38:37 +0000 Subject: [PATCH 07/15] use env helper to deal with platform compatibility Signed-off-by: Snow Pettersen --- .../matching/generic_inputs/environment/input_test.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/extensions/matching/generic_inputs/environment/input_test.cc b/test/extensions/matching/generic_inputs/environment/input_test.cc index 5247709088ff..504f480fe5de 100644 --- a/test/extensions/matching/generic_inputs/environment/input_test.cc +++ b/test/extensions/matching/generic_inputs/environment/input_test.cc @@ -1,5 +1,6 @@ #include "extensions/matching/generic_inputs/environment/input.h" +#include "test/test_common/environment.h" #include "gtest/gtest.h" namespace Envoy { @@ -14,11 +15,11 @@ TEST(InputTest, BasicUsage) { EXPECT_FALSE(input.get().has_value()); } - setenv("foo", "bar", true); + TestEnvironment::setEnvVar("foo", "bar", 1); Input input("foo"); EXPECT_EQ("bar", input.get().value()); - unsetenv("foo"); + TestEnvironment::unsetEnvVar("foo"); } } // namespace Environment } // namespace GenericInputs From 045988e8d6bfa1ea9f40303c98b344cfd2190bd0 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Thu, 11 Mar 2021 15:39:53 +0000 Subject: [PATCH 08/15] format Signed-off-by: Snow Pettersen --- .../extensions/matching/generic_inputs/environment/input_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/extensions/matching/generic_inputs/environment/input_test.cc b/test/extensions/matching/generic_inputs/environment/input_test.cc index 504f480fe5de..3733dbc45dea 100644 --- a/test/extensions/matching/generic_inputs/environment/input_test.cc +++ b/test/extensions/matching/generic_inputs/environment/input_test.cc @@ -1,6 +1,7 @@ #include "extensions/matching/generic_inputs/environment/input.h" #include "test/test_common/environment.h" + #include "gtest/gtest.h" namespace Envoy { From 260fc8dccb9de4efbca76115ea56ad829e89a6d7 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Mon, 15 Mar 2021 16:36:53 +0000 Subject: [PATCH 09/15] read env in factory creation Signed-off-by: Snow Pettersen --- .../generic_inputs/environment/config.cc | 11 ++++++++++- .../generic_inputs/environment/input.h | 11 ++--------- .../generic_inputs/environment/config_test.cc | 18 ++++++++++++++++-- .../generic_inputs/environment/input_test.cc | 11 ++++------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/source/extensions/matching/generic_inputs/environment/config.cc b/source/extensions/matching/generic_inputs/environment/config.cc index 8d8df3ec7dff..6ca76b37d872 100644 --- a/source/extensions/matching/generic_inputs/environment/config.cc +++ b/source/extensions/matching/generic_inputs/environment/config.cc @@ -1,5 +1,7 @@ #include "extensions/matching/generic_inputs/environment/config.h" +#include + #include "envoy/matcher/matcher.h" namespace Envoy { @@ -15,7 +17,14 @@ Config::createGenericDataInput(const Protobuf::Message& config, const envoy::extensions::matching::generic_inputs::environment::v3::Environment&>( config, factory_context.messageValidationVisitor()); - return std::make_unique(environment_config.name()); + // We read the env variable at construction time to avoid repeat lookups. + // This assumes that the environment remains stable during the process lifetime. + auto* value = getenv(environment_config.name().data()); + if (value != nullptr) { + return std::make_unique(std::string(value)); + } + + return std::make_unique(absl::nullopt); } /** diff --git a/source/extensions/matching/generic_inputs/environment/input.h b/source/extensions/matching/generic_inputs/environment/input.h index f95422246ece..03166359fbba 100644 --- a/source/extensions/matching/generic_inputs/environment/input.h +++ b/source/extensions/matching/generic_inputs/environment/input.h @@ -10,19 +10,12 @@ namespace Environment { class Input : public Envoy::Matcher::GenericDataInput { public: - explicit Input(absl::string_view name) { - // We read the env variable at construction time to avoid repeat lookups. - // This assumes that the environment remains stable during the process lifetime. - auto* value = getenv(name.data()); - if (value != nullptr) { - storage_ = std::string(value); - } - } + explicit Input(absl::optional&& value) : storage_(std::move(value)) {} absl::optional get() override { return storage_; } private: - absl::optional storage_; + const absl::optional storage_; }; } // namespace Environment } // namespace GenericInputs diff --git a/test/extensions/matching/generic_inputs/environment/config_test.cc b/test/extensions/matching/generic_inputs/environment/config_test.cc index b658d7291c0d..4dfcf1a337e0 100644 --- a/test/extensions/matching/generic_inputs/environment/config_test.cc +++ b/test/extensions/matching/generic_inputs/environment/config_test.cc @@ -3,6 +3,7 @@ #include "extensions/matching/generic_inputs/environment/config.h" #include "test/mocks/server/factory_context.h" +#include "test/test_common/environment.h" #include "gtest/gtest.h" @@ -28,8 +29,21 @@ TEST(ConfigTest, TestConfig) { Config factory; auto message = Envoy::Config::Utility::translateAnyToFactoryConfig( config.typed_config(), ProtobufMessage::getStrictValidationVisitor(), factory); - auto matcher = factory.createGenericDataInput(*message, context); - EXPECT_NE(nullptr, matcher); + + { + auto input = factory.createGenericDataInput(*message, context); + EXPECT_NE(nullptr, input); + EXPECT_EQ(input->get(), absl::nullopt); + } + + TestEnvironment::setEnvVar("foo", "bar", 1); + { + auto input = factory.createGenericDataInput(*message, context); + EXPECT_NE(nullptr, input); + EXPECT_EQ(input->get(), absl::make_optional("bar")); + } + + TestEnvironment::unsetEnvVar("foo"); } } // namespace Environment diff --git a/test/extensions/matching/generic_inputs/environment/input_test.cc b/test/extensions/matching/generic_inputs/environment/input_test.cc index 3733dbc45dea..df859b12bdf0 100644 --- a/test/extensions/matching/generic_inputs/environment/input_test.cc +++ b/test/extensions/matching/generic_inputs/environment/input_test.cc @@ -1,7 +1,5 @@ #include "extensions/matching/generic_inputs/environment/input.h" -#include "test/test_common/environment.h" - #include "gtest/gtest.h" namespace Envoy { @@ -13,14 +11,13 @@ namespace Environment { TEST(InputTest, BasicUsage) { { Input input("foo"); - EXPECT_FALSE(input.get().has_value()); + ASSERT_TRUE(input.get().has_value()); + EXPECT_EQ(input.get().value(), "foo"); } - TestEnvironment::setEnvVar("foo", "bar", 1); Input input("foo"); - EXPECT_EQ("bar", input.get().value()); - - TestEnvironment::unsetEnvVar("foo"); + ASSERT_TRUE(input.get().has_value()); + EXPECT_EQ(input.get().value(), "foo"); } } // namespace Environment } // namespace GenericInputs From b28f63428f8bbba1f83a93aac01e9f559626aec1 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Mon, 15 Mar 2021 17:06:13 +0000 Subject: [PATCH 10/15] rename to EnvironmentVariable Signed-off-by: Snow Pettersen --- api/BUILD | 2 +- .../{environment => environment_variable}/v3/BUILD | 0 .../v3/input.proto} | 12 ++++++------ api/versioning/BUILD | 2 +- generated_api_shadow/BUILD | 2 +- .../{environment => environment_variable}/v3/BUILD | 0 .../v3/input.proto} | 12 ++++++------ source/extensions/extensions_build_config.bzl | 2 +- .../{environment => environment_variable}/BUILD | 2 +- .../{environment => environment_variable}/config.cc | 6 +++--- .../{environment => environment_variable}/config.h | 12 ++++++------ .../{environment => environment_variable}/input.h | 2 +- .../{environment => environment_variable}/BUILD | 8 ++++---- .../config_test.cc | 8 ++++---- .../input_test.cc | 4 ++-- 15 files changed, 37 insertions(+), 37 deletions(-) rename api/envoy/extensions/matching/generic_inputs/{environment => environment_variable}/v3/BUILD (100%) rename api/envoy/extensions/matching/generic_inputs/{environment/v3/environment.proto => environment_variable/v3/input.proto} (64%) rename generated_api_shadow/envoy/extensions/matching/generic_inputs/{environment => environment_variable}/v3/BUILD (100%) rename generated_api_shadow/envoy/extensions/matching/generic_inputs/{environment/v3/environment.proto => environment_variable/v3/input.proto} (64%) rename source/extensions/matching/generic_inputs/{environment => environment_variable}/BUILD (95%) rename source/extensions/matching/generic_inputs/{environment => environment_variable}/config.cc (89%) rename source/extensions/matching/generic_inputs/{environment => environment_variable}/config.h (70%) rename source/extensions/matching/generic_inputs/{environment => environment_variable}/input.h (94%) rename test/extensions/matching/generic_inputs/{environment => environment_variable}/BUILD (75%) rename test/extensions/matching/generic_inputs/{environment => environment_variable}/config_test.cc (88%) rename test/extensions/matching/generic_inputs/{environment => environment_variable}/input_test.cc (82%) diff --git a/api/BUILD b/api/BUILD index 383d2e5678f2..42f725958793 100644 --- a/api/BUILD +++ b/api/BUILD @@ -243,7 +243,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", - "//envoy/extensions/matching/generic_inputs/environment/v3:pkg", + "//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/api/envoy/extensions/matching/generic_inputs/environment/v3/BUILD b/api/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD similarity index 100% rename from api/envoy/extensions/matching/generic_inputs/environment/v3/BUILD rename to api/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD diff --git a/api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto b/api/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto similarity index 64% rename from api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto rename to api/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto index 85ead0f5693e..331b33554913 100644 --- a/api/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto +++ b/api/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto @@ -1,22 +1,22 @@ syntax = "proto3"; -package envoy.extensions.matching.generic_inputs.environment.v3; +package envoy.extensions.matching.generic_inputs.environment_variable.v3; import "udpa/annotations/migrate.proto"; import "udpa/annotations/status.proto"; import "udpa/annotations/versioning.proto"; import "validate/validate.proto"; -option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment.v3"; -option java_outer_classname = "EnvironmentProto"; +option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment_variable.v3"; +option java_outer_classname = "InputProto"; option java_multiple_files = true; option (udpa.annotations.file_status).package_version_status = ACTIVE; -// [#protodoc-title: Environment Input] -// [#extension: envoy.matching.generic_inputs.environment] +// [#protodoc-title: Environment Variable Input] +// [#extension: envoy.matching.generic_inputs.environment_variable] // Reads an environment variable to provide an input for matching. -message Environment { +message Config { // Name of the environment variable to read from. string name = 1 [(validate.rules).string = {min_len: 1}]; } diff --git a/api/versioning/BUILD b/api/versioning/BUILD index 478f44282443..4eb112f523ad 100644 --- a/api/versioning/BUILD +++ b/api/versioning/BUILD @@ -126,7 +126,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", - "//envoy/extensions/matching/generic_inputs/environment/v3:pkg", + "//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/generated_api_shadow/BUILD b/generated_api_shadow/BUILD index 383d2e5678f2..42f725958793 100644 --- a/generated_api_shadow/BUILD +++ b/generated_api_shadow/BUILD @@ -243,7 +243,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", - "//envoy/extensions/matching/generic_inputs/environment/v3:pkg", + "//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/BUILD b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD similarity index 100% rename from generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/BUILD rename to generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD diff --git a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto similarity index 64% rename from generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto rename to generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto index 85ead0f5693e..331b33554913 100644 --- a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment/v3/environment.proto +++ b/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto @@ -1,22 +1,22 @@ syntax = "proto3"; -package envoy.extensions.matching.generic_inputs.environment.v3; +package envoy.extensions.matching.generic_inputs.environment_variable.v3; import "udpa/annotations/migrate.proto"; import "udpa/annotations/status.proto"; import "udpa/annotations/versioning.proto"; import "validate/validate.proto"; -option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment.v3"; -option java_outer_classname = "EnvironmentProto"; +option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment_variable.v3"; +option java_outer_classname = "InputProto"; option java_multiple_files = true; option (udpa.annotations.file_status).package_version_status = ACTIVE; -// [#protodoc-title: Environment Input] -// [#extension: envoy.matching.generic_inputs.environment] +// [#protodoc-title: Environment Variable Input] +// [#extension: envoy.matching.generic_inputs.environment_variable] // Reads an environment variable to provide an input for matching. -message Environment { +message Config { // Name of the environment variable to read from. string name = 1 [(validate.rules).string = {min_len: 1}]; } diff --git a/source/extensions/extensions_build_config.bzl b/source/extensions/extensions_build_config.bzl index 1e0e20ed0162..6b2959b73468 100644 --- a/source/extensions/extensions_build_config.bzl +++ b/source/extensions/extensions_build_config.bzl @@ -54,7 +54,7 @@ EXTENSIONS = { # Generic Inputs # - "envoy.matching.generic_inputs.environment": "//source/extensions/matching/generic_inputs/environment:config", + "envoy.matching.generic_inputs.environment_variable": "//source/extensions/matching/generic_inputs/environment_variable:config", # # HTTP filters diff --git a/source/extensions/matching/generic_inputs/environment/BUILD b/source/extensions/matching/generic_inputs/environment_variable/BUILD similarity index 95% rename from source/extensions/matching/generic_inputs/environment/BUILD rename to source/extensions/matching/generic_inputs/environment_variable/BUILD index 7a0104f85ce7..0acd7ebdad05 100644 --- a/source/extensions/matching/generic_inputs/environment/BUILD +++ b/source/extensions/matching/generic_inputs/environment_variable/BUILD @@ -29,6 +29,6 @@ envoy_cc_extension( "//include/envoy/matcher:matcher_interface", "//include/envoy/registry", "//include/envoy/server:factory_context_interface", - "@envoy_api//envoy/extensions/matching/generic_inputs/environment/v3:pkg_cc_proto", + "@envoy_api//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg_cc_proto", ], ) diff --git a/source/extensions/matching/generic_inputs/environment/config.cc b/source/extensions/matching/generic_inputs/environment_variable/config.cc similarity index 89% rename from source/extensions/matching/generic_inputs/environment/config.cc rename to source/extensions/matching/generic_inputs/environment_variable/config.cc index 6ca76b37d872..8323f2dc0577 100644 --- a/source/extensions/matching/generic_inputs/environment/config.cc +++ b/source/extensions/matching/generic_inputs/environment_variable/config.cc @@ -1,4 +1,4 @@ -#include "extensions/matching/generic_inputs/environment/config.h" +#include "extensions/matching/generic_inputs/environment_variable/config.h" #include @@ -8,13 +8,13 @@ namespace Envoy { namespace Extensions { namespace Matching { namespace GenericInputs { -namespace Environment { +namespace EnvironmentVariable { Envoy::Matcher::GenericDataInputPtr Config::createGenericDataInput(const Protobuf::Message& config, Server::Configuration::FactoryContext& factory_context) { const auto& environment_config = MessageUtil::downcastAndValidate< - const envoy::extensions::matching::generic_inputs::environment::v3::Environment&>( + const envoy::extensions::matching::generic_inputs::environment_variable::v3::Config&>( config, factory_context.messageValidationVisitor()); // We read the env variable at construction time to avoid repeat lookups. diff --git a/source/extensions/matching/generic_inputs/environment/config.h b/source/extensions/matching/generic_inputs/environment_variable/config.h similarity index 70% rename from source/extensions/matching/generic_inputs/environment/config.h rename to source/extensions/matching/generic_inputs/environment_variable/config.h index d8a609259600..6414918f64b0 100644 --- a/source/extensions/matching/generic_inputs/environment/config.h +++ b/source/extensions/matching/generic_inputs/environment_variable/config.h @@ -1,19 +1,19 @@ #pragma once -#include "envoy/extensions/matching/generic_inputs/environment/v3/environment.pb.h" -#include "envoy/extensions/matching/generic_inputs/environment/v3/environment.pb.validate.h" +#include "envoy/extensions/matching/generic_inputs/environment_variable/v3/input.pb.h" +#include "envoy/extensions/matching/generic_inputs/environment_variable/v3/input.pb.validate.h" #include "envoy/matcher/matcher.h" #include "envoy/server/factory_context.h" #include "common/protobuf/utility.h" -#include "extensions/matching/generic_inputs/environment/input.h" +#include "extensions/matching/generic_inputs/environment_variable/input.h" namespace Envoy { namespace Extensions { namespace Matching { namespace GenericInputs { -namespace Environment { +namespace EnvironmentVariable { class Config : public Envoy::Matcher::GenericDataInputFactory { public: @@ -21,11 +21,11 @@ class Config : public Envoy::Matcher::GenericDataInputFactory { createGenericDataInput(const Protobuf::Message& config, Server::Configuration::FactoryContext& factory_context) override; - std::string name() const override { return "envoy.matching.generic_inputs.environment"; } + std::string name() const override { return "envoy.matching.generic_inputs.environment_variable"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { return std::make_unique< - envoy::extensions::matching::generic_inputs::environment::v3::Environment>(); + envoy::extensions::matching::generic_inputs::environment_variable::v3::Config>(); } }; } // namespace Environment diff --git a/source/extensions/matching/generic_inputs/environment/input.h b/source/extensions/matching/generic_inputs/environment_variable/input.h similarity index 94% rename from source/extensions/matching/generic_inputs/environment/input.h rename to source/extensions/matching/generic_inputs/environment_variable/input.h index 03166359fbba..a274a6362575 100644 --- a/source/extensions/matching/generic_inputs/environment/input.h +++ b/source/extensions/matching/generic_inputs/environment_variable/input.h @@ -6,7 +6,7 @@ namespace Envoy { namespace Extensions { namespace Matching { namespace GenericInputs { -namespace Environment { +namespace EnvironmentVariable { class Input : public Envoy::Matcher::GenericDataInput { public: diff --git a/test/extensions/matching/generic_inputs/environment/BUILD b/test/extensions/matching/generic_inputs/environment_variable/BUILD similarity index 75% rename from test/extensions/matching/generic_inputs/environment/BUILD rename to test/extensions/matching/generic_inputs/environment_variable/BUILD index 894aec954c9c..12acd20a5af6 100644 --- a/test/extensions/matching/generic_inputs/environment/BUILD +++ b/test/extensions/matching/generic_inputs/environment_variable/BUILD @@ -14,9 +14,9 @@ envoy_package() envoy_extension_cc_test( name = "config_test", srcs = ["config_test.cc"], - extension_name = "envoy.matching.generic_inputs.environment", + extension_name = "envoy.matching.generic_inputs.environment_variable", deps = [ - "//source/extensions/matching/generic_inputs/environment:config", + "//source/extensions/matching/generic_inputs/environment_variable:config", "//test/mocks/server:factory_context_mocks", ], ) @@ -24,8 +24,8 @@ envoy_extension_cc_test( envoy_extension_cc_test( name = "input_test", srcs = ["input_test.cc"], - extension_name = "envoy.matching.generic_inputs.environment", + extension_name = "envoy.matching.generic_inputs.environment_variable", deps = [ - "//source/extensions/matching/generic_inputs/environment:input_lib", + "//source/extensions/matching/generic_inputs/environment_variable:input_lib", ], ) diff --git a/test/extensions/matching/generic_inputs/environment/config_test.cc b/test/extensions/matching/generic_inputs/environment_variable/config_test.cc similarity index 88% rename from test/extensions/matching/generic_inputs/environment/config_test.cc rename to test/extensions/matching/generic_inputs/environment_variable/config_test.cc index 4dfcf1a337e0..bb9faf86d2bb 100644 --- a/test/extensions/matching/generic_inputs/environment/config_test.cc +++ b/test/extensions/matching/generic_inputs/environment_variable/config_test.cc @@ -1,6 +1,6 @@ #include "common/config/utility.h" -#include "extensions/matching/generic_inputs/environment/config.h" +#include "extensions/matching/generic_inputs/environment_variable/config.h" #include "test/mocks/server/factory_context.h" #include "test/test_common/environment.h" @@ -11,7 +11,7 @@ namespace Envoy { namespace Extensions { namespace Matching { namespace GenericInputs { -namespace Environment { +namespace EnvironmentVariable { TEST(ConfigTest, TestConfig) { NiceMock context; @@ -19,7 +19,7 @@ TEST(ConfigTest, TestConfig) { const std::string yaml_string = R"EOF( name: hashing typed_config: - "@type": type.googleapis.com/envoy.extensions.matching.generic_inputs.environment.v3.Environment + "@type": type.googleapis.com/envoy.extensions.matching.generic_inputs.environment_variable.v3.Config name: foo )EOF"; @@ -50,4 +50,4 @@ TEST(ConfigTest, TestConfig) { } // namespace GenericInputs } // namespace Matching } // namespace Extensions -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/test/extensions/matching/generic_inputs/environment/input_test.cc b/test/extensions/matching/generic_inputs/environment_variable/input_test.cc similarity index 82% rename from test/extensions/matching/generic_inputs/environment/input_test.cc rename to test/extensions/matching/generic_inputs/environment_variable/input_test.cc index df859b12bdf0..2cc8de2015b6 100644 --- a/test/extensions/matching/generic_inputs/environment/input_test.cc +++ b/test/extensions/matching/generic_inputs/environment_variable/input_test.cc @@ -1,4 +1,4 @@ -#include "extensions/matching/generic_inputs/environment/input.h" +#include "extensions/matching/generic_inputs/environment_variable/input.h" #include "gtest/gtest.h" @@ -6,7 +6,7 @@ namespace Envoy { namespace Extensions { namespace Matching { namespace GenericInputs { -namespace Environment { +namespace EnvironmentVariable { TEST(InputTest, BasicUsage) { { From 84a528bae4edba877c3b101d4490c3a75c127edd Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Mon, 15 Mar 2021 17:09:31 +0000 Subject: [PATCH 11/15] format Signed-off-by: Snow Pettersen --- .../matching/generic_inputs/environment_variable/config.cc | 2 +- .../matching/generic_inputs/environment_variable/config.h | 2 +- .../matching/generic_inputs/environment_variable/input.h | 2 +- .../matching/generic_inputs/environment_variable/config_test.cc | 2 +- .../matching/generic_inputs/environment_variable/input_test.cc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/extensions/matching/generic_inputs/environment_variable/config.cc b/source/extensions/matching/generic_inputs/environment_variable/config.cc index 8323f2dc0577..195403676840 100644 --- a/source/extensions/matching/generic_inputs/environment_variable/config.cc +++ b/source/extensions/matching/generic_inputs/environment_variable/config.cc @@ -32,7 +32,7 @@ Config::createGenericDataInput(const Protobuf::Message& config, */ REGISTER_FACTORY(Config, Envoy::Matcher::GenericDataInputFactory); -} // namespace Environment +} // namespace EnvironmentVariable } // namespace GenericInputs } // namespace Matching } // namespace Extensions diff --git a/source/extensions/matching/generic_inputs/environment_variable/config.h b/source/extensions/matching/generic_inputs/environment_variable/config.h index 6414918f64b0..13a1c65ffccb 100644 --- a/source/extensions/matching/generic_inputs/environment_variable/config.h +++ b/source/extensions/matching/generic_inputs/environment_variable/config.h @@ -28,7 +28,7 @@ class Config : public Envoy::Matcher::GenericDataInputFactory { envoy::extensions::matching::generic_inputs::environment_variable::v3::Config>(); } }; -} // namespace Environment +} // namespace EnvironmentVariable } // namespace GenericInputs } // namespace Matching } // namespace Extensions diff --git a/source/extensions/matching/generic_inputs/environment_variable/input.h b/source/extensions/matching/generic_inputs/environment_variable/input.h index a274a6362575..c273ecd82ad7 100644 --- a/source/extensions/matching/generic_inputs/environment_variable/input.h +++ b/source/extensions/matching/generic_inputs/environment_variable/input.h @@ -17,7 +17,7 @@ class Input : public Envoy::Matcher::GenericDataInput { private: const absl::optional storage_; }; -} // namespace Environment +} // namespace EnvironmentVariable } // namespace GenericInputs } // namespace Matching } // namespace Extensions diff --git a/test/extensions/matching/generic_inputs/environment_variable/config_test.cc b/test/extensions/matching/generic_inputs/environment_variable/config_test.cc index bb9faf86d2bb..e17fc698a5ec 100644 --- a/test/extensions/matching/generic_inputs/environment_variable/config_test.cc +++ b/test/extensions/matching/generic_inputs/environment_variable/config_test.cc @@ -46,7 +46,7 @@ TEST(ConfigTest, TestConfig) { TestEnvironment::unsetEnvVar("foo"); } -} // namespace Environment +} // namespace EnvironmentVariable } // namespace GenericInputs } // namespace Matching } // namespace Extensions diff --git a/test/extensions/matching/generic_inputs/environment_variable/input_test.cc b/test/extensions/matching/generic_inputs/environment_variable/input_test.cc index 2cc8de2015b6..41c7bd63e037 100644 --- a/test/extensions/matching/generic_inputs/environment_variable/input_test.cc +++ b/test/extensions/matching/generic_inputs/environment_variable/input_test.cc @@ -19,7 +19,7 @@ TEST(InputTest, BasicUsage) { ASSERT_TRUE(input.get().has_value()); EXPECT_EQ(input.get().value(), "foo"); } -} // namespace Environment +} // namespace EnvironmentVariable } // namespace GenericInputs } // namespace Matching } // namespace Extensions From 246653f63c6d39f25b2fe94b2fe2188077d42b1a Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Thu, 18 Mar 2021 13:56:04 +0000 Subject: [PATCH 12/15] rename to common protocol inputs Signed-off-by: Snow Pettersen --- CODEOWNERS | 2 +- api/BUILD | 2 +- .../config/common/matcher/v3/matcher.proto | 2 +- .../common/matcher/v4alpha/matcher.proto | 2 +- .../environment_variable/v3/BUILD | 0 .../environment_variable/v3/input.proto | 6 ++-- api/versioning/BUILD | 2 +- bazel/envoy_library.bzl | 2 +- .../common_messages/common_messages.rst | 2 +- generated_api_shadow/BUILD | 2 +- .../config/common/matcher/v3/matcher.proto | 2 +- .../common/matcher/v4alpha/matcher.proto | 2 +- .../environment_variable/v3/BUILD | 0 .../environment_variable/v3/input.proto | 6 ++-- include/envoy/matcher/matcher.h | 25 ++++++++----- source/common/matcher/matcher.h | 24 +++++++------ source/extensions/extensions_build_config.bzl | 2 +- .../environment_variable/BUILD | 4 +-- .../environment_variable/config.cc | 16 ++++----- .../environment_variable/config.h | 35 +++++++++++++++++++ .../environment_variable/input.h | 6 ++-- .../environment_variable/config.h | 35 ------------------- .../environment_variable/BUILD | 8 ++--- .../environment_variable/config_test.cc | 12 +++---- .../environment_variable/input_test.cc | 6 ++-- 25 files changed, 107 insertions(+), 98 deletions(-) rename api/envoy/extensions/matching/{generic_inputs => common_inputs}/environment_variable/v3/BUILD (100%) rename api/envoy/extensions/matching/{generic_inputs => common_inputs}/environment_variable/v3/input.proto (70%) rename generated_api_shadow/envoy/extensions/matching/{generic_inputs => common_inputs}/environment_variable/v3/BUILD (100%) rename generated_api_shadow/envoy/extensions/matching/{generic_inputs => common_inputs}/environment_variable/v3/input.proto (70%) rename source/extensions/matching/{generic_inputs => common_inputs}/environment_variable/BUILD (82%) rename source/extensions/matching/{generic_inputs => common_inputs}/environment_variable/config.cc (62%) create mode 100644 source/extensions/matching/common_inputs/environment_variable/config.h rename source/extensions/matching/{generic_inputs => common_inputs}/environment_variable/input.h (81%) delete mode 100644 source/extensions/matching/generic_inputs/environment_variable/config.h rename test/extensions/matching/{generic_inputs => common_inputs}/environment_variable/BUILD (59%) rename test/extensions/matching/{generic_inputs => common_inputs}/environment_variable/config_test.cc (74%) rename test/extensions/matching/{generic_inputs => common_inputs}/environment_variable/input_test.cc (78%) diff --git a/CODEOWNERS b/CODEOWNERS index 67b42563c340..0dc3f4610b8c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -169,7 +169,7 @@ extensions/filters/http/oauth2 @rgs1 @derekargueta @snowp # hash input matcher /*/extensions/matching/input_matchers/consistent_hashing @snowp @donyu # environment generic input -/*/extensions/matching/generic_inputs/environment @snowp @donyu +/*/extensions/matching/common_inputs/environment @snowp @donyu # user space socket pair and event /*/extensions/io_socket/user_space @lambdai @antoniovicente # Default UUID4 request ID extension diff --git a/api/BUILD b/api/BUILD index 42f725958793..5371e9377e70 100644 --- a/api/BUILD +++ b/api/BUILD @@ -243,7 +243,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", - "//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg", + "//envoy/extensions/matching/common_inputs/environment_variable/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/api/envoy/config/common/matcher/v3/matcher.proto b/api/envoy/config/common/matcher/v3/matcher.proto index 25d74883ab80..f9a4aafa945e 100644 --- a/api/envoy/config/common/matcher/v3/matcher.proto +++ b/api/envoy/config/common/matcher/v3/matcher.proto @@ -50,7 +50,7 @@ message Matcher { // Predicate for a single input field. message SinglePredicate { // Protocol-specific specification of input field to match on. - // [#extension-category: envoy.matching.generic_inputs] + // [#extension-category: envoy.matching.common_inputs] core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/api/envoy/config/common/matcher/v4alpha/matcher.proto b/api/envoy/config/common/matcher/v4alpha/matcher.proto index be56a2e99c69..45a1e020751d 100644 --- a/api/envoy/config/common/matcher/v4alpha/matcher.proto +++ b/api/envoy/config/common/matcher/v4alpha/matcher.proto @@ -66,7 +66,7 @@ message Matcher { "envoy.config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate"; // Protocol-specific specification of input field to match on. - // [#extension-category: envoy.matching.generic_inputs] + // [#extension-category: envoy.matching.common-inputs] core.v4alpha.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/api/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD b/api/envoy/extensions/matching/common_inputs/environment_variable/v3/BUILD similarity index 100% rename from api/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD rename to api/envoy/extensions/matching/common_inputs/environment_variable/v3/BUILD diff --git a/api/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto b/api/envoy/extensions/matching/common_inputs/environment_variable/v3/input.proto similarity index 70% rename from api/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto rename to api/envoy/extensions/matching/common_inputs/environment_variable/v3/input.proto index 331b33554913..13db7227c640 100644 --- a/api/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto +++ b/api/envoy/extensions/matching/common_inputs/environment_variable/v3/input.proto @@ -1,19 +1,19 @@ syntax = "proto3"; -package envoy.extensions.matching.generic_inputs.environment_variable.v3; +package envoy.extensions.matching.common_inputs.environment_variable.v3; import "udpa/annotations/migrate.proto"; import "udpa/annotations/status.proto"; import "udpa/annotations/versioning.proto"; import "validate/validate.proto"; -option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment_variable.v3"; +option java_package = "io.envoyproxy.envoy.extensions.matching.common_inputs.environment_variable.v3"; option java_outer_classname = "InputProto"; option java_multiple_files = true; option (udpa.annotations.file_status).package_version_status = ACTIVE; // [#protodoc-title: Environment Variable Input] -// [#extension: envoy.matching.generic_inputs.environment_variable] +// [#extension: envoy.matching.common_inputs.environment_variable] // Reads an environment variable to provide an input for matching. message Config { diff --git a/api/versioning/BUILD b/api/versioning/BUILD index 4eb112f523ad..8fe926ffb278 100644 --- a/api/versioning/BUILD +++ b/api/versioning/BUILD @@ -126,7 +126,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", - "//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg", + "//envoy/extensions/matching/common_inputs/environment_variable/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/bazel/envoy_library.bzl b/bazel/envoy_library.bzl index 766051875663..74ab71efc303 100644 --- a/bazel/envoy_library.bzl +++ b/bazel/envoy_library.bzl @@ -82,7 +82,7 @@ EXTENSION_CATEGORIES = [ "envoy.health_checkers", "envoy.internal_redirect_predicates", "envoy.io_socket", - "envoy.matching.generic_inputs", + "envoy.matching.common_inputs", "envoy.matching.input_matchers", "envoy.rate_limit_descriptors", "envoy.request_id", diff --git a/docs/root/api-v3/common_messages/common_messages.rst b/docs/root/api-v3/common_messages/common_messages.rst index 10250637b835..85a077155f24 100644 --- a/docs/root/api-v3/common_messages/common_messages.rst +++ b/docs/root/api-v3/common_messages/common_messages.rst @@ -25,4 +25,4 @@ Common messages ../extensions/filters/common/dependency/v3/dependency.proto ../extensions/filters/common/matcher/action/v3/skip_action.proto ../extensions/matching/input_matchers/consistent_hashing/v3/consistent_hashing.proto - ../extensions/matching/generic_inputs/environment/v3/environment.proto + ../extensions/matching/common_inputs/environment_variable/v3/input.proto diff --git a/generated_api_shadow/BUILD b/generated_api_shadow/BUILD index 42f725958793..5371e9377e70 100644 --- a/generated_api_shadow/BUILD +++ b/generated_api_shadow/BUILD @@ -243,7 +243,7 @@ proto_library( "//envoy/extensions/internal_redirect/allow_listed_routes/v3:pkg", "//envoy/extensions/internal_redirect/previous_routes/v3:pkg", "//envoy/extensions/internal_redirect/safe_cross_scheme/v3:pkg", - "//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg", + "//envoy/extensions/matching/common_inputs/environment_variable/v3:pkg", "//envoy/extensions/matching/input_matchers/consistent_hashing/v3:pkg", "//envoy/extensions/network/socket_interface/v3:pkg", "//envoy/extensions/rate_limit_descriptors/expr/v3:pkg", diff --git a/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto b/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto index 25d74883ab80..f9a4aafa945e 100644 --- a/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto +++ b/generated_api_shadow/envoy/config/common/matcher/v3/matcher.proto @@ -50,7 +50,7 @@ message Matcher { // Predicate for a single input field. message SinglePredicate { // Protocol-specific specification of input field to match on. - // [#extension-category: envoy.matching.generic_inputs] + // [#extension-category: envoy.matching.common_inputs] core.v3.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto b/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto index be56a2e99c69..7747157a24dc 100644 --- a/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto +++ b/generated_api_shadow/envoy/config/common/matcher/v4alpha/matcher.proto @@ -66,7 +66,7 @@ message Matcher { "envoy.config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate"; // Protocol-specific specification of input field to match on. - // [#extension-category: envoy.matching.generic_inputs] + // [#extension-category: envoy.matching.common_inputs] core.v4alpha.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { diff --git a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD b/generated_api_shadow/envoy/extensions/matching/common_inputs/environment_variable/v3/BUILD similarity index 100% rename from generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/BUILD rename to generated_api_shadow/envoy/extensions/matching/common_inputs/environment_variable/v3/BUILD diff --git a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto b/generated_api_shadow/envoy/extensions/matching/common_inputs/environment_variable/v3/input.proto similarity index 70% rename from generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto rename to generated_api_shadow/envoy/extensions/matching/common_inputs/environment_variable/v3/input.proto index 331b33554913..13db7227c640 100644 --- a/generated_api_shadow/envoy/extensions/matching/generic_inputs/environment_variable/v3/input.proto +++ b/generated_api_shadow/envoy/extensions/matching/common_inputs/environment_variable/v3/input.proto @@ -1,19 +1,19 @@ syntax = "proto3"; -package envoy.extensions.matching.generic_inputs.environment_variable.v3; +package envoy.extensions.matching.common_inputs.environment_variable.v3; import "udpa/annotations/migrate.proto"; import "udpa/annotations/status.proto"; import "udpa/annotations/versioning.proto"; import "validate/validate.proto"; -option java_package = "io.envoyproxy.envoy.extensions.matching.generic_inputs.environment_variable.v3"; +option java_package = "io.envoyproxy.envoy.extensions.matching.common_inputs.environment_variable.v3"; option java_outer_classname = "InputProto"; option java_multiple_files = true; option (udpa.annotations.file_status).package_version_status = ACTIVE; // [#protodoc-title: Environment Variable Input] -// [#extension: envoy.matching.generic_inputs.environment_variable] +// [#extension: envoy.matching.common_inputs.environment_variable] // Reads an environment variable to provide an input for matching. message Config { diff --git a/include/envoy/matcher/matcher.h b/include/envoy/matcher/matcher.h index b7b7f9213361..ca55c8227c68 100644 --- a/include/envoy/matcher/matcher.h +++ b/include/envoy/matcher/matcher.h @@ -237,23 +237,30 @@ template class DataInputFactory : public Config::TypedFactory { } }; -class GenericDataInput { +/** + * Interface for types providing a way to use a string for matching without depending on protocol + * data. As a result, these can be used for all protocols. + */ +class CommonProtocolInput { public: - virtual ~GenericDataInput() = default; + virtual ~CommonProtocolInput() = default; virtual absl::optional get() PURE; }; -using GenericDataInputPtr = std::unique_ptr; +using CommonProtocolInputPtr = std::unique_ptr; -class GenericDataInputFactory : public Config::TypedFactory { +/** + * Factory for CommonProtocolInput. + */ +class CommonProtocolInputFactory : public Config::TypedFactory { public: /** - * Creates a GenericDataInput from the provided config. + * Creates a CommonProtocolInput from the provided config. */ - virtual GenericDataInputPtr - createGenericDataInput(const Protobuf::Message& config, - Server::Configuration::FactoryContext& factory_context) PURE; + virtual CommonProtocolInputPtr + createCommonProtocolInput(const Protobuf::Message& config, + Server::Configuration::FactoryContext& factory_context) PURE; - std::string category() const override { return "envoy.matching.generic_inputs"; } + std::string category() const override { return "envoy.matching.common_inputs"; } }; } // namespace Matcher diff --git a/source/common/matcher/matcher.h b/source/common/matcher/matcher.h index 6cea1e3da154..e2f41d27ad2a 100644 --- a/source/common/matcher/matcher.h +++ b/source/common/matcher/matcher.h @@ -155,19 +155,19 @@ template class MatchTreeFactory { return absl::nullopt; } - // Wrapper around a GenericDataInput that allows it to be used as a DataInput. - class GenericDataInputWrapper : public DataInput { + // Wrapper around a CommonProtocolInput that allows it to be used as a DataInput. + class CommonProtocolInputWrapper : public DataInput { public: - explicit GenericDataInputWrapper(GenericDataInputPtr&& generic_data_input) - : generic_data_input_(std::move(generic_data_input)) {} + explicit CommonProtocolInputWrapper(CommonProtocolInputPtr&& common_protocol_input) + : common_protocol_input_(std::move(common_protocol_input)) {} DataInputGetResult get(const DataType&) override { return DataInputGetResult{DataInputGetResult::DataAvailability::AllDataAvailable, - generic_data_input_->get()}; + common_protocol_input_->get()}; } private: - const GenericDataInputPtr generic_data_input_; + const CommonProtocolInputPtr common_protocol_input_; }; DataInputPtr @@ -179,12 +179,14 @@ template class MatchTreeFactory { return factory->createDataInput(*message, factory_context_); } - // If the provided config doesn't match a typed input, assume that this is a generic input. - auto& generic_factory = Config::Utility::getAndCheckFactory(config); + // If the provided config doesn't match a typed input, assume that this is one of the common + // inputs. + auto& common_input_factory = + Config::Utility::getAndCheckFactory(config); ProtobufTypes::MessagePtr message = Config::Utility::translateAnyToFactoryConfig( - config.typed_config(), factory_context_.messageValidationVisitor(), generic_factory); - return std::make_unique( - generic_factory.createGenericDataInput(*message, factory_context_)); + config.typed_config(), factory_context_.messageValidationVisitor(), common_input_factory); + return std::make_unique( + common_input_factory.createCommonProtocolInput(*message, factory_context_)); } InputMatcherPtr createInputMatcher( diff --git a/source/extensions/extensions_build_config.bzl b/source/extensions/extensions_build_config.bzl index 6b2959b73468..377c4bef5537 100644 --- a/source/extensions/extensions_build_config.bzl +++ b/source/extensions/extensions_build_config.bzl @@ -54,7 +54,7 @@ EXTENSIONS = { # Generic Inputs # - "envoy.matching.generic_inputs.environment_variable": "//source/extensions/matching/generic_inputs/environment_variable:config", + "envoy.matching.common_inputs.environment_variable": "//source/extensions/matching/common_inputs/environment_variable:config", # # HTTP filters diff --git a/source/extensions/matching/generic_inputs/environment_variable/BUILD b/source/extensions/matching/common_inputs/environment_variable/BUILD similarity index 82% rename from source/extensions/matching/generic_inputs/environment_variable/BUILD rename to source/extensions/matching/common_inputs/environment_variable/BUILD index 0acd7ebdad05..cf54b92130a8 100644 --- a/source/extensions/matching/generic_inputs/environment_variable/BUILD +++ b/source/extensions/matching/common_inputs/environment_variable/BUILD @@ -22,13 +22,13 @@ envoy_cc_extension( name = "config", srcs = ["config.cc"], hdrs = ["config.h"], - category = "envoy.matching.generic_inputs", + category = "envoy.matching.common_inputs", security_posture = "robust_to_untrusted_downstream", deps = [ ":input_lib", "//include/envoy/matcher:matcher_interface", "//include/envoy/registry", "//include/envoy/server:factory_context_interface", - "@envoy_api//envoy/extensions/matching/generic_inputs/environment_variable/v3:pkg_cc_proto", + "@envoy_api//envoy/extensions/matching/common_inputs/environment_variable/v3:pkg_cc_proto", ], ) diff --git a/source/extensions/matching/generic_inputs/environment_variable/config.cc b/source/extensions/matching/common_inputs/environment_variable/config.cc similarity index 62% rename from source/extensions/matching/generic_inputs/environment_variable/config.cc rename to source/extensions/matching/common_inputs/environment_variable/config.cc index 195403676840..494cda285ea5 100644 --- a/source/extensions/matching/generic_inputs/environment_variable/config.cc +++ b/source/extensions/matching/common_inputs/environment_variable/config.cc @@ -1,4 +1,4 @@ -#include "extensions/matching/generic_inputs/environment_variable/config.h" +#include "extensions/matching/common_inputs/environment_variable/config.h" #include @@ -7,14 +7,14 @@ namespace Envoy { namespace Extensions { namespace Matching { -namespace GenericInputs { +namespace CommonInputs { namespace EnvironmentVariable { -Envoy::Matcher::GenericDataInputPtr -Config::createGenericDataInput(const Protobuf::Message& config, - Server::Configuration::FactoryContext& factory_context) { +Envoy::Matcher::CommonProtocolInputPtr +Config::createCommonProtocolInput(const Protobuf::Message& config, + Server::Configuration::FactoryContext& factory_context) { const auto& environment_config = MessageUtil::downcastAndValidate< - const envoy::extensions::matching::generic_inputs::environment_variable::v3::Config&>( + const envoy::extensions::matching::common_inputs::environment_variable::v3::Config&>( config, factory_context.messageValidationVisitor()); // We read the env variable at construction time to avoid repeat lookups. @@ -30,10 +30,10 @@ Config::createGenericDataInput(const Protobuf::Message& config, /** * Static registration for the environment data input. @see RegisterFactory. */ -REGISTER_FACTORY(Config, Envoy::Matcher::GenericDataInputFactory); +REGISTER_FACTORY(Config, Envoy::Matcher::CommonProtocolInputFactory); } // namespace EnvironmentVariable -} // namespace GenericInputs +} // namespace CommonInputs } // namespace Matching } // namespace Extensions } // namespace Envoy \ No newline at end of file diff --git a/source/extensions/matching/common_inputs/environment_variable/config.h b/source/extensions/matching/common_inputs/environment_variable/config.h new file mode 100644 index 000000000000..1585d69b0000 --- /dev/null +++ b/source/extensions/matching/common_inputs/environment_variable/config.h @@ -0,0 +1,35 @@ +#pragma once + +#include "envoy/extensions/matching/common_inputs/environment_variable/v3/input.pb.h" +#include "envoy/extensions/matching/common_inputs/environment_variable/v3/input.pb.validate.h" +#include "envoy/matcher/matcher.h" +#include "envoy/server/factory_context.h" + +#include "common/protobuf/utility.h" + +#include "extensions/matching/common_inputs/environment_variable/input.h" + +namespace Envoy { +namespace Extensions { +namespace Matching { +namespace CommonInputs { +namespace EnvironmentVariable { + +class Config : public Envoy::Matcher::CommonProtocolInputFactory { +public: + Envoy::Matcher::CommonProtocolInputPtr + createCommonProtocolInput(const Protobuf::Message& config, + Server::Configuration::FactoryContext& factory_context) override; + + std::string name() const override { return "envoy.matching.common_inputs.environment_variable"; } + + ProtobufTypes::MessagePtr createEmptyConfigProto() override { + return std::make_unique< + envoy::extensions::matching::common_inputs::environment_variable::v3::Config>(); + } +}; +} // namespace EnvironmentVariable +} // namespace CommonInputs +} // namespace Matching +} // namespace Extensions +} // namespace Envoy \ No newline at end of file diff --git a/source/extensions/matching/generic_inputs/environment_variable/input.h b/source/extensions/matching/common_inputs/environment_variable/input.h similarity index 81% rename from source/extensions/matching/generic_inputs/environment_variable/input.h rename to source/extensions/matching/common_inputs/environment_variable/input.h index c273ecd82ad7..53bf8e297ead 100644 --- a/source/extensions/matching/generic_inputs/environment_variable/input.h +++ b/source/extensions/matching/common_inputs/environment_variable/input.h @@ -5,10 +5,10 @@ namespace Envoy { namespace Extensions { namespace Matching { -namespace GenericInputs { +namespace CommonInputs { namespace EnvironmentVariable { -class Input : public Envoy::Matcher::GenericDataInput { +class Input : public Matcher::CommonProtocolInput { public: explicit Input(absl::optional&& value) : storage_(std::move(value)) {} @@ -18,7 +18,7 @@ class Input : public Envoy::Matcher::GenericDataInput { const absl::optional storage_; }; } // namespace EnvironmentVariable -} // namespace GenericInputs +} // namespace CommonInputs } // namespace Matching } // namespace Extensions } // namespace Envoy \ No newline at end of file diff --git a/source/extensions/matching/generic_inputs/environment_variable/config.h b/source/extensions/matching/generic_inputs/environment_variable/config.h deleted file mode 100644 index 13a1c65ffccb..000000000000 --- a/source/extensions/matching/generic_inputs/environment_variable/config.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "envoy/extensions/matching/generic_inputs/environment_variable/v3/input.pb.h" -#include "envoy/extensions/matching/generic_inputs/environment_variable/v3/input.pb.validate.h" -#include "envoy/matcher/matcher.h" -#include "envoy/server/factory_context.h" - -#include "common/protobuf/utility.h" - -#include "extensions/matching/generic_inputs/environment_variable/input.h" - -namespace Envoy { -namespace Extensions { -namespace Matching { -namespace GenericInputs { -namespace EnvironmentVariable { - -class Config : public Envoy::Matcher::GenericDataInputFactory { -public: - Envoy::Matcher::GenericDataInputPtr - createGenericDataInput(const Protobuf::Message& config, - Server::Configuration::FactoryContext& factory_context) override; - - std::string name() const override { return "envoy.matching.generic_inputs.environment_variable"; } - - ProtobufTypes::MessagePtr createEmptyConfigProto() override { - return std::make_unique< - envoy::extensions::matching::generic_inputs::environment_variable::v3::Config>(); - } -}; -} // namespace EnvironmentVariable -} // namespace GenericInputs -} // namespace Matching -} // namespace Extensions -} // namespace Envoy \ No newline at end of file diff --git a/test/extensions/matching/generic_inputs/environment_variable/BUILD b/test/extensions/matching/common_inputs/environment_variable/BUILD similarity index 59% rename from test/extensions/matching/generic_inputs/environment_variable/BUILD rename to test/extensions/matching/common_inputs/environment_variable/BUILD index 12acd20a5af6..e688a7dcb792 100644 --- a/test/extensions/matching/generic_inputs/environment_variable/BUILD +++ b/test/extensions/matching/common_inputs/environment_variable/BUILD @@ -14,9 +14,9 @@ envoy_package() envoy_extension_cc_test( name = "config_test", srcs = ["config_test.cc"], - extension_name = "envoy.matching.generic_inputs.environment_variable", + extension_name = "envoy.matching.common_inputs.environment_variable", deps = [ - "//source/extensions/matching/generic_inputs/environment_variable:config", + "//source/extensions/matching/common_inputs/environment_variable:config", "//test/mocks/server:factory_context_mocks", ], ) @@ -24,8 +24,8 @@ envoy_extension_cc_test( envoy_extension_cc_test( name = "input_test", srcs = ["input_test.cc"], - extension_name = "envoy.matching.generic_inputs.environment_variable", + extension_name = "envoy.matching.common_inputs.environment_variable", deps = [ - "//source/extensions/matching/generic_inputs/environment_variable:input_lib", + "//source/extensions/matching/common_inputs/environment_variable:input_lib", ], ) diff --git a/test/extensions/matching/generic_inputs/environment_variable/config_test.cc b/test/extensions/matching/common_inputs/environment_variable/config_test.cc similarity index 74% rename from test/extensions/matching/generic_inputs/environment_variable/config_test.cc rename to test/extensions/matching/common_inputs/environment_variable/config_test.cc index e17fc698a5ec..f8a697979c9e 100644 --- a/test/extensions/matching/generic_inputs/environment_variable/config_test.cc +++ b/test/extensions/matching/common_inputs/environment_variable/config_test.cc @@ -1,6 +1,6 @@ #include "common/config/utility.h" -#include "extensions/matching/generic_inputs/environment_variable/config.h" +#include "extensions/matching/common_inputs/environment_variable/config.h" #include "test/mocks/server/factory_context.h" #include "test/test_common/environment.h" @@ -10,7 +10,7 @@ namespace Envoy { namespace Extensions { namespace Matching { -namespace GenericInputs { +namespace CommonInputs { namespace EnvironmentVariable { TEST(ConfigTest, TestConfig) { @@ -19,7 +19,7 @@ TEST(ConfigTest, TestConfig) { const std::string yaml_string = R"EOF( name: hashing typed_config: - "@type": type.googleapis.com/envoy.extensions.matching.generic_inputs.environment_variable.v3.Config + "@type": type.googleapis.com/envoy.extensions.matching.common_inputs.environment_variable.v3.Config name: foo )EOF"; @@ -31,14 +31,14 @@ TEST(ConfigTest, TestConfig) { config.typed_config(), ProtobufMessage::getStrictValidationVisitor(), factory); { - auto input = factory.createGenericDataInput(*message, context); + auto input = factory.createCommonProtocolInput(*message, context); EXPECT_NE(nullptr, input); EXPECT_EQ(input->get(), absl::nullopt); } TestEnvironment::setEnvVar("foo", "bar", 1); { - auto input = factory.createGenericDataInput(*message, context); + auto input = factory.createCommonProtocolInput(*message, context); EXPECT_NE(nullptr, input); EXPECT_EQ(input->get(), absl::make_optional("bar")); } @@ -47,7 +47,7 @@ TEST(ConfigTest, TestConfig) { } } // namespace EnvironmentVariable -} // namespace GenericInputs +} // namespace CommonInputs } // namespace Matching } // namespace Extensions } // namespace Envoy diff --git a/test/extensions/matching/generic_inputs/environment_variable/input_test.cc b/test/extensions/matching/common_inputs/environment_variable/input_test.cc similarity index 78% rename from test/extensions/matching/generic_inputs/environment_variable/input_test.cc rename to test/extensions/matching/common_inputs/environment_variable/input_test.cc index 41c7bd63e037..7c0bcc9768c1 100644 --- a/test/extensions/matching/generic_inputs/environment_variable/input_test.cc +++ b/test/extensions/matching/common_inputs/environment_variable/input_test.cc @@ -1,11 +1,11 @@ -#include "extensions/matching/generic_inputs/environment_variable/input.h" +#include "extensions/matching/common_inputs/environment_variable/input.h" #include "gtest/gtest.h" namespace Envoy { namespace Extensions { namespace Matching { -namespace GenericInputs { +namespace CommonInputs { namespace EnvironmentVariable { TEST(InputTest, BasicUsage) { @@ -20,7 +20,7 @@ TEST(InputTest, BasicUsage) { EXPECT_EQ(input.get().value(), "foo"); } } // namespace EnvironmentVariable -} // namespace GenericInputs +} // namespace CommonInputs } // namespace Matching } // namespace Extensions } // namespace Envoy From fde8b7b989eb7980bc0b91fa5da31e6c09896162 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Thu, 18 Mar 2021 14:00:37 +0000 Subject: [PATCH 13/15] fix v4 Signed-off-by: Snow Pettersen --- api/envoy/config/common/matcher/v4alpha/matcher.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/envoy/config/common/matcher/v4alpha/matcher.proto b/api/envoy/config/common/matcher/v4alpha/matcher.proto index 45a1e020751d..7747157a24dc 100644 --- a/api/envoy/config/common/matcher/v4alpha/matcher.proto +++ b/api/envoy/config/common/matcher/v4alpha/matcher.proto @@ -66,7 +66,7 @@ message Matcher { "envoy.config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate"; // Protocol-specific specification of input field to match on. - // [#extension-category: envoy.matching.common-inputs] + // [#extension-category: envoy.matching.common_inputs] core.v4alpha.TypedExtensionConfig input = 1 [(validate.rules).message = {required: true}]; oneof matcher { From 2a0ea2f8fd11eb266e0c9fbb243ff84ca61e89c2 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Fri, 19 Mar 2021 12:56:55 +0000 Subject: [PATCH 14/15] fix tests Signed-off-by: Snow Pettersen --- test/common/matcher/matcher_test.cc | 2 +- test/common/matcher/test_utility.h | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/common/matcher/matcher_test.cc b/test/common/matcher/matcher_test.cc index f5441864141e..2f6125e04d85 100644 --- a/test/common/matcher/matcher_test.cc +++ b/test/common/matcher/matcher_test.cc @@ -101,7 +101,7 @@ TEST_F(MatcherTest, CustomGenericInput) { TestUtility::validate(matcher); MatchTreeFactory factory(factory_context_); - auto generic_factory = TestGenericDataInputFactory("generic", "foo"); + auto common_input_factory = TestCommonProtocolInputFactory("generic", "foo"); auto match_tree = factory.create(matcher); const auto result = match_tree->match(TestData()); diff --git a/test/common/matcher/test_utility.h b/test/common/matcher/test_utility.h index 64ad1f5f3631..76cccbe548f9 100644 --- a/test/common/matcher/test_utility.h +++ b/test/common/matcher/test_utility.h @@ -16,21 +16,22 @@ struct TestData { static absl::string_view name() { return "test"; } }; -// A DataInput that returns the configured value every time. -struct GenericTestInput : public GenericDataInput { - explicit GenericTestInput(const std::string& data) : data_(data) {} +// A CommonProtocolInput that returns the configured value every time. +struct CommonProtocolTestInput : public CommonProtocolInput { + explicit CommonProtocolTestInput(const std::string& data) : data_(data) {} absl::optional get() override { return data_; } const std::string data_; }; -class TestGenericDataInputFactory : public GenericDataInputFactory { +class TestCommonProtocolInputFactory : public CommonProtocolInputFactory { public: - TestGenericDataInputFactory(absl::string_view factory_name, absl::string_view data) + TestCommonProtocolInputFactory(absl::string_view factory_name, absl::string_view data) : factory_name_(std::string(factory_name)), value_(std::string(data)), injection_(*this) {} - GenericDataInputPtr createGenericDataInput(const Protobuf::Message&, - Server::Configuration::FactoryContext&) override { - return std::make_unique(value_); + CommonProtocolInputPtr + createCommonProtocolInput(const Protobuf::Message&, + Server::Configuration::FactoryContext&) override { + return std::make_unique(value_); } ProtobufTypes::MessagePtr createEmptyConfigProto() override { @@ -41,7 +42,7 @@ class TestGenericDataInputFactory : public GenericDataInputFactory { private: const std::string factory_name_; const std::string value_; - Registry::InjectFactory injection_; + Registry::InjectFactory injection_; }; // A DataInput that returns the configured value every time. From 8df489f2ce544231ff39f820ee2fd71fa68ab3e8 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Wed, 31 Mar 2021 19:22:22 +0000 Subject: [PATCH 15/15] add newlines Signed-off-by: Snow Pettersen --- .../matching/common_inputs/environment_variable/config.cc | 2 +- .../matching/common_inputs/environment_variable/config.h | 2 +- .../matching/common_inputs/environment_variable/input.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/extensions/matching/common_inputs/environment_variable/config.cc b/source/extensions/matching/common_inputs/environment_variable/config.cc index 494cda285ea5..a7716e0b0748 100644 --- a/source/extensions/matching/common_inputs/environment_variable/config.cc +++ b/source/extensions/matching/common_inputs/environment_variable/config.cc @@ -36,4 +36,4 @@ REGISTER_FACTORY(Config, Envoy::Matcher::CommonProtocolInputFactory); } // namespace CommonInputs } // namespace Matching } // namespace Extensions -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/source/extensions/matching/common_inputs/environment_variable/config.h b/source/extensions/matching/common_inputs/environment_variable/config.h index 1585d69b0000..a583785a3101 100644 --- a/source/extensions/matching/common_inputs/environment_variable/config.h +++ b/source/extensions/matching/common_inputs/environment_variable/config.h @@ -32,4 +32,4 @@ class Config : public Envoy::Matcher::CommonProtocolInputFactory { } // namespace CommonInputs } // namespace Matching } // namespace Extensions -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/source/extensions/matching/common_inputs/environment_variable/input.h b/source/extensions/matching/common_inputs/environment_variable/input.h index 53bf8e297ead..240869d9c9d0 100644 --- a/source/extensions/matching/common_inputs/environment_variable/input.h +++ b/source/extensions/matching/common_inputs/environment_variable/input.h @@ -21,4 +21,4 @@ class Input : public Matcher::CommonProtocolInput { } // namespace CommonInputs } // namespace Matching } // namespace Extensions -} // namespace Envoy \ No newline at end of file +} // namespace Envoy