Skip to content

Commit

Permalink
Support to install KubeSphere with a not release version (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen authored Oct 21, 2021
1 parent 7522ed5 commit 3f8ecfc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kubectl-plugin/install/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/client-go/dynamic"
"os"
"path"
"strings"
)

func newInstallerCmd() (cmd *cobra.Command) {
Expand Down Expand Up @@ -68,6 +69,9 @@ func (o *installerOption) preRunE(_ *cobra.Command, args []string) (err error) {
o.ksInstaller.ImageNamespace = "kubespheredev"
o.ksInstaller.Version = o.nightly
}
if isNotReleaseVersion(o.version) {
o.ksInstaller.ImageNamespace = "kubespheredev"
}
for _, item := range o.components {
switch item {
case "servicemesh":
Expand Down Expand Up @@ -99,6 +103,11 @@ func (o *installerOption) preRunE(_ *cobra.Command, args []string) (err error) {
return
}

func isNotReleaseVersion(version string) bool {
return strings.Contains(version, "rc") || strings.Contains(version, "alpha") ||
strings.Contains(version, "beta")
}

func (o *installerOption) getCrdAndCC() (crd, cc string, err error) {
var crdTmp *template.Template
if crdTmp, err = template.New("crd").Parse(installer.GetKSInstaller()); err != nil {
Expand Down
45 changes: 45 additions & 0 deletions kubectl-plugin/install/installer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package install

import "testing"

func Test_isNotReleaseVersion(t *testing.T) {
type args struct {
version string
}
tests := []struct {
name string
args args
want bool
}{{
name: "rc version",
args: args{
version: "v1.0-rc1",
},
want: true,
}, {
name: "alpha version",
args: args{
version: "v1.0-alpha1",
},
want: true,
}, {
name: "beta version",
args: args{
version: "v1.0-beta-1",
},
want: true,
}, {
name: "release version",
args: args{
version: "v1.0",
},
want: false,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isNotReleaseVersion(tt.args.version); got != tt.want {
t.Errorf("isNotReleaseVersion() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 3f8ecfc

Please sign in to comment.