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

Fix for bundle version in the installer CLI #449

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/installer/cli-dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func listSupported() {
osFilters, osBundles := ListSupportedOS()
for i := range osFilters {
for _, k8s := range ListSupportedK8s(osBundles[i]) {
_, err = fmt.Fprintf(w, "%s\t %s\t%s\n", osFilters[i], k8s, GetBundleName(osBundles[i], k8s))
_, err = fmt.Fprintf(w, "%s\t %s\t%s\n", osFilters[i], k8s, GetBundleName(osBundles[i], GetK8sBundle(k8s)))
if err != nil {
klogger.Error(err, "Failed to write to tabwriter")
}
Expand Down
6 changes: 3 additions & 3 deletions agent/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func getSupportedRegistry(ob algo.OutputBuilder) registry {
*/

// Match any patch version of the specified Major & Minor K8s version
reg.AddK8sFilter("v1.21.*")
reg.AddK8sFilter("v1.22.*")
reg.AddK8sFilter("v1.23.*")
reg.AddK8sFilter("v1.21.*", "v1.22")
reg.AddK8sFilter("v1.22.*", "v1.22")
reg.AddK8sFilter("v1.23.*", "v1.22")

// Match concrete os version to repository os version
reg.AddOsFilter("Ubuntu_20.04.*_x86-64", linuxDistro)
Expand Down
11 changes: 10 additions & 1 deletion agent/installer/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"regexp"
)

var k8sFilterBundleMap map[string]string

type osk8sInstaller interface{}
type k8sInstallerMap map[string]osk8sInstaller
type osk8sInstallerMap map[string]k8sInstallerMap
Expand Down Expand Up @@ -55,8 +57,15 @@ func (r *registry) AddOsFilter(osFilter, osBundle string) {
r.filterOSBundleList = append(r.filterOSBundleList, filterOsBundlePair{osFilter: osFilter, osBundle: osBundle})
}

func (r *registry) AddK8sFilter(k8sFilter string) {
func (r *registry) AddK8sFilter(k8sFilter, k8sBundle string) {
r.filterK8sBundleList = append(r.filterK8sBundleList, filterK8sBundle{k8sFilter: k8sFilter})
if k8sFilterBundleMap == nil {
k8sFilterBundleMap = make(map[string]string)
}
k8sFilterBundleMap[k8sFilter] = k8sBundle
}
func GetK8sBundle(k8sFilter string) string {
return k8sFilterBundleMap[k8sFilter]
}

// ListOS returns a list of OSes supported by the registry
Expand Down
4 changes: 2 additions & 2 deletions agent/installer/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("Byohost Installer Tests", func() {

r.AddOsFilter("ubuntu.*", "ubuntu")
r.AddOsFilter("rhel.*", "rhel")
r.AddK8sFilter("v1.22.*")
r.AddK8sFilter("v1.22.*", "v1.22")

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

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