From 6e3cf7a24f46f77693826fe912ae0b2778bf0865 Mon Sep 17 00:00:00 2001 From: Ricardo Maraschini Date: Thu, 22 Feb 2024 21:58:46 +0100 Subject: [PATCH] feat: ensure we always process add-ons the same order (#410) * feat: ensure we always process add-ons the same order maps does not guarantee we are going to read the properties in the same order they are created. use an slice of add-ons instead. * feat: print add name instead of type (error) --- pkg/addons/applier.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/addons/applier.go b/pkg/addons/applier.go index 28611f212..ef009d786 100644 --- a/pkg/addons/applier.go +++ b/pkg/addons/applier.go @@ -123,23 +123,25 @@ func (a *Applier) HostPreflights() (*v1beta2.HostPreflightSpec, error) { } // load instantiates all enabled addons. -func (a *Applier) load() (map[string]AddOn, error) { - addons := map[string]AddOn{} +func (a *Applier) load() ([]AddOn, error) { + addons := []AddOn{} obs, err := openebs.New() if err != nil { return nil, fmt.Errorf("unable to create openebs addon: %w", err) } - addons["openebs"] = obs + addons = append(addons, obs) + embedoperator, err := embeddedclusteroperator.New(a.endUserConfig, a.license) if err != nil { return nil, fmt.Errorf("unable to create embedded cluster operator addon: %w", err) } - addons["embeddedclusteroperator"] = embedoperator + addons = append(addons, embedoperator) + aconsole, err := adminconsole.New("kotsadm", a.prompt, a.config, a.license) if err != nil { return nil, fmt.Errorf("unable to create admin console addon: %w", err) } - addons["adminconsole"] = aconsole + addons = append(addons, aconsole) return addons, nil } @@ -149,16 +151,18 @@ func (a *Applier) Versions(additionalCharts []v1beta1.Chart) (map[string]string, if err != nil { return nil, fmt.Errorf("unable to load addons: %w", err) } + versions := map[string]string{} - for name, addon := range addons { + for _, addon := range addons { version, err := addon.Version() if err != nil { - return nil, fmt.Errorf("unable to get version (%s): %w", name, err) + return nil, fmt.Errorf("unable to get version (%s): %w", addon.Name(), err) } for k, v := range version { versions[k] = v } } + for _, chart := range additionalCharts { versions[chart.Name] = chart.Version }