@@ -7,10 +7,13 @@ import (
77	"fmt" 
88	"testing" 
99
10+ 	logrtest "github.com/go-logr/logr/testr" 
1011	"github.com/stretchr/testify/require" 
1112	corev1 "k8s.io/api/core/v1" 
1213	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 
14+ 	"k8s.io/apimachinery/pkg/runtime" 
1315	"k8s.io/utils/ptr" 
16+ 	"sigs.k8s.io/controller-runtime/pkg/client/fake" 
1417	gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" 
1518
1619	"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common" 
@@ -160,8 +163,12 @@ func TestConsulDataplaneContainer_PrivilegedPorts(t *testing.T) {
160163					GRPCPort : GRPCPort ,
161164				},
162165			}
163- 
164- 			container , err  :=  consulDataplaneContainer (metrics , config , tc .gcc , tc .gateway , []corev1.VolumeMount {})
166+ 			log  :=  logrtest .New (t )
167+ 			s  :=  runtime .NewScheme ()
168+ 			objs  :=  resources {}
169+ 			client  :=  fake .NewClientBuilder ().WithScheme (s ).WithObjects (objs ... ).Build ()
170+ 			gatekeeper  :=  New (log , client , nil )
171+ 			container , err  :=  gatekeeper .consulDataplaneContainer (metrics , config , tc .gcc , tc .gateway , []corev1.VolumeMount {})
165172			require .NoError (t , err )
166173
167174			// Check command 
@@ -231,8 +238,12 @@ func TestConsulDataplaneContainer_SecurityContext(t *testing.T) {
231238			MapPrivilegedContainerPorts : 0 ,
232239		},
233240	}
234- 
235- 	container , err  :=  consulDataplaneContainer (metrics , config , gcc , gateway , []corev1.VolumeMount {})
241+ 	log  :=  logrtest .New (t )
242+ 	s  :=  runtime .NewScheme ()
243+ 	objs  :=  resources {}
244+ 	client  :=  fake .NewClientBuilder ().WithScheme (s ).WithObjects (objs ... ).Build ()
245+ 	gatekeeper  :=  New (log , client , nil )
246+ 	container , err  :=  gatekeeper .consulDataplaneContainer (metrics , config , gcc , gateway , []corev1.VolumeMount {})
236247	require .NoError (t , err )
237248
238249	// Verify all security context fields are set correctly 
@@ -296,7 +307,13 @@ func TestConsulDataplaneContainer_BasicFunctionality(t *testing.T) {
296307		},
297308	}
298309
299- 	container , err  :=  consulDataplaneContainer (metrics , config , gcc , gateway , volumeMounts )
310+ 	log  :=  logrtest .New (t )
311+ 	s  :=  runtime .NewScheme ()
312+ 	objs  :=  resources {}
313+ 	client  :=  fake .NewClientBuilder ().WithScheme (s ).WithObjects (objs ... ).Build ()
314+ 	gatekeeper  :=  New (log , client , nil )
315+ 
316+ 	container , err  :=  gatekeeper .consulDataplaneContainer (metrics , config , gcc , gateway , volumeMounts )
300317	require .NoError (t , err )
301318
302319	// Basic container properties 
0 commit comments