-
Notifications
You must be signed in to change notification settings - Fork 3
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
Modularize and add validation #22
Conversation
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.
Generally looks fine to me.
This PR does multiple things at the same time. Please try to scope PRs to a single thing in the future.
Some more comments would be welcome too. You'll make the lives your future self, the rest of the team and open source contributors a lot easier.
build: extensions | ||
CGO_ENABLED=0 go build -ldflags "-w -s" -o dist/protoc-gen-fieldmask-$(shell go env GOOS)-$(shell go env GOARCH)$(shell go env GOEXE) . | ||
build: | ||
CGO_ENABLED=0 go build -ldflags "-w -s" -o dist/protoc-gen-fieldmask . |
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 would keep the suffix
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's unnecessary complexity.
We're going to make releases with goreleaser
if we need them.
This make target is only useful for development and in that case the GOOS
and GOARCH
are always known by the caller.
Here's how the generated code looks like for |
ae22044
to
c790ac2
Compare
c790ac2
to
8f13f5e
Compare
4ea3051
to
08e7415
Compare
71fb4ce
to
2d5c8f7
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.
Code looks quite good. Also checked the generated validators.
I have a question with the error handling in the code generated by protoc-gen-validate.
if !_ApplicationIdentifiers_ApplicationID_Pattern.MatchString(m.GetApplicationID()) {
return ApplicationIdentifiersValidationError{
field: "ApplicationID",
reason: "value does not match regex pattern \"^[a-z0-9](?:[-]?[a-z0-9]){2,}$\"",
}
}
Two questions:
- Does this output the Go generated fieldname and not the proto name (ex: application_id)?
That is undesirable since we want to return theproto
names to the caller. - Does it output the full path of the error(ex: end_device_ids.application_ids.application_id)?
2d5c8f7
to
8eec7ff
Compare
|
Summary:
Closes #21
Closes #18
References TheThingsNetwork/lorawan-stack#51
Changes:
protoc-gen-star
dep
dependencyprotoc
from environment by default, not Docker imageNotes for Reviewers:
This PR uses forks of both https://github.com/lyft/protoc-gen-star (it uses features in lyft/protoc-gen-star#51) and https://github.com/lyft/protoc-gen-validate(minor changes there to improve GoGo support and use fieldpaths)
I forked
protoc-gen-validate
, since only minor changes are necessary to make it work with fieldpaths(TheThingsIndustries/protoc-gen-validate@0e040cd), however we do not need to maintain any validators and we're fully compatible with the upstream plugin.cc @KrishnaIyer