@@ -23,21 +23,14 @@ import (
23
23
24
24
. "github.com/onsi/ginkgo/v2" //lint:ignore ST1001 Ignoring this for now
25
25
. "github.com/onsi/gomega" //lint:ignore ST1001 Ignoring this for now
26
- apiadmissionregistrationv1 "k8s.io/api/admissionregistration/v1"
27
26
corev1 "k8s.io/api/core/v1"
28
27
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
29
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
28
"k8s.io/client-go/kubernetes/scheme"
31
- "k8s.io/utils/pointer"
32
29
ctrl "sigs.k8s.io/controller-runtime"
33
30
"sigs.k8s.io/controller-runtime/pkg/client"
34
31
"sigs.k8s.io/controller-runtime/pkg/envtest"
35
32
logf "sigs.k8s.io/controller-runtime/pkg/log"
36
33
"sigs.k8s.io/controller-runtime/pkg/log/zap"
37
- "sigs.k8s.io/controller-runtime/pkg/webhook"
38
- "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
39
- "sigs.k8s.io/hierarchical-namespaces/internal/objects"
40
- "sigs.k8s.io/hierarchical-namespaces/internal/webhooks"
41
34
42
35
// +kubebuilder:scaffold:imports
43
36
@@ -76,28 +69,8 @@ func HNCBeforeSuite() {
76
69
SetDefaultEventuallyTimeout (time .Second * 4 )
77
70
78
71
By ("configuring test environment" )
79
- sideEffectClassNone := apiadmissionregistrationv1 .SideEffectClassNone
80
72
testEnv = & envtest.Environment {
81
73
CRDDirectoryPaths : []string {filepath .Join (".." , ".." , "config" , "crd" , "bases" )},
82
- WebhookInstallOptions : envtest.WebhookInstallOptions {
83
- ValidatingWebhooks : []* apiadmissionregistrationv1.ValidatingWebhookConfiguration {{
84
- ObjectMeta : metav1.ObjectMeta {
85
- Name : webhooks .ValidatingWebhookConfigurationName ,
86
- },
87
- Webhooks : []apiadmissionregistrationv1.ValidatingWebhook {{
88
- Name : webhooks .ObjectsWebhookName ,
89
- AdmissionReviewVersions : []string {"v1" },
90
- SideEffects : & sideEffectClassNone ,
91
- ClientConfig : apiadmissionregistrationv1.WebhookClientConfig {
92
- Service : & apiadmissionregistrationv1.ServiceReference {
93
- Namespace : "system" ,
94
- Name : "webhook-service" ,
95
- Path : pointer .String (objects .ServingPath ),
96
- },
97
- },
98
- }},
99
- }},
100
- },
101
74
}
102
75
103
76
By ("starting test environment" )
@@ -121,20 +94,13 @@ func HNCBeforeSuite() {
121
94
// CF: https://github.com/microsoft/azure-databricks-operator/blob/0f722a710fea06b86ecdccd9455336ca712bf775/controllers/suite_test.go
122
95
123
96
By ("creating manager" )
124
- webhookInstallOptions := & testEnv .WebhookInstallOptions
125
97
k8sManager , err := ctrl .NewManager (cfg , ctrl.Options {
126
98
NewClient : config .NewClient (false ),
127
99
MetricsBindAddress : "0" , // disable metrics serving since 'go test' runs multiple suites in parallel processes
128
100
Scheme : scheme .Scheme ,
129
- Host : webhookInstallOptions .LocalServingHost ,
130
- Port : webhookInstallOptions .LocalServingPort ,
131
- CertDir : webhookInstallOptions .LocalServingCertDir ,
132
101
})
133
102
Expect (err ).ToNot (HaveOccurred ())
134
103
135
- // Register a dummy webhook since the test control plane is to test reconcilers
136
- k8sManager .GetWebhookServer ().Register (objects .ServingPath , & webhook.Admission {Handler : & allowAllHandler {}})
137
-
138
104
By ("creating reconcilers" )
139
105
opts := setup.Options {
140
106
MaxReconciles : 100 ,
@@ -159,12 +125,6 @@ func HNCBeforeSuite() {
159
125
}()
160
126
}
161
127
162
- type allowAllHandler struct {}
163
-
164
- func (a allowAllHandler ) Handle (_ context.Context , _ admission.Request ) admission.Response {
165
- return webhooks .Allow ("All requests are allowed by allowAllHandler" )
166
- }
167
-
168
128
func HNCAfterSuite () {
169
129
if k8sManagerCancelFn != nil {
170
130
k8sManagerCancelFn ()
0 commit comments