Skip to content

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

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

a-hilaly
Copy link
Member

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]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from jlbutler and jljaco January 10, 2024 17:14
@ack-prow ack-prow bot added the approved label Jan 10, 2024
@a-hilaly a-hilaly force-pushed the gotag-config branch 2 times, most recently from 359c560 to 143e03b Compare January 10, 2024 17:16
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]>
@a-hilaly
Copy link
Member Author

/hold

@ack-prow ack-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 10, 2024
Copy link

@jonathan-innis jonathan-innis left a comment

Choose a reason for hiding this comment

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

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 10, 2024
Copy link

ack-prow bot commented Jan 10, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@a-hilaly
Copy link
Member Author

/retest

@a-hilaly
Copy link
Member Author

experiencing some etcd timeouts with the ec2-controller, restarting to see if it's consistent
/test ec2-controller-test

@a-hilaly
Copy link
Member Author

/unhold

@ack-prow ack-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 10, 2024
@ack-prow ack-prow bot merged commit 3753ca3 into aws-controllers-k8s:main Jan 10, 2024
@a-hilaly
Copy link
Member Author

/test all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants