-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matching: add support for generic inputs and add environment variable input #15410
Conversation
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
// [#extension: envoy.matching.generic_inputs.environment] | ||
|
||
// Reads an environment variable to provide an input for matching. | ||
message Environment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment
sounds ambiguous, something more descriptive, perhaps EnvironmentVariable
, would be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea agreed, will update
Could you add some docs/examples demonstrating how this |
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly curious what you think: if this side-effect was moved out of the constructor (into the factory perhaps?), this class would become a trivial wrapper around absl::optional<std::string>
. This would make tests simpler, I think: GenericTestInput
wouldn't be needed, and TestGenericDataInputFactory
would only need to overload the method that retrieves env var with one that returns something expected in the test. Even though getenv() is pretty benign, side-effects in constructors always catch my attention...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that, let me give that a go!
Looks good, other than a small nits re: naming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm api
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
/retest |
Retrying Azure Pipelines: |
lgtm, not sure why precheck docs is failing; perhaps try merging in the latest from the main branch? |
@dmitri-d the doc fails because:
|
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm api
can you check CI?
Signed-off-by: Snow Pettersen <[email protected]>
This should be ready for another pass |
@htuch @mattklein123 either of you want to review this? |
Sure I can take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
this needs to merge main - it would fail linting on postsubmit if merged as is /wait |
Signed-off-by: Snow Pettersen <[email protected]>
Signed-off-by: Snow Pettersen <[email protected]>
Adds support for a "generic input" extension point that allows specifying inputs that are not dependent on protocol data.
Adds an environment variable generic input that allows matching on the value of an environment variable.
Risk Level: Medium
Testing: UTs for extension and generic input creation
Docs Changes: n/a
Release Notes:
Platform Specific Features:
Fixes #14781