@@ -506,8 +506,10 @@ func TestLoadConfig(t *testing.T) {
506
506
},
507
507
},
508
508
cfg : allocatorconfig.Config {
509
- ServiceMonitorSelector : map [string ]string {
510
- "testsvc" : "testsvc" ,
509
+ ServiceMonitorSelector : & metav1.LabelSelector {
510
+ MatchLabels : map [string ]string {
511
+ "testsvc" : "testsvc" ,
512
+ },
511
513
},
512
514
},
513
515
want : & promconfig.Config {
@@ -571,8 +573,10 @@ func TestLoadConfig(t *testing.T) {
571
573
},
572
574
},
573
575
cfg : allocatorconfig.Config {
574
- PodMonitorSelector : map [string ]string {
575
- "testpod" : "testpod" ,
576
+ PodMonitorSelector : & metav1.LabelSelector {
577
+ MatchLabels : map [string ]string {
578
+ "testpod" : "testpod" ,
579
+ },
576
580
},
577
581
},
578
582
want : & promconfig.Config {
@@ -633,8 +637,10 @@ func TestLoadConfig(t *testing.T) {
633
637
},
634
638
},
635
639
cfg : allocatorconfig.Config {
636
- ServiceMonitorNamespaceSelector : map [string ]string {
637
- "label1" : "label1" ,
640
+ ServiceMonitorNamespaceSelector : & metav1.LabelSelector {
641
+ MatchLabels : map [string ]string {
642
+ "label1" : "label1" ,
643
+ },
638
644
},
639
645
},
640
646
want : & promconfig.Config {
@@ -695,8 +701,10 @@ func TestLoadConfig(t *testing.T) {
695
701
},
696
702
},
697
703
cfg : allocatorconfig.Config {
698
- PodMonitorNamespaceSelector : map [string ]string {
699
- "label1" : "label1" ,
704
+ PodMonitorNamespaceSelector : & metav1.LabelSelector {
705
+ MatchLabels : map [string ]string {
706
+ "label1" : "label1" ,
707
+ },
700
708
},
701
709
},
702
710
want : & promconfig.Config {
@@ -790,8 +798,10 @@ func TestNamespaceLabelUpdate(t *testing.T) {
790
798
}
791
799
792
800
cfg := allocatorconfig.Config {
793
- PodMonitorNamespaceSelector : map [string ]string {
794
- "label1" : "label1" ,
801
+ PodMonitorNamespaceSelector : & metav1.LabelSelector {
802
+ MatchLabels : map [string ]string {
803
+ "label1" : "label1" ,
804
+ },
795
805
},
796
806
}
797
807
@@ -1005,19 +1015,11 @@ func getTestPrometheusCRWatcher(t *testing.T, svcMonitors []*monitoringv1.Servic
1005
1015
prom := & monitoringv1.Prometheus {
1006
1016
Spec : monitoringv1.PrometheusSpec {
1007
1017
CommonPrometheusFields : monitoringv1.CommonPrometheusFields {
1008
- ScrapeInterval : monitoringv1 .Duration ("30s" ),
1009
- ServiceMonitorSelector : & metav1.LabelSelector {
1010
- MatchLabels : cfg .ServiceMonitorSelector ,
1011
- },
1012
- PodMonitorSelector : & metav1.LabelSelector {
1013
- MatchLabels : cfg .PodMonitorSelector ,
1014
- },
1015
- ServiceMonitorNamespaceSelector : & metav1.LabelSelector {
1016
- MatchLabels : cfg .ServiceMonitorNamespaceSelector ,
1017
- },
1018
- PodMonitorNamespaceSelector : & metav1.LabelSelector {
1019
- MatchLabels : cfg .PodMonitorNamespaceSelector ,
1020
- },
1018
+ ScrapeInterval : monitoringv1 .Duration ("30s" ),
1019
+ ServiceMonitorSelector : cfg .ServiceMonitorSelector ,
1020
+ PodMonitorSelector : cfg .PodMonitorSelector ,
1021
+ ServiceMonitorNamespaceSelector : cfg .ServiceMonitorNamespaceSelector ,
1022
+ PodMonitorNamespaceSelector : cfg .PodMonitorNamespaceSelector ,
1021
1023
},
1022
1024
},
1023
1025
}
@@ -1048,20 +1050,16 @@ func getTestPrometheusCRWatcher(t *testing.T, svcMonitors []*monitoringv1.Servic
1048
1050
resourceSelector := prometheus .NewResourceSelector (promOperatorLogger , prom , store , nsMonInf , operatorMetrics , eventRecorder )
1049
1051
1050
1052
return & PrometheusCRWatcher {
1051
- kubeMonitoringClient : mClient ,
1052
- k8sClient : k8sClient ,
1053
- informers : informers ,
1054
- nsInformer : nsMonInf ,
1055
- stopChannel : make (chan struct {}),
1056
- configGenerator : generator ,
1057
- podMonitorNamespaceSelector : & metav1.LabelSelector {
1058
- MatchLabels : cfg .PodMonitorNamespaceSelector ,
1059
- },
1060
- serviceMonitorNamespaceSelector : & metav1.LabelSelector {
1061
- MatchLabels : cfg .ServiceMonitorNamespaceSelector ,
1062
- },
1063
- resourceSelector : resourceSelector ,
1064
- store : store ,
1053
+ kubeMonitoringClient : mClient ,
1054
+ k8sClient : k8sClient ,
1055
+ informers : informers ,
1056
+ nsInformer : nsMonInf ,
1057
+ stopChannel : make (chan struct {}),
1058
+ configGenerator : generator ,
1059
+ podMonitorNamespaceSelector : cfg .PodMonitorNamespaceSelector ,
1060
+ serviceMonitorNamespaceSelector : cfg .ServiceMonitorNamespaceSelector ,
1061
+ resourceSelector : resourceSelector ,
1062
+ store : store ,
1065
1063
}, source
1066
1064
1067
1065
}
0 commit comments