@@ -25,11 +25,9 @@ import (
2525 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2727 "k8s.io/apimachinery/pkg/runtime"
28- "k8s.io/apimachinery/pkg/types"
2928 "k8s.io/apimachinery/pkg/util/intstr"
3029 yamlutil "k8s.io/apimachinery/pkg/util/yaml"
3130 "k8s.io/utils/ptr"
32- k8sYaml "sigs.k8s.io/yaml"
3331
3432 runtimeCli "sigs.k8s.io/controller-runtime/pkg/client"
3533 "sigs.k8s.io/controller-runtime/pkg/log"
@@ -81,50 +79,8 @@ func installOperator(ctx context.Context, cli runtimeCli.Client, ns string, opts
8179 Expect (cli .Create (ctx , o )).To (Succeed ())
8280 }
8381
84- GinkgoWriter .Printf ("Waiting for webhook-server-tls Secret to be ready...\n " )
85- Eventually (func (ctx context.Context ) error {
86- secret := & v1.Secret {}
87- return cli .Get (ctx , types.NamespacedName {Name : "webhook-server-tls" , Namespace : ns }, secret )
88- }).WithContext (ctx ).Should (Succeed (), "Failed to wait for webhook-server-tls Secret to be created by Cert-Manager." )
89-
90- GinkgoWriter .Printf ("Waiting for ValidatingWebhookConfiguration caBundle injection...\n " )
91- Eventually (func (ctx context.Context ) (bool , error ) {
92- webhookConfig := & admissionv1.ValidatingWebhookConfiguration {}
93- err := cli .Get (ctx , types.NamespacedName {Name : "validation.securesigns.rhtas.redhat.com" }, webhookConfig )
94- if err != nil {
95- return false , err
96- }
97- if len (webhookConfig .Webhooks ) > 0 && len (webhookConfig .Webhooks [0 ].ClientConfig .CABundle ) > 0 {
98- return true , nil
99- }
100- return false , nil
101- }).WithContext (ctx ).Should (BeTrue (), "Cert-Manager failed to inject CA bundle into Webhook Config." )
102-
10382 Expect (cli .Create (ctx , managerPod (ns , opts ... ))).To (Succeed ())
10483
105- GinkgoWriter .Printf ("Waiting for manager Pod to appear...\n " )
106- Eventually (func (ctx context.Context ) error {
107- pod := & v1.Pod {}
108- return cli .Get (ctx , types.NamespacedName {Name : managerPodName , Namespace : ns }, pod )
109- }).WithContext (ctx ).Should (Succeed (), "Manager Pod failed to appear in API server after creation." )
110-
111- GinkgoWriter .Printf ("Waiting for Service Endpoints to appear...\n " )
112- Eventually (func (ctx context.Context ) error {
113- endpoints := & v1.Endpoints {}
114- err := cli .Get (ctx , types.NamespacedName {Name : "controller-manager-webhook-service" , Namespace : ns }, endpoints )
115-
116- if err != nil {
117- return err
118- }
119-
120- if len (endpoints .Subsets ) == 0 || len (endpoints .Subsets [0 ].Addresses ) == 0 {
121- return fmt .Errorf ("webhook service has no ready endpoints yet" )
122- }
123-
124- return nil
125- }).WithContext (ctx ).WithTimeout (1 * time .Minute ).Should (Succeed (),
126- "Webhook service failed to register a ready endpoint." )
127-
12884 time .Sleep (1 * time .Minute )
12985
13086}
@@ -341,7 +297,12 @@ func webhookInfra(ns string) []runtimeCli.Object {
341297 service ["namespace" ] = ns
342298
343299 webhooks [0 ] = webhook
344- unstructured .SetNestedSlice (u .Object , webhooks , "webhooks" )
300+ err = unstructured .SetNestedSlice (u .Object , webhooks , "webhooks" )
301+
302+ if err != nil {
303+ Fail (fmt .Errorf ("failed to set Namespace on ValidatingWebhookConfiguration resource: %w" , err ).Error ())
304+ }
305+
345306 }
346307
347308 if kind == "Certificate" {
@@ -361,14 +322,6 @@ func webhookInfra(ns string) []runtimeCli.Object {
361322 }
362323 }
363324
364- finalYAML , err := k8sYaml .Marshal (u .Object )
365- if err != nil {
366- GinkgoWriter .Printf ("Warning: Failed to marshal object %s/%s for debugging: %v\n " , kind , u .GetName (), err )
367- } else {
368- GinkgoWriter .Printf ("\n --- YAML DEBUG START: %s/%s ---\n %s\n --- YAML DEBUG END ---\n " ,
369- kind , u .GetName (), string (finalYAML ))
370- }
371-
372325 objects = append (objects , u )
373326 }
374327 }
0 commit comments