@@ -28,6 +28,7 @@ import (
2828func TestValidatingWebhookConfigurationStore (t * testing.T ) {
2929 startTime := 1501569018
3030 metav1StartTime := metav1 .Unix (int64 (startTime ), 0 )
31+ externalURL := "example.com"
3132
3233 cases := []generateMetricsTestCase {
3334 {
@@ -69,6 +70,37 @@ func TestValidatingWebhookConfigurationStore(t *testing.T) {
6970 ` ,
7071 MetricNames : []string {"kube_validatingwebhookconfiguration_created" , "kube_validatingwebhookconfiguration_info" , "kube_validatingwebhookconfiguration_metadata_resource_version" },
7172 },
73+ {
74+ Obj : & admissionregistrationv1.ValidatingWebhookConfiguration {
75+ ObjectMeta : metav1.ObjectMeta {
76+ Name : "validatingwebhookconfiguration3" ,
77+ Namespace : "ns3" ,
78+ CreationTimestamp : metav1StartTime ,
79+ ResourceVersion : "abcdef" ,
80+ },
81+ Webhooks : []admissionregistrationv1.ValidatingWebhook {
82+ {
83+ Name : "webhook_with_service" ,
84+ ClientConfig : admissionregistrationv1.WebhookClientConfig {
85+ Service : & admissionregistrationv1.ServiceReference {Name : "svc" , Namespace : "ns" },
86+ },
87+ },
88+ {
89+ Name : "webhook_with_external_url" ,
90+ ClientConfig : admissionregistrationv1.WebhookClientConfig {
91+ URL : & externalURL ,
92+ },
93+ },
94+ },
95+ },
96+ Want : `
97+ # HELP kube_validatingwebhookconfiguration_webhook_clientconfig_service Service used by the apiserver to connect to a validating webhook.
98+ # TYPE kube_validatingwebhookconfiguration_webhook_clientconfig_service gauge
99+ kube_validatingwebhookconfiguration_webhook_clientconfig_service{webhook_name="webhook_with_external_url",namespace="ns3",service_name="",service_namespace="",validatingwebhookconfiguration="validatingwebhookconfiguration3"} 1
100+ kube_validatingwebhookconfiguration_webhook_clientconfig_service{webhook_name="webhook_with_service",namespace="ns3",service_name="svc",service_namespace="ns",validatingwebhookconfiguration="validatingwebhookconfiguration3"} 1
101+ ` ,
102+ MetricNames : []string {"kube_validatingwebhookconfiguration_webhook_clientconfig_service" },
103+ },
72104 }
73105 for i , c := range cases {
74106 c .Func = generator .ComposeMetricGenFuncs (validatingWebhookConfigurationMetricFamilies )
0 commit comments