Skip to content

Commit 9db95f3

Browse files
committed
Made small changes so the CLI shows correct bundle version.
Made a map from k8s filter to k8s bundle (this is in order to easily output correct bundle for example 1.23.* -> 1.22) Made changes to installer.go and the registry tests to accomodate the added second argument to the function.
1 parent cc605cf commit 9db95f3

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

agent/installer/cli-dev.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func listSupported() {
107107
osFilters, osBundles := ListSupportedOS()
108108
for i := range osFilters {
109109
for _, k8s := range ListSupportedK8s(osBundles[i]) {
110-
_, err = fmt.Fprintf(w, "%s\t %s\t%s\n", osFilters[i], k8s, GetBundleName(osBundles[i], k8s))
110+
_, err = fmt.Fprintf(w, "%s\t %s\t%s\n", osFilters[i], k8s, GetBundleName(osBundles[i], GetK8sBundle(k8s)))
111111
if err != nil {
112112
klogger.Error(err, "Failed to write to tabwriter")
113113
}

agent/installer/installer.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func getSupportedRegistry(ob algo.OutputBuilder) registry {
6868
*/
6969

7070
// Match any patch version of the specified Major & Minor K8s version
71-
reg.AddK8sFilter("v1.21.*")
72-
reg.AddK8sFilter("v1.22.*")
73-
reg.AddK8sFilter("v1.23.*")
71+
reg.AddK8sFilter("v1.21.*", "v1.22")
72+
reg.AddK8sFilter("v1.22.*", "v1.22")
73+
reg.AddK8sFilter("v1.23.*", "v1.22")
7474

7575
// Match concrete os version to repository os version
7676
reg.AddOsFilter("Ubuntu_20.04.*_x86-64", linuxDistro)

agent/installer/registry.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"regexp"
99
)
1010

11+
var k8sFilterBundleMap map[string]string
12+
1113
type osk8sInstaller interface{}
1214
type k8sInstallerMap map[string]osk8sInstaller
1315
type osk8sInstallerMap map[string]k8sInstallerMap
@@ -55,8 +57,15 @@ func (r *registry) AddOsFilter(osFilter, osBundle string) {
5557
r.filterOSBundleList = append(r.filterOSBundleList, filterOsBundlePair{osFilter: osFilter, osBundle: osBundle})
5658
}
5759

58-
func (r *registry) AddK8sFilter(k8sFilter string) {
60+
func (r *registry) AddK8sFilter(k8sFilter, k8sBundle string) {
5961
r.filterK8sBundleList = append(r.filterK8sBundleList, filterK8sBundle{k8sFilter: k8sFilter})
62+
if k8sFilterBundleMap == nil {
63+
k8sFilterBundleMap = make(map[string]string)
64+
}
65+
k8sFilterBundleMap[k8sFilter] = k8sBundle
66+
}
67+
func GetK8sBundle(k8sFilter string) string {
68+
return k8sFilterBundleMap[k8sFilter]
6069
}
6170

6271
// ListOS returns a list of OSes supported by the registry

agent/installer/registry_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var _ = Describe("Byohost Installer Tests", func() {
4040

4141
r.AddOsFilter("ubuntu.*", "ubuntu")
4242
r.AddOsFilter("rhel.*", "rhel")
43-
r.AddK8sFilter("v1.22.*")
43+
r.AddK8sFilter("v1.22.*", "v1.22")
4444

4545
inst, osBundle := r.GetInstaller("ubuntu-1", "v1.22.1")
4646
Expect(inst).To(Equal(dummy122))
@@ -70,7 +70,7 @@ var _ = Describe("Byohost Installer Tests", func() {
7070
// Bundle OS does not match filter OS
7171
r.AddBundleInstaller("UBUNTU", "v1.22.*", dummy122)
7272
r.AddOsFilter("ubuntu.*", "UBUNTU")
73-
r.AddK8sFilter("v1.22.*")
73+
r.AddK8sFilter("v1.22.*", "v1.22")
7474

7575
inst, osBundle := r.GetInstaller("ubuntu-1", "v1.22.1")
7676
Expect(inst).To(Equal(dummy122))

0 commit comments

Comments
 (0)