-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Fixes Golint Errors: staging/src/k8s.io/kube-aggregator #73369
Fixes Golint Errors: staging/src/k8s.io/kube-aggregator #73369
Conversation
Hi @eloyekunle. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/assign @lavalamp |
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.
@eloyekunle thank you for the PR.
please squash the commits into one.
/priority backlog
/kind cleanup
07978fb
to
f3c092b
Compare
Hi @neolit123 |
/ok-to-test |
5ad37e2
to
000ceb6
Compare
please pass tests |
e64fd8e
to
b92dba9
Compare
@fejta I don't know why the |
/retest |
@fejta @neolit123 |
f655570
to
342dfc3
Compare
// unconditionally (irrespective of the latest resource version), when | ||
// there is no resource version specified in the object. | ||
AllowUnconditionalUpdate() bool | ||
} |
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.
can one test that it is complete?
var _ RESTUpdateStrategy = nil.(RESTCreateUpdateStrategy)
Is that valid code?
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.
Yes, one can test with:
var _ RESTCreateStrategy = (RESTCreateUpdateStrategy)(nil)
I've added the tests.
@@ -0,0 +1,46 @@ | |||
/* | |||
Copyright 2014 The Kubernetes Authors. |
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.
2019
Some last nit, then lgtm. |
342dfc3
to
833a300
Compare
@sttts |
@@ -0,0 +1,52 @@ | |||
/* |
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.
nit: could you name this file create_update.go
(underscore) instead of the hyphen?
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.
Hi @rajathagasthya
I've updated the file name.
7cddc77
to
c174300
Compare
// for cases where you want to auto-register APIs like TPRs or groups from the core kube-apiserver | ||
type autoRegisterController struct { | ||
type Controller struct { |
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.
we shouldn't export this type just to make lint happy
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.
Across the codebase, most controllers similar to this are exported.
For example:
- APIServiceRegistrationController.
- CertificateController
- AutoRegisterController
- AvailableConditionController
- CloudNodeController
and many others are exported, and they all have 'getters', similar to this one (i.e. NewControllerName
) returning the exported controller.
Is there another way to satisfy Golint, or will I have to leave this package in .golint_failures
?
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.
@liggitt I agree with @eloyekunle. Let's not block this by making Controller public. We need a better golint exception mechanism.
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 agree with @eloyekunle. Let's not block this by making Controller public
not sure if you are suggesting keeping this package in .golint_failures or making Controller public. I'd prefer not to export just to make golint happy, but I don't feel that strongly
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.
Jordan, why is it important for this to stay private?
Automated systems like this and gofmt don't always produce the ideal decision at the micro level (maybe you hate tabs, or disagree with lint's exported type directives), but at the macro level the value of providing consistent expectations makes it easier for large teams to collaborate on large code bases.
Removing this package from .golint_failures is useful for two reasons:
- It ensures no other, potentially more useful failures, get checked into this package.
- A shorter .golint_failure exception lint makes it more likely other packages will fix their lint errors rather than being one of the few special-cased packages.
IMO it is generally an unproductive use of time to try and fight the linting system (but maybe this is an exceptional circumstance?)
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.
why is it important for this to stay private?
this is a package in an exported repo, so making the controller class public implies it is a suitable API for other projects to depend on. I don't think its structure has been considered in that light, so simply making it public to pass a linting check seems subpar
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.
Jordan, is this the only controversial part about the PR?
Elijah, if so how would you feel about removing this part from this PR. This will expedite removing most of the lint errors.
If you're up for it, I'd suggest creating a second PR with just the autoRegisterController change (and removing the lint exception). We can continue the discussion there.
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.
yes, everything else looked fine to me
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.
Sounds good, I've removed this part from the PR. The controller is now unexported.
one comment on exported type, lgtm otherwise |
We had this discussion before, even with the golint people. I still consider export of private structs as a good pattern, golint doesn't. Introducing interfaces is ugly. |
c174300
to
6e9fc74
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: eloyekunle, fejta, liggitt 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 |
Feels so good to have my first contribution to Kubernetes! 😄 |
Nice work man! |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Fixes lint issues in Go files under:
staging/src/k8s.io/kube-aggregator
.Removed
staging/src/k8s.io/kube-aggregator
fromhack/.golint_failures
.Special notes for your reviewer:
See #68026 for more information.
Does this PR introduce a user-facing change?: