Skip to content
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 pattern to string.proto #40

Closed
wants to merge 6 commits into from
Closed

Conversation

silverstar194
Copy link

No description provided.

//
// Examples:
//
// abc/{lang}/{county} matches the value abc/us/eng
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the semantics of a "pattern"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.
Can you clarify where lang/county categories and their possible values are defined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added clarify in comments/code above

@adisuissa
Copy link

cc @adisuissa

Signed-off-by: silverstar195 <seanmaloney@google.com>
Signed-off-by: silverstar195 <seanmaloney@google.com>
Signed-off-by: silverstar195 <seanmaloney@google.com>
Signed-off-by: silverstar195 <seanmaloney@google.com>
// abc/{lang}/{county} matches the value abc/eng/us
// Note format of: abs/<user-defined-var>/<user-defined-var>
// {lang} == "eng" and {country} == "us"
string pattern = 8 [(validate.rules).string = {min_len: 1}];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I think I'm missing something.
Is the idea to match a string given some pattern, and assign the values to their variables (e.g., lang will be "eng"), or are there known categories and known possible values for these categories, and a match will occur if the used values are in the categories.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The will be matched and assigned to variables. No know categories.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would the string "abcdef" match against pattern="abc{first}{second}", as the possible assignments are possible:
first="de", second="f"
first="d", second="ef"
?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not be a valid config. Only items between "/"s are used as vars.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting use-case, and I'm not sure if it should be specified as part of the StringMatcher (the StringMatcher just matches according to some pattern, and doesn't assign values to external variables).

@snowp was this kind of use-case ever considered?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type of matching seems very specific to path matching, but StringMatcher can be used for things other than paths, so I'm not sure this is really the right place for this. I think it would make more sense to create a new matcher for this purpose.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be used in any context where simplified wildcard matching based on a delimiter is needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the delimiter is fixed to slash, and only wildcards or strings w/o wildcards are allowed in between.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with expanding the / to be generalized. There is a lot of value here by providing simplified regex style matches.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that even with making this more generalized, it still seems to be a fairly special case. I think it makes more sense for this to be a separate matcher, just like RegexMatcher is.

Signed-off-by: Sean Maloney <seanmaloney@google.com>
//
// Examples:
//
// abc/*/* matches the value abc/eng/us

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each example should be in bullet (line prefix with *). Also each of the actual pattern/value should be italic (reference). See rendered output of previous docs: https://www.envoyproxy.io/docs/envoy/latest/api-v3/type/matcher/v3/string.proto

Unfortunately I don't think the cncf repo runs the docs rendering script in a PR. @phlax is this correct? How do we make sure these docs are rendered well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

envoy pulls in the xds protos as a dep so when the dep is updated the newer protos are rendered

if you need to test a PR ahead of this you can create a PR in envoy and point the dep at the PR (commit hash for PR mostly will work as release version in bazel/repository_locations.bzl)

Comment on lines 68 to 69
// Note format of: abs/<wildcard-1>/<wildcard-2>
// {wildcard-1} == "eng" and {wildcard-2} == "us"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that wildcard-1/2 makes this more confusing, as the matcher only matches the entries.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

// Note format of: abs/<wildcard-1>/<wildcard-2>
// {wildcard-1} == "eng" and {wildcard-2} == "us"
//
// abc/foo matches the value abc/foo

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Signed-off-by: Sean Maloney <seanmaloney@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants