Skip to content

Commit 8d9967e

Browse files
author
Jeff Peeler
committed
feat(clusteroperator): plumb additional clients
1 parent 80a0850 commit 8d9967e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

cmd/catalog/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
utilclock "k8s.io/apimachinery/pkg/util/clock"
1717
"k8s.io/client-go/tools/clientcmd"
1818

19+
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client"
1920
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog"
2021
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
2122
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
@@ -155,6 +156,10 @@ func main() {
155156
log.Fatalf("error configuring client: %s", err.Error())
156157
}
157158
opClient := operatorclient.NewClientFromConfig(*kubeConfigPath, logger)
159+
crClient, err := client.NewClient(*kubeConfigPath)
160+
if err != nil {
161+
log.Fatalf("error configuring client: %s", err.Error())
162+
}
158163

159164
// Create a new instance of the operator.
160165
op, err := catalog.NewOperator(ctx, *kubeConfigPath, utilclock.RealClock{}, logger, *wakeupInterval, *configmapServerImage, *catalogNamespace, namespaces...)
@@ -166,7 +171,7 @@ func main() {
166171
<-op.Ready()
167172

168173
if *writeStatusName != "" {
169-
operatorstatus.MonitorClusterStatus(*writeStatusName, *catalogNamespace, op.AtLevel(), op.Done(), opClient, configClient)
174+
operatorstatus.MonitorClusterStatus(*writeStatusName, *catalogNamespace, op.AtLevel(), op.Done(), opClient, configClient, crClient)
170175
}
171176

172177
<-op.Done()

cmd/olm/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func main() {
196196
<-op.Ready()
197197

198198
if *writeStatusName != "" {
199-
operatorstatus.MonitorClusterStatus(*writeStatusName, *namespace, op.AtLevel(), ctx.Done(), opClient, configClient)
199+
operatorstatus.MonitorClusterStatus(*writeStatusName, *namespace, op.AtLevel(), ctx.Done(), opClient, configClient, crClient)
200200
}
201201

202202
if *writePackageServerStatusName != "" {

pkg/lib/operatorstatus/status.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
configv1 "github.com/openshift/api/config/v1"
1010
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
11+
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
1112
log "github.com/sirupsen/logrus"
1213
corev1 "k8s.io/api/core/v1"
1314
k8serrors "k8s.io/apimachinery/pkg/api/errors"
@@ -27,7 +28,7 @@ const (
2728
clusterOperatorCatalogSource = "operator-lifecycle-manager-catalog"
2829
)
2930

30-
func MonitorClusterStatus(name, namespace string, syncCh <-chan error, stopCh <-chan struct{}, opClient operatorclient.ClientInterface, configClient configv1client.ConfigV1Interface) {
31+
func MonitorClusterStatus(name, namespace string, syncCh <-chan error, stopCh <-chan struct{}, opClient operatorclient.ClientInterface, configClient configv1client.ConfigV1Interface, crClient versioned.Interface) {
3132
var (
3233
syncs int
3334
successfulSyncs int
@@ -113,7 +114,7 @@ func MonitorClusterStatus(name, namespace string, syncCh <-chan error, stopCh <-
113114
},
114115
},
115116
})
116-
created.Status.RelatedObjects = relatedObjects(name, namespace)
117+
created.Status.RelatedObjects = relatedObjects(name, namespace, opClient, crClient)
117118
if createErr != nil {
118119
log.Errorf("Failed to create cluster operator: %v\n", createErr)
119120
return
@@ -246,7 +247,7 @@ func findOperatorStatusCondition(conditions []configv1.ClusterOperatorStatusCond
246247

247248
// relatedObjects returns RelatedObjects in the ClusterOperator.Status.
248249
// RelatedObjects are consumed by https://github.com/openshift/must-gather
249-
func relatedObjects(name, namespace string) []configv1.ObjectReference {
250+
func relatedObjects(name, namespace string, opClient operatorclient.ClientInterface, crClient versioned.Interface) []configv1.ObjectReference {
250251
var objectReferences []configv1.ObjectReference
251252
switch name {
252253
case clusterOperatorOLM:

0 commit comments

Comments
 (0)