-
Notifications
You must be signed in to change notification settings - Fork 98
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
Add matches filter #447
Add matches filter #447
Conversation
8ef0f9f
to
ac6d900
Compare
975c909
to
a6f0e63
Compare
I've updated the tests, and add one new feature to the I've not added a test for the |
b36acbe
to
c5f4bbe
Compare
config.ok_or_else(|| Error::MissingConfig(self.name())) | ||
} | ||
} | ||
|
||
/// Arguments needed to create a new filter. | ||
pub struct CreateFilterArgs<'a> { | ||
pub struct CreateFilterArgs { |
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.
Let's call out in the PR description that is a breaking change, so its visible in the release docs
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've added the label, which I believe is what @markmandel is using.
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.
Yeah we need the label too! What I meant was in this case the label isn't enough since the breakage isn't obvious at all from the PR - usually with a release folks will go through the breaking PRs (which is where the label comes in) and it should be clear what broke. Here that won't be possible at all without reading the code which would be harsh, so let's mention that this PR does in fact contain a breaking change since adding a Matches filter isn't breaking in itself.
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.
Yes please - add a note about this in the description, so when i write the release notes I won't forget 👍🏻
/// The filter specified in `filter` will be called. | ||
Filter { | ||
filter: String, | ||
config: Option<ConfigType>, |
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 think this can be Option<serde_yaml::Value> rather than a full config type or? since this is only used for the yaml config? in which case it probably allows us to avoid the custom serde we have for fallthrough? (same for Branch)
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.
It is needed since someone can send a Fallthrough::Filter
through xDS/protobuf, not just in the static configuration
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.
Ah so iiuc its not necessarily it being used through xds but rather that to use deserialize we need to be able to convert from proto to yaml and there isn't a reasonable way to do that for the transparent filter config field? We don't have to use deserialize
since its only a helper function, we can call the convert function ourselves and instantiate the filter i.e
fn create_filter(&self, args: CreateFilterArgs) -> Result<FilterInstance, Error> {
let (config_json, on_read, on_write) = match args {
ConfigType::Static(config) => {
// Instantiate sub filters from static config
},
ConfigType::Dynamic(config) => {
// Instantiate sub filters from dynamic config
}
}
let filter = Matches::new(on_read, on_write)?;
Ok(FilterInstance::new(
config_json,
Box::new(filter) as Box<dyn Filter>,
))
}
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.
Sure, though I'm not sure what that provides over the current approach.
f38d9d7
to
a0debc8
Compare
docs/src/filters/matches.md
Outdated
|
||
View the [Matches](./matches.md) filter documentation for more details. | ||
|
||
### [Configuration Options](../../api/quilkin/filters/matches/struct.Config.html) |
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.
Let's add the documentation like we have it currently for filters. It means for users that don't know Rust they have to work it out from the Rust code.
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.
How are you generating that? Is there a specific format I should be following?
on_read: | ||
metadataKey: myapp.com/token | ||
branches: | ||
- value: abc |
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.
From digging into the code, value
can't be a base64 byte array, correct? It has be one of the Value
types such as String or Int? (bool?). This makes sense, since the dynamic metadata could come from anywhere, and as such, should be a Value
.
(Just making sure my understanding is correct).
If so, we might want to make that extra clear in the documentation.
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.
Yes, it's not base64, it's a string.
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.
nods that makes total sense -- I think we should be clear in that in the docs with a comment somewhere, as I could see people assuming it was a byte array and attempting to fill it as such.
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.
Well I mean it should be documented but that's also valid to do that. That's why the PartialEq
of Value
compares the value between strings and bytes, so that you can set a string here and use it to match the bytes, since a lot of marker values in my experience are at least string friendly if not human-readable.
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.
100% agree.
config.ok_or_else(|| Error::MissingConfig(self.name())) | ||
} | ||
} | ||
|
||
/// Arguments needed to create a new filter. | ||
pub struct CreateFilterArgs<'a> { | ||
pub struct CreateFilterArgs { |
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.
Yes please - add a note about this in the description, so when i write the release notes I won't forget 👍🏻
a0debc8
to
07cdba6
Compare
@markmandel Now with #478, do we want to merge this in, and I can add the configuration schema in that? |
Co-authored-by: Ifeanyi Ubah <ifeanyi.ubah@embark-studios.com>
Co-authored-by: Ifeanyi Ubah <ifeanyi.ubah@embark-studios.com>
Co-authored-by: Ifeanyi Ubah <ifeanyi.ubah@embark-studios.com>
07cdba6
to
31df6c7
Compare
I like it! Also good to get this in for 0.3.0 👍🏻 |
Build Succeeded 🥳 Build Id: 76e917c6-c950-4a53-bc44-9683c1dc1b84 To build this version:
|
Adds a minimal version of the quilkin matches filter discussed in #401.
I believe closes #401, #412
Breaking Changes
ConfigType::Static
now acceptsserde_yaml::Value
by value instead of by reference.