Skip to content

Commit 6e3cf7a

Browse files
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)
1 parent e7bd5f8 commit 6e3cf7a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/addons/applier.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,25 @@ func (a *Applier) HostPreflights() (*v1beta2.HostPreflightSpec, error) {
123123
}
124124

125125
// load instantiates all enabled addons.
126-
func (a *Applier) load() (map[string]AddOn, error) {
127-
addons := map[string]AddOn{}
126+
func (a *Applier) load() ([]AddOn, error) {
127+
addons := []AddOn{}
128128
obs, err := openebs.New()
129129
if err != nil {
130130
return nil, fmt.Errorf("unable to create openebs addon: %w", err)
131131
}
132-
addons["openebs"] = obs
132+
addons = append(addons, obs)
133+
133134
embedoperator, err := embeddedclusteroperator.New(a.endUserConfig, a.license)
134135
if err != nil {
135136
return nil, fmt.Errorf("unable to create embedded cluster operator addon: %w", err)
136137
}
137-
addons["embeddedclusteroperator"] = embedoperator
138+
addons = append(addons, embedoperator)
139+
138140
aconsole, err := adminconsole.New("kotsadm", a.prompt, a.config, a.license)
139141
if err != nil {
140142
return nil, fmt.Errorf("unable to create admin console addon: %w", err)
141143
}
142-
addons["adminconsole"] = aconsole
144+
addons = append(addons, aconsole)
143145
return addons, nil
144146
}
145147

@@ -149,16 +151,18 @@ func (a *Applier) Versions(additionalCharts []v1beta1.Chart) (map[string]string,
149151
if err != nil {
150152
return nil, fmt.Errorf("unable to load addons: %w", err)
151153
}
154+
152155
versions := map[string]string{}
153-
for name, addon := range addons {
156+
for _, addon := range addons {
154157
version, err := addon.Version()
155158
if err != nil {
156-
return nil, fmt.Errorf("unable to get version (%s): %w", name, err)
159+
return nil, fmt.Errorf("unable to get version (%s): %w", addon.Name(), err)
157160
}
158161
for k, v := range version {
159162
versions[k] = v
160163
}
161164
}
165+
162166
for _, chart := range additionalCharts {
163167
versions[chart.Name] = chart.Version
164168
}

0 commit comments

Comments
 (0)