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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 Standardize api import aliases #5830

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Dec 9, 2021

What this PR does / why we need it:
This PR standardizes our import aliases (follow-up to: #5788 (comment))

Upsides of standardizing aliases:

  • Consistent importing, i.e. whenever you see an import alias somewhere in the code you can be sure your using the right package / version of the package
    • So no more cases of the v1alpha4 package being aliased as v1beta1 and vice versa.
  • it makes especially the conversion files way more readable if every package just has one alias we're always using
  • no more nits on PRs for import aliases of one of the enforced packages
  • it should help as an additional validation layer when we're introducing the next api version as we can just adjust the expected aliases in golangci.yaml and the linter will catch a bunch of mistakes for us.

Not sure how it works in other IDEs, but in Intellij you can just write bootstrapv1.<struct-name> and it will automatically import the correct package because it tracks all known aliases. This works better if there is a clear alias=>package mapping.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 9, 2021
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 9, 2021
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Dec 9, 2021

@sbueringer: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-e2e-ipv6-main 83d5a61 link false /test pull-cluster-api-e2e-ipv6-main

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.

@fabriziopandini
Copy link
Member

nice one!

@sbueringer sbueringer changed the title [WIP] 馃尡 Standardize api import aliases 馃尡 Standardize api import aliases Dec 9, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 9, 2021
@sbueringer sbueringer force-pushed the pr-standardize-api-import-aliases branch 2 times, most recently from 64264bc to d411869 Compare December 9, 2021 13:33
@sbueringer sbueringer closed this Dec 9, 2021
@sbueringer sbueringer force-pushed the pr-standardize-api-import-aliases branch from d411869 to e889246 Compare December 9, 2021 13:36
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 9, 2021
@sbueringer
Copy link
Member Author

/reopen

@k8s-ci-robot
Copy link
Contributor

@sbueringer: Failed to re-open PR: state cannot be changed. There are no new commits on the sbueringer:pr-standardize-api-import-aliases branch.

In response to this:

/reopen

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.

@sbueringer
Copy link
Member Author

Something broke my rebase workflow. I'll open a new PR

@sbueringer
Copy link
Member Author

sbueringer commented Dec 9, 2021

Okay I just revived that branch/PR instead

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Dec 9, 2021
@k8s-ci-robot
Copy link
Contributor

@sbueringer: Reopened this PR.

In response to this:

/reopen

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.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 9, 2021
Signed-off-by: Stefan B眉ringer buringerst@vmware.com
@sbueringer sbueringer force-pushed the pr-standardize-api-import-aliases branch from 2e4c350 to b0797b3 Compare December 9, 2021 14:08
@sbueringer
Copy link
Member Author

Rebased and self-reviewed the PR. Should be ready for review now.

@sbueringer
Copy link
Member Author

/assign @fabriziopandini @vincepri

(cc @stmcginnis, might be also interesting for you)

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! It should help clarify things.
We should add this as a task for releasing a new API version somewhere too, but that can be outside of this PR.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 9, 2021
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4
alias: bootstrapv1alpha4
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
alias: bootstrapv1
Copy link
Member

Choose a reason for hiding this comment

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

should we reserve v1 for real v1 and let the beta imports be consistent e.g bootstrapv1beta1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm good question. Up until know we used v1 everywhere (and with everywhere I also mean in a bunch of providers :))

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the main idea behind that is that when we upgrade the version only the import changes and not huge parts of the codebase

Copy link
Member

Choose a reason for hiding this comment

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

yes. this is for avoiding churn in the codebase at each release and it kind of makes sense if you read it as the last version in the v1 series (or at least that was the original idea)

@fabriziopandini
Copy link
Member

/lgtm
I'm definitely +1 to standardize common imports on well know names (whatever they are).
looking for others' opinions.

@sbueringer
Copy link
Member Author

/assign @vincepri
If you've got some time, would be great if you can take a look :)

alias: clusterv1
# CAPI exp
- pkg: sigs.k8s.io/cluster-api/exp/api/v1alpha3
alias: expv1alpha3
Copy link
Member

Choose a reason for hiding this comment

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

nit: clusterexp*?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would be fine for me. I just used the currently most commonly used alias. But I'm not sure which one would be better (same would probably apply to addonsv1 => clusteraddonsv1, too)

On one side having the cluster prefix would be more consistent with infraexp on the other side it's ab it longer

@fabriziopandini WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

using cluster prefix seems kind of redundant to me, but no strong opinions

Copy link
Member Author

Choose a reason for hiding this comment

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

Similar here.

@enxebre
Copy link
Member

enxebre commented Dec 10, 2021

/lgtm

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2021
@k8s-ci-robot k8s-ci-robot merged commit c1730d3 into kubernetes-sigs:main Dec 10, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Dec 10, 2021
@sbueringer sbueringer deleted the pr-standardize-api-import-aliases branch December 10, 2021 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants