Skip to content
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

Make Ansible Operator parameter case conversion optional #3245

Merged

Conversation

fabianvf
Copy link
Member

Description of the change:
Adds the snakeCaseParameters (default true) parameter to the watches.yaml, which disables the camelCase -> snake_case conversion

Motivation for the change:
For some users this causes more problems than it solves, and it definitely should be optional.

Closes #1770

Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

SGTM

@fabianvf Does this warrant a line in the CHANGELOG? Seems more like a feature than a bugfix.

@fabianvf
Copy link
Member Author

@hasbro17 good call, added changelog fragment

Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

Not sure if the CI failure is related, but LGTM on the docs and CHANGELOG fragment.

@tengqm
Copy link
Contributor

tengqm commented Jun 25, 2020

/lgtm

@openshift-ci-robot
Copy link

@tengqm: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 25, 2020
@fabianvf fabianvf force-pushed the ansible-snake-case-optional branch from de14936 to a752cdf Compare June 25, 2020 16:29
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 25, 2020
@fabianvf fabianvf force-pushed the ansible-snake-case-optional branch 2 times, most recently from 627fe96 to 1dae72e Compare July 2, 2020 16:43
@@ -54,6 +54,7 @@ type Watch struct {
WatchDependentResources bool `yaml:"watchDependentResources"`
WatchClusterScopedResources bool `yaml:"watchClusterScopedResources"`
Selector metav1.LabelSelector `yaml:"selector"`
SnakeCaseParameters bool `yaml:"snakeCaseParameters"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The issue faced in the lint is maligned. To solve it you can just keep the bools at the ends. Move the Selector before of them.


To know more about it see: https://medium.com/@sebassegros/golang-dealing-with-maligned-structs-9b77bacf4b97
Running golangci-lint
pkg/ansible/watches/watches.go:44:12: struct of size 200 bytes could be of size 192 bytes (maligned)
type Watch struct {
           ^
Makefile:89: recipe for target 'lint' failed
make: *** [lint] Error 1
The command "make test-sanity" exited with 2.
cache.2
store build cache

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm speechless at this lint check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@camilamacedo86 Thanks for the pointer. I didn't realize that Go is so hypercritical and nitpicking ... and I'm not sure if it is always a good thing. But anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarifies, the maligned is a lint check. It checks the usage of memory space of a structure and alert when we are using more spaces than required. Why it would be a bad thing at all?

However, in the cases that we decide to prioritize the code understatement instead of it, we can just say for the lint ignore the specific check in the specific place by using // nolint:maligned

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is always the right thing to do, the compiler should do this byte alignment transparently rather than forcing the developer to think about these details. There are other cases I want to order my fields for different purposes, e.g. semantic grouping, deriving Web UI for an input struct etc.

@camilamacedo86
Copy link
Contributor

HI @fabianvf,

it shows ok to go forward, just missing rebase. 👍 great work btw

@fabianvf fabianvf force-pushed the ansible-snake-case-optional branch from 6aef654 to 44e8c3b Compare July 13, 2020 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ansible] CR variables converted to snake_case when passed to playbook
5 participants