Skip to content

Commit e496f4b

Browse files
committed
availableupdates: Refactor getting desired/current architecture
The commit does change the default behaviour of the `getDesiredArchitecture` method. However, the method is only used once in the `syncAvailableUpdates` method and nowhere else. The commit adds the subsequent logic for evaluating a desired architecture to the method itself and implements the `getCurrentArchitecture` method. The goal is to introduces "getters" for such values where the unified capitalization is enforced, and their return values are of the same nature (e.g., "Multi", "amd64", ...).
1 parent ccc0e36 commit e496f4b

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pkg/cvo/availableupdates.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,7 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1
4949

5050
channel := config.Spec.Channel
5151
desiredArch := optr.getDesiredArchitecture(config.Spec.DesiredUpdate)
52-
currentArch := runtime.GOARCH
53-
54-
if optr.release.Architecture == configv1.ClusterVersionArchitectureMulti {
55-
currentArch = string(configv1.ClusterVersionArchitectureMulti)
56-
}
57-
58-
if desiredArch == "" {
59-
desiredArch = currentArch
60-
}
52+
currentArch := optr.getCurrentArchitecture()
6153

6254
// updates are only checked at most once per minimumUpdateCheckInterval or if the generation changes
6355
optrAvailableUpdates := optr.getAvailableUpdates()
@@ -330,7 +322,14 @@ func (optr *Operator) getDesiredArchitecture(update *configv1.Update) string {
330322
if update != nil {
331323
return string(update.Architecture)
332324
}
333-
return ""
325+
return optr.getCurrentArchitecture()
326+
}
327+
328+
func (optr *Operator) getCurrentArchitecture() string {
329+
if optr.release.Architecture == configv1.ClusterVersionArchitectureMulti {
330+
return string(configv1.ClusterVersionArchitectureMulti)
331+
}
332+
return runtime.GOARCH
334333
}
335334

336335
func calculateAvailableUpdatesStatus(ctx context.Context, clusterID string, transport *http.Transport, userAgent, updateService, desiredArch,

0 commit comments

Comments
 (0)