Skip to content

Commit

Permalink
Update to use global KDM
Browse files Browse the repository at this point in the history
  • Loading branch information
STARRY-S committed Aug 14, 2024
1 parent 28011ab commit 1b0d73e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
8 changes: 5 additions & 3 deletions pkg/commands/generate_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ func (cc *generateListCmd) prepareGenerator() error {
}

switch {
case utils.SemverMajorMinorEqual(cc.rancherVersion, "v2.6"):
option.MinKubeVersion = "v1.21.0"
case utils.SemverMajorMinorEqual(cc.rancherVersion, "v2.7"):
option.MinKubeVersion = "v1.23.0"
case utils.SemverMajorMinorEqual(cc.rancherVersion, "v2.8"):
option.MinKubeVersion = "v1.25.0"
case utils.SemverMajorMinorEqual(cc.rancherVersion, "v2.9"):
option.MinKubeVersion = "v1.27.0"
case utils.SemverMajorMinorEqual(cc.rancherVersion, "v2.10"):
option.MinKubeVersion = "v1.29.0"
default:
option.MinKubeVersion = "v0.1.0"
option.MinKubeVersion = "v1.21.0"
}
if cc.kdm != "" {
if _, err := url.ParseRequestURI(cc.kdm); err != nil {
Expand Down
25 changes: 22 additions & 3 deletions pkg/commands/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commands
import (
"github.com/cnrancher/hangar/pkg/rancher/chartimages"
"github.com/cnrancher/hangar/pkg/rancher/listgenerator"
"github.com/cnrancher/hangar/pkg/utils"
"github.com/sirupsen/logrus"
"golang.org/x/mod/semver"
)
Expand Down Expand Up @@ -293,15 +294,33 @@ func addRancherPrimeManagerKontainerDriverMetadata(
func addRancherPrimeManagerGCKontainerDriverMetadata(
v string, o *listgenerator.GeneratorOption, dev bool,
) {
majorMinor := semver.MajorMinor(v)
urlMap := KontainerDriverMetadataGCURLs
urlMap := KontainerDriverMetadataURLs
if dev {
urlMap = KontainerDriverMetadataGCURLsDEV
urlMap = KontainerDriverMetadataURLsDEV
}
if shouldUseGCKDM(v) {
if dev {
urlMap = KontainerDriverMetadataGCURLsDEV
} else {
urlMap = KontainerDriverMetadataGCURLs
}
}

majorMinor := semver.MajorMinor(v)
url, ok := urlMap[majorMinor]
if !ok {
logrus.Warnf("KDM URL of version %q not found!", majorMinor)
return
}
o.KDMURL = url
}

func shouldUseGCKDM(version string) bool {
// v2.8.5 and v2.9.0+ does not required to use GC KDM anymore
if n, e := utils.SemverCompare(version, "v2.9.0"); e == nil && n >= 0 {
return false
} else if n, e := utils.SemverCompare(version, "v2.8.5"); e == nil && n >= 0 {
return false
}
return true
}

0 comments on commit 1b0d73e

Please sign in to comment.