@@ -67,6 +67,7 @@ import (
67
67
68
68
telemetry "github.com/openshift/console-operator/pkg/console/telemetry"
69
69
70
+ "github.com/go-test/deep"
70
71
consoleoperator "github.com/openshift/console-operator/pkg/console/operator"
71
72
"github.com/openshift/library-go/pkg/operator/loglevel"
72
73
)
@@ -456,21 +457,41 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
456
457
)
457
458
458
459
// Show all ConsolePlugin instances as related objects
460
+ // Show all namespaces that are used by ConsolePlugin Backend Service as related objects
461
+ // Show all namespaces that are used by Proxy Service configs as related objects
462
+ // Deduplicate related objects
459
463
clusterOperatorStatus .WithRelatedObjectsFunc (func () (bool , []configv1.ObjectReference ) {
460
464
relatedObjects := []configv1.ObjectReference {}
461
465
consolePlugins , err := consoleClient .ConsoleV1 ().ConsolePlugins ().List (ctx , metav1.ListOptions {})
462
466
if err != nil {
463
467
return false , nil
464
468
}
465
469
for _ , plugin := range consolePlugins .Items {
466
- relatadPlugin := configv1.ObjectReference {
470
+ relatedObjects = append ( relatedObjects , configv1.ObjectReference {
467
471
Group : "console.openshift.io" ,
468
472
Resource : "consoleplugins" ,
469
473
Name : plugin .GetName (),
474
+ })
475
+ if plugin .Spec .Backend .Service != nil {
476
+ ns := plugin .Spec .Backend .Service .Namespace
477
+ relatedObjects = append (relatedObjects , configv1.ObjectReference {
478
+ Group : corev1 .GroupName ,
479
+ Resource : "namespaces" ,
480
+ Name : ns ,
481
+ })
482
+ }
483
+ for _ , proxy := range plugin .Spec .Proxy {
484
+ if proxy .Endpoint .Service != nil && proxy .Endpoint .Service .Namespace != "" {
485
+ relatedObjects = append (relatedObjects , configv1.ObjectReference {
486
+ Group : corev1 .GroupName ,
487
+ Resource : "namespaces" ,
488
+ Name : proxy .Endpoint .Service .Namespace ,
489
+ })
490
+ }
470
491
}
471
- relatedObjects = append (relatedObjects , relatadPlugin )
472
492
}
473
- return true , relatedObjects
493
+
494
+ return true , deduplicateObjectReferences (relatedObjects )
474
495
})
475
496
476
497
// NOTE: be sure to uncomment the .Run() below if using this
@@ -661,3 +682,20 @@ func extractStaticPodOperatorStatus(obj *unstructured.Unstructured, fieldManager
661
682
}
662
683
return & ret .Status .OperatorStatusApplyConfiguration , nil
663
684
}
685
+
686
+ func deduplicateObjectReferences (objs []configv1.ObjectReference ) []configv1.ObjectReference {
687
+ result := make ([]configv1.ObjectReference , 0 , len (objs ))
688
+ for _ , obj := range objs {
689
+ duplicate := false
690
+ for _ , existing := range result {
691
+ if len (deep .Equal (obj , existing )) == 0 {
692
+ duplicate = true
693
+ break
694
+ }
695
+ }
696
+ if ! duplicate {
697
+ result = append (result , obj )
698
+ }
699
+ }
700
+ return result
701
+ }
0 commit comments