Skip to content

Commit 337b156

Browse files
author
Jeff Peeler
committed
chore(olm): refactor updateNamespaceList
return error as the last argument
1 parent cd201c5 commit 337b156

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/controller/operators/olm/operatorgroup.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (a *Operator) syncOperatorGroups(obj interface{}) error {
2424
}
2525
log.Infof("syncing operator group %v", op)
2626

27-
err, targetedNamespaces := a.updateNamespaceList(op)
27+
targetedNamespaces, err := a.updateNamespaceList(op)
2828
log.Debugf("Got targetedNamespaces: '%v'", targetedNamespaces)
2929
if err != nil {
3030
log.Errorf("updateNamespaceList error: %v", err)
@@ -142,30 +142,30 @@ func namespacesChanged(clusterNamespaces []*corev1.Namespace, statusNamespaces [
142142
return false
143143
}
144144

145-
func (a *Operator) updateNamespaceList(op *v1alpha2.OperatorGroup) (error, []*corev1.Namespace) {
145+
func (a *Operator) updateNamespaceList(op *v1alpha2.OperatorGroup) ([]*corev1.Namespace, error) {
146146
selector, err := metav1.LabelSelectorAsSelector(&op.Spec.Selector)
147147
if err != nil {
148-
return err, nil
148+
return nil, err
149149
}
150150

151151
namespaceList, err := a.lister.CoreV1().NamespaceLister().List(selector)
152152
if err != nil {
153-
return err, nil
153+
return nil, err
154154
}
155155

156156
if !namespacesChanged(namespaceList, op.Status.Namespaces) {
157157
// status is current with correct namespaces, so no further updates required
158-
return nil, namespaceList
158+
return namespaceList, nil
159159
}
160160
log.Debugf("Namespace change detected, found: %v", namespaceList)
161161
op.Status.Namespaces = make([]*corev1.Namespace, len(namespaceList))
162162
copy(op.Status.Namespaces, namespaceList)
163163
op.Status.LastUpdated = timeNow()
164164
_, err = a.client.OperatorsV1alpha2().OperatorGroups(op.Namespace).UpdateStatus(op)
165165
if err != nil {
166-
return err, namespaceList
166+
return namespaceList, err
167167
}
168-
return nil, namespaceList
168+
return namespaceList, nil
169169
}
170170

171171
func (a *Operator) ensureClusterRoles(op *v1alpha2.OperatorGroup) error {

0 commit comments

Comments
 (0)