-
Notifications
You must be signed in to change notification settings - Fork 431
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
Standardize more package import aliases #2529
Conversation
@@ -24,7 +24,7 @@ import ( | |||
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2021-05-01/containerservice" | |||
"github.com/google/go-cmp/cmp" | |||
"github.com/pkg/errors" | |||
infrav1alpha4 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" |
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.
This was a misleading alias.
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.
Thanks for the PR @mboersma! I left some thoughts in the comments.
alias: clusterv1 | ||
# CAPI exp | ||
- pkg: sigs.k8s.io/cluster-api/exp/api/v1alpha3 | ||
alias: expv1alpha3 |
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.
Maybe it should be expclusterv1alpha3
to be consistent with the above?
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.
The CAPI rules for importas
were copied from CAPI's golangci-lint configuration. I think we should just use them as-is to make it easier to move between codebases. I notice that's what CAPA did as well.
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.
Well, some say you should always question things and there is always room for the improvement... 😄 But perhaps less optimal consistency is better than better inconsistency, so I guess that's OK. Thanks for explaining! Feel free to mark as resolved.
- pkg: sigs.k8s.io/cluster-api-provider-azure/exp/api/v1alpha3 | ||
alias: infrav1alpha3exp | ||
- pkg: sigs.k8s.io/cluster-api-provider-azure/exp/api/v1alpha4 | ||
alias: infrav1alpha4exp |
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.
It's expv1alpha4
with exp
prefix, but infrav1alpha4exp
with exp
suffix, maybe we can make it more consistent?
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, we could--I chose the infrav1exp
pattern for CAPZ imports because it was already the most-used, so that minimized the churn in the codebase. But infraexpv1
and infraexpv1alpha4
are arguably more consistent with CAPI's imports.
@@ -72,6 +72,34 @@ linters-settings: | |||
# Controller Runtime | |||
- pkg: sigs.k8s.io/controller-runtime | |||
alias: ctrl | |||
# CAPI | |||
- pkg: sigs.k8s.io/cluster-api/api/v1alpha3 |
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 wonder, if source file imports only single package named v1alpha3
, will the linter still require an alias?
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.
It will, because we have no-unaliased: true
set in .golangci.yml.
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.
All good if that's deliberate. I think I like it this way, similar to ,
ending the last entry in the lists. It won't make you change unrelated stuff when you add new import. Feel free to mark as resolved.
@invidian I noticed that this only really fixes half of the problem, since there are still randomly-named imports of these packages in When we're all happy with the naming here, I'll update that branch and put a followup PR out. |
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
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jackfrancis 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 |
@mboersma: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/cherry-pick release-1.4 |
@jackfrancis: #2529 failed to apply on top of branch "release-1.4":
In response to this:
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. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Standardizes several popular import aliases by adding them to the
importas
linter configuration. This is an area of code where creativity is ultimately unhelpful. The CAPI sections were copied from CAPI's golangci config.Which issue(s) this PR fixes:
Refs #2289
Special notes for your reviewer:
TODOs:
Release note: