@@ -22,6 +22,7 @@ import (
2222 gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
2323
2424 ngfAPI "github.com/nginx/nginx-gateway-fabric/v2/apis/v1alpha1"
25+ "github.com/nginx/nginx-gateway-fabric/v2/apis/v1alpha2"
2526 "github.com/nginx/nginx-gateway-fabric/v2/internal/controller/config"
2627 "github.com/nginx/nginx-gateway-fabric/v2/internal/controller/licensing/licensingfakes"
2728 "github.com/nginx/nginx-gateway-fabric/v2/internal/controller/metrics/collectors"
@@ -642,6 +643,104 @@ var _ = Describe("eventHandler", func() {
642643
643644 Expect (handler .GetLatestConfiguration ()).To (BeEmpty ())
644645 })
646+
647+ It ("should process events with volume mounts from Deployment" , func () {
648+ // Create a gateway with EffectiveNginxProxy containing Deployment VolumeMounts
649+ gatewayWithVolumeMounts := & graph.Graph {
650+ Gateways : map [types.NamespacedName ]* graph.Gateway {
651+ {Namespace : "test" , Name : "gateway" }: {
652+ Valid : true ,
653+ Source : & gatewayv1.Gateway {
654+ ObjectMeta : metav1.ObjectMeta {
655+ Name : "gateway" ,
656+ Namespace : "test" ,
657+ },
658+ },
659+ DeploymentName : types.NamespacedName {
660+ Namespace : "test" ,
661+ Name : controller .CreateNginxResourceName ("gateway" , "nginx" ),
662+ },
663+ EffectiveNginxProxy : & graph.EffectiveNginxProxy {
664+ Kubernetes : & v1alpha2.KubernetesSpec {
665+ Deployment : & v1alpha2.DeploymentSpec {
666+ Container : v1alpha2.ContainerSpec {
667+ VolumeMounts : []v1.VolumeMount {
668+ {
669+ Name : "test-volume" ,
670+ MountPath : "/etc/test" ,
671+ },
672+ },
673+ },
674+ },
675+ },
676+ },
677+ },
678+ },
679+ }
680+
681+ fakeProcessor .ProcessReturns (gatewayWithVolumeMounts )
682+
683+ e := & events.UpsertEvent {Resource : & gatewayv1.HTTPRoute {}}
684+ batch := []interface {}{e }
685+
686+ handler .HandleEventBatch (context .Background (), logr .Discard (), batch )
687+
688+ // Verify that UpdateConfig was called with the volume mounts
689+ Expect (fakeNginxUpdater .UpdateConfigCallCount ()).Should (Equal (1 ))
690+ _ , _ , volumeMounts := fakeNginxUpdater .UpdateConfigArgsForCall (0 )
691+ Expect (volumeMounts ).To (HaveLen (1 ))
692+ Expect (volumeMounts [0 ].Name ).To (Equal ("test-volume" ))
693+ Expect (volumeMounts [0 ].MountPath ).To (Equal ("/etc/test" ))
694+ })
695+
696+ It ("should process events with volume mounts from DaemonSet" , func () {
697+ // Create a gateway with EffectiveNginxProxy containing DaemonSet VolumeMounts
698+ gatewayWithVolumeMounts := & graph.Graph {
699+ Gateways : map [types.NamespacedName ]* graph.Gateway {
700+ {Namespace : "test" , Name : "gateway" }: {
701+ Valid : true ,
702+ Source : & gatewayv1.Gateway {
703+ ObjectMeta : metav1.ObjectMeta {
704+ Name : "gateway" ,
705+ Namespace : "test" ,
706+ },
707+ },
708+ DeploymentName : types.NamespacedName {
709+ Namespace : "test" ,
710+ Name : controller .CreateNginxResourceName ("gateway" , "nginx" ),
711+ },
712+ EffectiveNginxProxy : & graph.EffectiveNginxProxy {
713+ Kubernetes : & v1alpha2.KubernetesSpec {
714+ DaemonSet : & v1alpha2.DaemonSetSpec {
715+ Container : v1alpha2.ContainerSpec {
716+ VolumeMounts : []v1.VolumeMount {
717+ {
718+ Name : "daemon-volume" ,
719+ MountPath : "/var/daemon" ,
720+ },
721+ },
722+ },
723+ },
724+ },
725+ },
726+ },
727+ },
728+ }
729+
730+ fakeProcessor .ProcessReturns (gatewayWithVolumeMounts )
731+
732+ e := & events.UpsertEvent {Resource : & gatewayv1.HTTPRoute {}}
733+ batch := []interface {}{e }
734+
735+ handler .HandleEventBatch (context .Background (), logr .Discard (), batch )
736+
737+ // Verify that UpdateConfig was called with the volume mounts
738+ Expect (fakeNginxUpdater .UpdateConfigCallCount ()).Should (Equal (1 ))
739+ _ , _ , volumeMounts := fakeNginxUpdater .UpdateConfigArgsForCall (0 )
740+ Expect (volumeMounts ).To (HaveLen (1 ))
741+ Expect (volumeMounts [0 ].Name ).To (Equal ("daemon-volume" ))
742+ Expect (volumeMounts [0 ].MountPath ).To (Equal ("/var/daemon" ))
743+ })
645744})
646745
647746var _ = Describe ("getGatewayAddresses" , func () {
0 commit comments