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

Use only int64 and float64 #63

Closed
wants to merge 5 commits into from
Closed

Use only int64 and float64 #63

wants to merge 5 commits into from

Conversation

mmorel-35
Copy link
Contributor

Fixes #54

@mmorel-35 mmorel-35 requested a review from a team as a code owner May 13, 2021 10:02
@mmorel-35 mmorel-35 marked this pull request as draft May 13, 2021 10:13
@mmorel-35 mmorel-35 changed the title Use only int64 instead of int or float64 Use only int64 and float64 May 13, 2021
@mmorel-35 mmorel-35 marked this pull request as ready for review May 13, 2021 10:28
@mmorel-35
Copy link
Contributor Author

mmorel-35 commented May 13, 2021

I have used float on createdAt and updatedAt because of this : https://github.com/Kong/go-kong/runs/2574465387?check_suite_focus=true#step:7:279

Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

Looks good, please however:

  • see the comment Feature Request: Controller-Gen Compatibility #54 (comment) - it doesn't affect the code of this PR, just FYI
  • see the action required (in the attached comment)
  • be advised that I'm checking with maintainers of Kong Gateway that the created_at change from int to float is appropriate.

Comment on lines +18 to +20
linters-settings:
lll:
line-length: 150
Copy link
Contributor

Choose a reason for hiding this comment

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

lll has 120 as the default and this is what we have configured in other repos. Why do you want to change that?

Suggestion: remove the customization (leave the default) and wrap all changed lines that require it.

Sources []*CIDRPort `json:"sources,omitempty" yaml:"sources,omitempty"`
Destinations []*CIDRPort `json:"destinations,omitempty" yaml:"destinations,omitempty"`
Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty"`
HTTPSRedirectStatusCode *int64 `json:"https_redirect_status_code,omitempty" yaml:"https_redirect_status_code,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mflendrich, this line is the reason why I changed lll parameters.
I can't find a way to resize it beneath 121 characters with int it's fine but with int64, it isn't

Copy link
Contributor

Choose a reason for hiding this comment

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

golangci supports per-file exemptions, which would be appropriate here. go-kong doesn't currently have any, but deck does: https://github.com/Kong/kong/blob/master/kong.conf.default#L98-L126 is an example for this rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure of your link ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@rainest
Copy link
Contributor

rainest commented May 13, 2021

I don't think this fixes the issue. kubernetes-sigs/controller-tools#245 and the controller-gen source indicates that float64 isn't any permissible than float. The restriction exists because float conversions are inconsistent in and out of strings in JSON, not because of a need to support large or higher-precision values.

We'd approached this before in #17, which moves to a string-backed type, but decided against it because it's a breaking change in go-kong and allowDangerousTypes is available for KIC. The dangerous conversion should be minimal impact, since the problem fields are things we ignore in practice (created/updated at timestamps) or values where precision weirdness is probably low impact (health thresholds).

@mmorel-35
Copy link
Contributor Author

mmorel-35 commented May 13, 2021

OK, shall we drop the PR so ?

@rainest
Copy link
Contributor

rainest commented May 13, 2021

Yeah--wouldn't help the issue with controller-gen and we don't have other reasons to modify the types.

FWIW, the odd-looking discrepancy in the timestamp types is intentional. Kong actually defines both integer and float timestamp types, though only targets use the float variant.

@rainest rainest closed this May 13, 2021
@mmorel-35 mmorel-35 deleted the feature/controller-gen-compat branch May 13, 2021 18:03
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.

Feature Request: Controller-Gen Compatibility
3 participants