-
Notifications
You must be signed in to change notification settings - Fork 583
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
gogo support #66
gogo support #66
Conversation
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Partially addresses #52 |
@rodaine I want to hear your thoughts how best to structure this. I can fix the build once we agree how to get this started. |
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 awesome! Can we also add docs to identify support as well as what features of gogo's annotations will work (or more specifically which ones won't)?
templates/go/duration.go
Outdated
if err != nil { return {{ errCause . "err" "value is not a valid duration" }} } | ||
{{ end }} | ||
{{ end }} | ||
{{ else }} |
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.
Instead of these big conditionals, how about we move the shared templates into something like goshared
and have separate templates for where the two targets diverge? So everything but duration
, time
, and file
(or perhaps just a preamble
) are shared. Does that make sense?
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.
Done
tests/kitchensink/gogo/any.pb.go
Outdated
@@ -0,0 +1,490 @@ | |||
// Code generated by protoc-gen-gogo. |
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 exclude the test gen'd 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.
Done
tests/kitchensink/duration.proto
Outdated
google.protobuf.Duration gogo1 = 17 [(validate.rules).duration.lt = {seconds: 5}, (gogoproto.stdduration) = true]; | ||
google.protobuf.Duration gogo2 = 18 [(validate.rules).duration.lt = {seconds: 5}, (gogoproto.nullable) = false]; | ||
google.protobuf.Duration gogo3 = 19 [(validate.rules).duration.lt = {seconds: 5}, (gogoproto.stdduration) = true, (gogoproto.nullable) = false]; | ||
google.protobuf.Duration gogo4 = 20 [(validate.rules).duration.required = true, (gogoproto.nullable) = false]; |
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.
Can these have more descriptive names? Makes it easier to debug when looking at the generator output.
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.
Done
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Thanks @rodaine. Can you help me bring in gogo protoc plugin into the CI docker image? |
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Build fixed! |
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
PTAL, added docs and separate templates into go/gogo as requested. |
templates/gogo/duration.go
Outdated
|
||
{{ template "durationcmp" . }} | ||
} | ||
{{ end }} |
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.
The nesting here is difficult to follow. We run gofmt against generated code, so you should just structure the template for readability and let the formatter fix it in the final output.
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.
Likewise for timestamp
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, responded.
Signed-off-by: Kuat Yessenov <[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.
Thanks for getting this through!
This is a working prototype for implementing constraints for gogo-generated protobufs.
This is sufficient for handling envoyproxy/data-plane-api:
Signed-off-by: Kuat Yessenov [email protected]