-
Notifications
You must be signed in to change notification settings - Fork 578
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
Feature/add optional support #537
Feature/add optional support #537
Conversation
Signed-off-by: Sarthak Gupta <signed@sarthak.sh>
Looks like you're running afoul of the DCO. See https://github.com/envoyproxy/envoy/blob/main/CONTRIBUTING.md#fixing-dco |
The build action runs with Bazel, which uses a separate dependencies list than the Go build. Can you update the PGS dep here? |
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
b5a644a
to
e736bcf
Compare
@akonradi got it! updated the PR. thanks for the rapid response :) |
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
52068ad
to
ef139b2
Compare
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.
This is definitely going to need some tests.
{{ range .OneOfs }} | ||
{{ range .RealOneOfs }} |
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.
Is this going to cause problems for messages with optional fields with validations?
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.
generating gofiles with a message like this works just fine now.
message AddEntityEntitlementRequest {
optional string name= 1 [(validate.rules).string = {
pattern: "^[^[0-9]A-Za-z]+( [^[0-9]A-Za-z]+)*$",
max_bytes: 256,
}]; /** name */
}
the regex fails when expected and if no value is provided, no error is thrown, since it's marked as optional.
I don't know the ins and outs of generation, especially since that piece comes from the original PR, so I'm not sure what the halo effect is like with this change.
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
f9188cf
to
ad94922
Compare
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
ad94922
to
af6f8b4
Compare
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
5dd0a3a
to
c6772be
Compare
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
…ency Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
@akonradi I go things working for golang, but the java version seems to have some sort of dependency mismatch. There's an error, but that's not expected on the more recent version of protobuf that the golang library is correctly depending on. I don't have any maven or bazel experience, and I'm struggling to find where the issue is. Any help here is appreciated. |
@rmichela, if you have a chance to take a look? |
I figured out what was going on. The Java protobuf and grpc dependencies were for versions that predated proto optional fields. I updated the dependencies in #545, which will need to be merged before this PR will compile. |
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
5852f78
to
2f52871
Compare
Any update here? ✌️ |
is this awaiting final review? @rodaine would you know who can approve this? |
✌️ |
When will this feature be merged in? @akonradi |
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.
Thanks for the hard work on this issue, and your patience on the review. Once the test cases are added, we can go ahead and merge this.
tests/harness/cases/optional.proto
Outdated
} | ||
|
||
message MessageRequiredButOptional { optional TestOptionalMsg val = 1 [(validate.rules).message.required = true]; } | ||
message Int64LTEOptional { optional int64 val = 1 [(validate.rules).int64.lte = 64]; } |
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.
Please add some test cases to the executor, otherwise this won't actually test the behavior of these: https://github.com/envoyproxy/protoc-gen-validate/blob/main/tests/harness/executor/cases.go
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 moved the tests to existing proto files since creating new ones resulted in a level of complexity i didn't want to deal with.
cd3e7a6
to
43718f8
Compare
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
43718f8
to
c5b310d
Compare
tests passed! 🎉 |
Signed-off-by: Mitchell Bundy <mitchell.bundy@unity3d.com>
Awesome job! Thank you for all the hard work to get this over the finish line 😁 |
1) Fix regression from #529. The code needs to handle enums at file scope and in a message. At the same time also handle arbitrary nesting. 2) Fix regression from #537 when dealing with single element string oneofs (and possibly other types being returned as pointer types vs. value types and breaking in queries. This fixes that for both C++ and Go. It's possible this fix shoudl be in PG* but doing it here for simplicity. 3) Modify the C++ validator registry to have polymorphic lookup capability which I want to use in Envoy. Signed-off-by: Matt Klein <mklein@lyft.com>
* Various small fixes 1) Fix regression from #529. The code needs to handle enums at file scope and in a message. At the same time also handle arbitrary nesting. 2) Fix regression from #537 when dealing with single element string oneofs (and possibly other types being returned as pointer types vs. value types and breaking in queries. This fixes that for both C++ and Go. It's possible this fix shoudl be in PG* but doing it here for simplicity. 3) Modify the C++ validator registry to have polymorphic lookup capability which I want to use in Envoy. Signed-off-by: Matt Klein <mklein@lyft.com> * fix Signed-off-by: Matt Klein <mklein@lyft.com> * fix Signed-off-by: Matt Klein <mklein@lyft.com>
closes #431
spin off of #474