-
Notifications
You must be signed in to change notification settings - Fork 204
Introducing a generator configuration for GoTag customization #485
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
Conversation
359c560
to
143e03b
Compare
This patch introduces a new configuration, `go_tag`, to allow ACK developers to customize the "Go tags" in the generated structures. With this configuration users can easily override the default Go tags, making adjustements like changing the tag name, adding omitempty directives or even introducing new ones (yaml, gorm, protobuf etc). This change helps ACK users overcome the challenge imposed by our names utility package (`aws-controllers-k8s/pkg/names/`) which adds an underscore suffix to field names that matches Golang keywords. Resulting in an odd UX when consuming the generated ACK CRDs (e.g using `type_: <...>` instead of `type: <...>`) We purposefully avoided directly modifying the `names` utility package (trimming the underscores when generating the go tags) as it will break compatibility with the already existing CRDs (yep we missed this). Without some sort of mutating webhooks that will handle field renames, we'll avoid going that route, and instead start using `go_tag` configs for future CRDs/fields. This patch will help in tweaking the generated code for aws-controllers-k8s/eks-controller#84 Signed-off-by: Amine Hilaly <[email protected]>
143e03b
to
f108e30
Compare
/hold |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a-hilaly, acornett21, jonathan-innis The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
experiencing some etcd timeouts with the ec2-controller, restarting to see if it's consistent |
/unhold |
/test all |
This patch introduces a new configuration,
go_tag
, to allow ACKdevelopers to customize the "Go tags" in the generated structures.
With this configuration users can easily override the default Go tags,
making adjustements like changing the tag name, adding omitempty
directives or even introducing new ones (yaml, gorm, protobuf etc).
This change helps ACK users overcome the challenge imposed by our names
utility package (
aws-controllers-k8s/pkg/names/
) which adds anunderscore suffix to field names that matches Golang keywords. Resulting
in an odd UX when consuming the generated ACK CRDs (e.g using
type_: <...>
instead oftype: <...>
)We purposefully avoided directly modifying the
names
utility package(trimming the underscores when generating the go tags) as it will break
compatibility with the already existing CRDs (yep we missed this).
Without some sort of mutating webhooks that will handle field renames,
we'll avoid going that route, and instead start using
go_tag
configsfor future CRDs/fields.
This patch will help in tweaking the generated code for
aws-controllers-k8s/eks-controller#84
Signed-off-by: Amine Hilaly [email protected]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.