@@ -38,6 +38,7 @@ import (
3838 smoothoperatorsamples "github.com/pdok/smooth-operator/config/samples"
3939 smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
4040 traefikiov1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
41+ appsv1 "k8s.io/api/apps/v1"
4142 v2 "k8s.io/api/autoscaling/v2"
4243 v1 "k8s.io/api/core/v1"
4344 k8serrors "k8s.io/apimachinery/pkg/api/errors"
@@ -261,17 +262,8 @@ var _ = Describe("WMS Controller", func() {
261262 /**
262263 Init container tests
263264 */
264- getInitContainer := func (name string ) (v1.Container , error ) {
265- for _ , container := range deployment .Spec .Template .Spec .InitContainers {
266- if container .Name == name {
267- return container , nil
268- }
269- }
270265
271- return v1.Container {}, fmt .Errorf ("init container with name %s not found" , name )
272- }
273-
274- blobDownloadContainer , err := getInitContainer ("blob-download" )
266+ blobDownloadContainer , err := getInitContainer ("blob-download" , deployment )
275267 Expect (err ).NotTo (HaveOccurred ())
276268 Expect (blobDownloadContainer .Image ).Should (Equal (reconcilerImages .MultitoolImage ))
277269 volumeMounts := []v1.VolumeMount {
@@ -288,7 +280,7 @@ var _ = Describe("WMS Controller", func() {
288280 Expect (blobDownloadContainer .Command ).Should (Equal ([]string {"/bin/sh" , "-c" }))
289281 Expect (len (blobDownloadContainer .Args )).Should (BeNumerically (">" , 0 ))
290282
291- mapfileGeneratorContainer , err := getInitContainer ("mapfile-generator" )
283+ mapfileGeneratorContainer , err := getInitContainer ("mapfile-generator" , deployment )
292284 Expect (err ).NotTo (HaveOccurred ())
293285 Expect (mapfileGeneratorContainer .Image ).Should (Equal (reconcilerImages .MapfileGeneratorImage ))
294286 volumeMounts = []v1.VolumeMount {
@@ -299,7 +291,7 @@ var _ = Describe("WMS Controller", func() {
299291 Expect (mapfileGeneratorContainer .Command ).Should (Equal ([]string {"generate-mapfile" }))
300292 Expect (mapfileGeneratorContainer .Args ).Should (Equal ([]string {"--not-include" , "wms" , "/input/input.json" , "/srv/data/config/mapfile" }))
301293
302- capabilitiesGeneratorContainer , err := getInitContainer ("capabilities-generator" )
294+ capabilitiesGeneratorContainer , err := getInitContainer ("capabilities-generator" , deployment )
303295 Expect (err ).NotTo (HaveOccurred ())
304296 Expect (capabilitiesGeneratorContainer .Image ).Should (Equal (reconcilerImages .CapabilitiesGeneratorImage ))
305297 volumeMounts = []v1.VolumeMount {
@@ -388,6 +380,40 @@ var _ = Describe("WMS Controller", func() {
388380 Expect (err ).To (HaveOccurred ())
389381 })
390382
383+ It ("Should not mount a ogc web service proxy configmap if options.REWRITEGROUPTODATALAYERS is FALSE." , func () {
384+ wmsResource := & pdoknlv3.WMS {}
385+ wmsResource .Namespace = namespace
386+ wmsResource .Name = typeNamespacedNameWms .Name
387+ err := k8sClient .Get (ctx , typeNamespacedNameWms , wmsResource )
388+ Expect (client .IgnoreNotFound (err )).NotTo (HaveOccurred ())
389+
390+ By ("Cleanup the specific resource instance WMS" )
391+ Expect (k8sClient .Delete (ctx , wmsResource )).To (Succeed ())
392+
393+ sampleWms , err := getUniqueWMSSample (counter )
394+ counter ++
395+ typeNamespacedNameWms .Name = sampleWms .Name
396+ Expect (err ).NotTo (HaveOccurred ())
397+ sampleWms .Spec .Options .RewriteGroupToDataLayers = smoothoperatorutils .Pointer (false )
398+ //sampleWms.Spec.Options.DisableWebserviceProxy = smoothoperatorutils.Pointer(true)
399+
400+ Expect (k8sClient .Create (ctx , sampleWms .DeepCopy ())).To (Succeed ())
401+ Expect (k8sClient .Get (ctx , typeNamespacedNameWms , wms )).To (Succeed ())
402+
403+ controllerReconciler := getWMSReconciler ()
404+
405+ By ("Reconciling the WMS and checking the configMap" )
406+ reconcileWMS (controllerReconciler , wms , typeNamespacedNameWms )
407+ deployment := & appsv1.Deployment {}
408+ err = k8sClient .Get (ctx , types.NamespacedName {Namespace : namespace , Name : getBareDeployment (wms , MapserverName ).GetName ()}, deployment )
409+ Expect (err ).NotTo (HaveOccurred ())
410+ blobDownloadContainer , err := getInitContainer ("blob-download" , deployment )
411+ Expect (blobDownloadContainer .Name ).To (BeEquivalentTo ("blob-download" ))
412+ legendFixer , err := getInitContainer ("legend-fixer" , deployment )
413+ Expect (err ).To (HaveOccurred ())
414+ Expect (legendFixer .Name ).To (BeEquivalentTo ("" ))
415+ })
416+
391417 It ("Should create correct configMap manifest." , func () {
392418 controllerReconciler := getWMSReconciler ()
393419
@@ -845,3 +871,13 @@ func checkWMSLabels(labelSets ...map[string]string) {
845871 Expect (labelSet ).To (Equal (expectedLabels ))
846872 }
847873}
874+
875+ func getInitContainer (name string , deployment * appsv1.Deployment ) (v1.Container , error ) {
876+ for _ , container := range deployment .Spec .Template .Spec .InitContainers {
877+ if container .Name == name {
878+ return container , nil
879+ }
880+ }
881+
882+ return v1.Container {}, fmt .Errorf ("init container with name %s not found" , name )
883+ }
0 commit comments