@@ -2,9 +2,10 @@ package webhooksupportabilitycontroller
2
2
3
3
import (
4
4
"context"
5
-
6
5
operatorv1 "github.com/openshift/api/operator/v1"
7
6
"github.com/openshift/library-go/pkg/operator/v1helpers"
7
+
8
+ apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
8
9
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
9
10
"k8s.io/apimachinery/pkg/labels"
10
11
)
@@ -21,24 +22,31 @@ func (c *webhookSupportabilityController) updateCRDConversionWebhookConfiguratio
21
22
}
22
23
var webhookInfos []webhookInfo
23
24
for _ , crd := range crds {
24
- conversion := crd .Spec .Conversion
25
- if conversion == nil || conversion .Strategy != v1 .WebhookConverter {
26
- continue
27
- }
28
- clientConfig := conversion .Webhook .ClientConfig
29
- if clientConfig == nil || clientConfig .Service == nil {
25
+ if ! hasCRDConversionWebhookConfiguration (crd ) {
30
26
continue
31
27
}
32
28
info := webhookInfo {
33
29
Name : crd .Name ,
34
- CABundle : clientConfig .CABundle ,
30
+ CABundle : crd . Spec . Conversion . Webhook . ClientConfig .CABundle ,
35
31
Service : & serviceReference {
36
- Namespace : clientConfig .Service .Namespace ,
37
- Name : clientConfig .Service .Name ,
38
- Port : clientConfig .Service .Port ,
32
+ Namespace : crd . Spec . Conversion . Webhook . ClientConfig .Service .Namespace ,
33
+ Name : crd . Spec . Conversion . Webhook . ClientConfig .Service .Name ,
34
+ Port : crd . Spec . Conversion . Webhook . ClientConfig .Service .Port ,
39
35
},
40
36
}
41
37
webhookInfos = append (webhookInfos , info )
42
38
}
43
39
return c .updateWebhookConfigurationDegraded (ctx , condition , webhookInfos )
44
40
}
41
+
42
+ func hasCRDConversionWebhookConfiguration (crd * apiextensionsv1.CustomResourceDefinition ) bool {
43
+ conversion := crd .Spec .Conversion
44
+ if conversion == nil || conversion .Strategy != v1 .WebhookConverter {
45
+ return false
46
+ }
47
+ clientConfig := conversion .Webhook .ClientConfig
48
+ if clientConfig == nil || clientConfig .Service == nil {
49
+ return false
50
+ }
51
+ return true
52
+ }
0 commit comments