Skip to content

Commit

Permalink
feat: ensure we always process add-ons the same order (#410)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
ricardomaraschini authored Feb 22, 2024
1 parent e7bd5f8 commit 6e3cf7a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/addons/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down

0 comments on commit 6e3cf7a

Please sign in to comment.