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

feat: support k8s and kubesphere version without "v" #1396

Merged
merged 1 commit into from
Jul 23, 2022
Merged

feat: support k8s and kubesphere version without "v" #1396

merged 1 commit into from
Jul 23, 2022

Conversation

zaunist
Copy link
Contributor

@zaunist zaunist commented Jul 22, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

This makes kubekey more convenient to use and improves the user experience

Which issue(s) this PR fixes:

Fixes #1365

Special notes for reviewers:

Does this PR introduced a user-facing change?

Now, we can use both "1.23.6" and "v1.23.6" to create clusters.

Additional documentation, usage docs, etc.:


@ks-ci-bot ks-ci-bot added kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 22, 2022
Copy link
Member

@mangoGoForward mangoGoForward left a comment

Choose a reason for hiding this comment

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

Nice work, thanks for your contribution.
And please confirm whether the file of go.sum needs to be modified

@@ -109,7 +109,11 @@ func (d *DefaultLoader) Load() (*kubekeyapiv1alpha2.Cluster, error) {
Registry: {hostname},
}
if d.KubernetesVersion != "" {
s := strings.Split(d.KubernetesVersion, "-")
ver := normalizedBuildVersion(d.KubernetesVersion)
if len(ver) < 2 {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks your advice. :)

@@ -127,7 +131,11 @@ func (d *DefaultLoader) Load() (*kubekeyapiv1alpha2.Cluster, error) {
}

if d.KubeSphereEnable {
if err := defaultKSConfig(&allInOne.Spec.KubeSphere, d.KubeSphereVersion); err != nil {
ver := normalizedBuildVersion(d.KubeSphereVersion)
if len(ver) < 2 {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

@ks-ci-bot ks-ci-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 22, 2022
@mangoGoForward
Copy link
Member

Hi @zaunist , seems this place also need to process

if f.KubeSphereEnable {
if err := defaultKSConfig(&clusterCfg.Spec.KubeSphere, f.KubeSphereVersion); err != nil {
return nil, err
}
}
if f.KubernetesVersion != "" {
s := strings.Split(f.KubernetesVersion, "-")
if len(s) > 1 {
clusterCfg.Spec.Kubernetes.Version = s[0]
clusterCfg.Spec.Kubernetes.Type = s[1]
} else {
clusterCfg.Spec.Kubernetes.Version = f.KubernetesVersion
}
}

@ks-ci-bot ks-ci-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 22, 2022
@mangoGoForward
Copy link
Member

/label tide/merge-method-squash

@ks-ci-bot ks-ci-bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 22, 2022
Copy link
Member

@mangoGoForward mangoGoForward left a comment

Choose a reason for hiding this comment

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

Good to me
/LGTM

@ks-ci-bot
Copy link
Collaborator

@mangoGoForward: changing LGTM is restricted to collaborators

In response to this:

Good to me
/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.

@zaunist
Copy link
Contributor Author

zaunist commented Jul 22, 2022

@pixiake PTAL.

return nil, err
}
}

if f.KubernetesVersion != "" {
s := strings.Split(f.KubernetesVersion, "-")
if ver := normalizedBuildVersion(f.KubernetesVersion); ver != "" {
Copy link
Collaborator

@24sama 24sama Jul 22, 2022

Choose a reason for hiding this comment

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

f.KubernetesVersion is generated by cmd's flag:

cmd.Flags().StringVarP(&o.Kubernetes, "with-kubernetes", "", "", "Specify a supported version of kubernetes")

So, I guess normalizing this variable may not work for the Kubernetes version only specified in the config file.

What do you think about normalizing clusterCfg.Spec.Kubernetes.Version directly?

@24sama
Copy link
Collaborator

24sama commented Jul 22, 2022

Hi @zaunist , thanks for your contributions!

@zaunist
Copy link
Contributor Author

zaunist commented Jul 22, 2022

Hi @zaunist , thanks for your contributions!

Good catch, thanks for your carefulness :)

@24sama
Copy link
Collaborator

24sama commented Jul 22, 2022

/lgtm

@ks-ci-bot ks-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2022
@ks-ci-bot
Copy link
Collaborator

LGTM label has been added.

Git tree hash: c7143bbee50aca004ad747dc78210b9bcd75c64b

@24sama
Copy link
Collaborator

24sama commented Jul 22, 2022

LGTM, the last thing, could you please squash your commits @zaunist ? The git history will look more clear.

support kubenetes and kubesphere version without "v"
@zaunist zaunist requested a review from 24sama July 22, 2022 12:13
@24sama
Copy link
Collaborator

24sama commented Jul 23, 2022

Thanks @zaunist

/approve

@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 24sama, zaunist

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

@ks-ci-bot ks-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 23, 2022
@ks-ci-bot ks-ci-bot merged commit 97ad9f3 into kubesphere:master Jul 23, 2022
@pixiake
Copy link
Collaborator

pixiake commented Jul 25, 2022

@all-contributors please add @zaunist for code

@allcontributors
Copy link
Contributor

@pixiake

I've put up a pull request to add @zaunist! 🎉

@pixiake
Copy link
Collaborator

pixiake commented Jul 25, 2022

@all-contributors please add @mangoGoForward for review

@allcontributors
Copy link
Contributor

@pixiake

I've put up a pull request to add @mangoGoForward! 🎉

@zaunist zaunist deleted the feat/support_prefix_version branch July 25, 2022 09:04
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support version number without v
5 participants