mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
Chore: swtich between old and new registry in vela install (#6173)
* Chore: swtich between old and new registry in vela install Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com> * add comments Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com> * minor fix Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com> --------- Signed-off-by: Qiaozp <qiaozhongpei.qzp@alibaba-inc.com>
This commit is contained in:
@@ -44,3 +44,22 @@ func GetOfficialKubeVelaVersion(versionStr string) (string, error) {
|
||||
}
|
||||
return v[:len(v)-len(metadata)], nil
|
||||
}
|
||||
|
||||
// ShouldUseLegacyHelmRepo checks whether the provided version should use the legacy helm repo
|
||||
func ShouldUseLegacyHelmRepo(ver *version.Version) bool {
|
||||
if ver.LessThan(version.Must(version.NewVersion("1.8.2"))) {
|
||||
return true
|
||||
}
|
||||
|
||||
if ver.GreaterThanOrEqual(version.Must(version.NewVersion("1.9.0"))) {
|
||||
return false
|
||||
}
|
||||
|
||||
// After v1.9.0-beta.1.post1, we use the new helm repo
|
||||
switch ver.Prerelease() {
|
||||
case "beta.1.post1", "beta.2", "beta.3":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package version
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -41,3 +42,33 @@ func TestGetVersion(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "1.2.0", version)
|
||||
}
|
||||
|
||||
func TestShouldUseLegacyHelmRepo(t *testing.T) {
|
||||
tests := []struct {
|
||||
ver string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
ver: "v1.2.0",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
ver: "v1.9.0-beta.1",
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
ver: "v1.9.0-beta.1.post1",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
ver: "v1.9.1",
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.ver, func(t *testing.T) {
|
||||
ver := version.Must(version.NewVersion(tt.ver))
|
||||
assert.Equalf(t, tt.want, ShouldUseLegacyHelmRepo(ver), "ShouldUseLegacyHelmRepo(%v)", tt.ver)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user