diff --git a/internal/controller/capabilitiesgenerator/mapper.go b/internal/controller/capabilitiesgenerator/mapper.go index 172be4a..ce93c30 100644 --- a/internal/controller/capabilitiesgenerator/mapper.go +++ b/internal/controller/capabilitiesgenerator/mapper.go @@ -62,7 +62,7 @@ func MapWFSToCapabilitiesGeneratorInput(wfs *pdoknlv3.WFS, ownerInfo *smoothoper if wfs.Spec.Service.Inspire != nil { config.Global.AdditionalSchemaLocations = inspireSchemaLocations - metadataURL, _ := replaceMustachTemplate(ownerInfo.Spec.MetadataUrls.CSW.HrefTemplate, wfs.Spec.Service.Inspire.ServiceMetadataURL.CSW.MetadataIdentifier) + metadataURL, _ := replaceMustacheTemplate(ownerInfo.Spec.MetadataUrls.CSW.HrefTemplate, wfs.Spec.Service.Inspire.ServiceMetadataURL.CSW.MetadataIdentifier) config.Services.WFS200Config.Wfs200.Capabilities.OperationsMetadata = &wfs200.OperationsMetadata{ ExtendedCapabilities: &wfs200.ExtendedCapabilities{ @@ -106,7 +106,7 @@ func getFeatureTypeList(wfs *pdoknlv3.WFS, ownerInfo *smoothoperatorv1.OwnerInfo otherCRS = append(otherCRS, CRS) } - metadataURL, err := replaceMustachTemplate(ownerInfo.Spec.MetadataUrls.CSW.HrefTemplate, fType.DatasetMetadataURL.CSW.MetadataIdentifier) + metadataURL, err := replaceMustacheTemplate(ownerInfo.Spec.MetadataUrls.CSW.HrefTemplate, fType.DatasetMetadataURL.CSW.MetadataIdentifier) if err != nil { return nil, err } @@ -148,7 +148,7 @@ func createCRSFromEpsgString(epsgString string) (*wfs200.CRS, error) { }, nil } -func replaceMustachTemplate(hrefTemplate string, identifier string) (string, error) { +func replaceMustacheTemplate(hrefTemplate string, identifier string) (string, error) { templateVariable := map[string]string{"identifier": identifier} return mustache.Render(hrefTemplate, templateVariable) } @@ -165,8 +165,6 @@ func mapServiceProvider(provider *smoothoperatorv1.ServiceProvider) (serviceProv } } - // TODO fix linting (nestif) - //nolint:nestif if provider.ServiceContact != nil { serviceProvider.ServiceContact = &wfs200.ServiceContact{ IndividualName: provider.ServiceContact.IndividualName, @@ -174,39 +172,44 @@ func mapServiceProvider(provider *smoothoperatorv1.ServiceProvider) (serviceProv Role: provider.ServiceContact.Role, } if provider.ServiceContact.ContactInfo != nil { - serviceProvider.ServiceContact.ContactInfo = &wfs200.ContactInfo{ - Text: provider.ServiceContact.ContactInfo.Text, - HoursOfService: provider.ServiceContact.ContactInfo.HoursOfService, - ContactInstructions: provider.ServiceContact.ContactInfo.ContactInstructions, - } - if provider.ServiceContact.ContactInfo.Phone != nil { - serviceProvider.ServiceContact.ContactInfo.Phone = &wfs200.Phone{ - Voice: provider.ServiceContact.ContactInfo.Phone.Voice, - Facsimile: provider.ServiceContact.ContactInfo.Phone.Facsimile, - } - } - if provider.ServiceContact.ContactInfo.Address != nil { - serviceProvider.ServiceContact.ContactInfo.Address = &wfs200.Address{ - DeliveryPoint: provider.ServiceContact.ContactInfo.Address.DeliveryPoint, - City: provider.ServiceContact.ContactInfo.Address.City, - AdministrativeArea: provider.ServiceContact.ContactInfo.Address.AdministrativeArea, - PostalCode: provider.ServiceContact.ContactInfo.Address.PostalCode, - Country: provider.ServiceContact.ContactInfo.Address.Country, - ElectronicMailAddress: provider.ServiceContact.ContactInfo.Address.ElectronicMailAddress, - } - } - if provider.ServiceContact.ContactInfo.OnlineResource != nil { - serviceProvider.ServiceContact.ContactInfo.OnlineResource = &wfs200.OnlineResource{ - Type: provider.ServiceContact.ContactInfo.OnlineResource.Type, - Href: provider.ServiceContact.ContactInfo.OnlineResource.Href, - } - } + serviceProvider.ServiceContact.ContactInfo = mapContactInfo(*provider.ServiceContact.ContactInfo) } } return serviceProvider } +func mapContactInfo(contactInfo smoothoperatorv1.ContactInfo) (serviceContactInfo *wfs200.ContactInfo) { + serviceContactInfo = &wfs200.ContactInfo{ + Text: contactInfo.Text, + HoursOfService: contactInfo.HoursOfService, + ContactInstructions: contactInfo.ContactInstructions, + } + if contactInfo.Phone != nil { + serviceContactInfo.Phone = &wfs200.Phone{ + Voice: contactInfo.Phone.Voice, + Facsimile: contactInfo.Phone.Facsimile, + } + } + if contactInfo.Address != nil { + serviceContactInfo.Address = &wfs200.Address{ + DeliveryPoint: contactInfo.Address.DeliveryPoint, + City: contactInfo.Address.City, + AdministrativeArea: contactInfo.Address.AdministrativeArea, + PostalCode: contactInfo.Address.PostalCode, + Country: contactInfo.Address.Country, + ElectronicMailAddress: contactInfo.Address.ElectronicMailAddress, + } + } + if contactInfo.OnlineResource != nil { + serviceContactInfo.OnlineResource = &wfs200.OnlineResource{ + Type: contactInfo.OnlineResource.Type, + Href: contactInfo.OnlineResource.Href, + } + } + return +} + func MapWMSToCapabilitiesGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoperatorv1.OwnerInfo) (*capabilitiesgenerator.Config, error) { hostBaseURL := "https://service.pdok.nl" canonicalServiceURL := hostBaseURL + "/" + pdoknlv3.GetBaseURLPath(wms) @@ -271,7 +274,7 @@ func MapWMSToCapabilitiesGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoper if wms.Spec.Service.Inspire != nil { config.Global.AdditionalSchemaLocations = inspireSchemaLocations - metadataURL, _ := replaceMustachTemplate(ownerInfo.Spec.MetadataUrls.CSW.HrefTemplate, wms.Spec.Service.Inspire.ServiceMetadataURL.CSW.MetadataIdentifier) + metadataURL, _ := replaceMustacheTemplate(ownerInfo.Spec.MetadataUrls.CSW.HrefTemplate, wms.Spec.Service.Inspire.ServiceMetadataURL.CSW.MetadataIdentifier) defaultLanguage := wms130.Language{Language: wms.Spec.Service.Inspire.Language} diff --git a/internal/controller/shared_controller.go b/internal/controller/shared_controller.go index 54335e4..4cd3f7a 100644 --- a/internal/controller/shared_controller.go +++ b/internal/controller/shared_controller.go @@ -59,8 +59,11 @@ const ( ) var ( - AppLabelKey = "app" - MapserverName = "mapserver" + AppLabelKey = "app" + MapserverName = "mapserver" + LegendGeneratorName = "legend-generator" + FeatureInfoGeneratorName = "featureinfo-generator" + OgcWebserviceProxyName = "ogc-webservice-proxy" // Service ports mapserverPortName = "mapserver" @@ -126,7 +129,7 @@ func getSharedBareObjects[O pdoknlv3.WMSWFS](obj O) []client.Object { getBareIngressRoute(obj), getBareHorizontalPodAutoScaler(obj), getBareConfigMapBlobDownload(obj), - getBareConfigMap(obj), + getBareConfigMap(obj, MapserverName), getBareService(obj), getBareCorsHeadersMiddleware(obj), getBarePodDisruptionBudget(obj), @@ -790,7 +793,7 @@ func mutateService[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, service *corev1. if obj.Type() == pdoknlv3.ServiceTypeWMS { if obj.Options().UseWebserviceProxy() { ports = append(ports, corev1.ServicePort{ - Name: "ogc-webservice-proxy", + Name: OgcWebserviceProxyName, Port: 9111, }) } @@ -888,10 +891,10 @@ func mutatePodDisruptionBudget[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, podD return ctrl.SetControllerReference(obj, podDisruptionBudget, getReconcilerScheme(r)) } -func getBareConfigMap[O pdoknlv3.WMSWFS](obj O) *corev1.ConfigMap { +func getBareConfigMap[O pdoknlv3.WMSWFS](obj O, name string) *corev1.ConfigMap { return &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: getSuffixedName(obj, MapserverName), + Name: getSuffixedName(obj, name), Namespace: obj.GetNamespace(), }, } @@ -1032,7 +1035,7 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con // region ConfigMap { - configMap := getBareConfigMap(obj) + configMap := getBareConfigMap(obj, MapserverName) if err = mutateConfigMap(r, obj, configMap); err != nil { return operationResults, err } @@ -1094,60 +1097,33 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con } // end region ConfigMap-BlobDownload - // TODO fix linting (nestif) - //nolint:nestif if obj.Type() == pdoknlv3.ServiceTypeWMS { wms, _ := any(obj).(*pdoknlv3.WMS) wmsReconciler := (*WMSReconciler)(r) - // region ConfigMap-LegendGenerator - { - configMapLg := getBareConfigMapLegendGenerator(wms) - if err = mutateConfigMapLegendGenerator(wmsReconciler, wms, configMapLg); err != nil { - return operationResults, err - } - operationResults[smoothoperatorutils.GetObjectFullName(reconcilerClient, configMapLg)], err = controllerutil.CreateOrUpdate(ctx, reconcilerClient, configMapLg, func() error { - return mutateConfigMapLegendGenerator(wmsReconciler, wms, configMapLg) + configMaps := make(map[string]func(*WMSReconciler, *pdoknlv3.WMS, *corev1.ConfigMap) error) + configMaps[LegendGeneratorName] = mutateConfigMapLegendGenerator + configMaps[FeatureInfoGeneratorName] = mutateConfigMapFeatureinfoGenerator + configMaps[OgcWebserviceProxyName] = mutateConfigMapOgcWebserviceProxy + for cmName, mutate := range configMaps { + cm, or, err := getConfigMap(ctx, wms, wmsReconciler, cmName, func(r *WMSReconciler, w *pdoknlv3.WMS, cm *corev1.ConfigMap) error { + return mutate(r, w, cm) }) - if err != nil { - return operationResults, fmt.Errorf("unable to create/update resource %s: %w", smoothoperatorutils.GetObjectFullName(reconcilerClient, configMapLg), err) - } - hashedConfigMapNames.LegendGenerator = configMapLg.Name - } - // end region ConfigMap-LegendGenerator - - // region ConfigMap-FeatureinfoGenerator - { - configMapFig := getBareConfigMapFeatureinfoGenerator(wms) - if err = mutateConfigMapFeatureinfoGenerator(wmsReconciler, wms, configMapFig); err != nil { - return operationResults, err + if or != nil { + operationResults[smoothoperatorutils.GetObjectFullName(reconcilerClient, cm)] = *or } - operationResults[smoothoperatorutils.GetObjectFullName(reconcilerClient, configMapFig)], err = controllerutil.CreateOrUpdate(ctx, reconcilerClient, configMapFig, func() error { - return mutateConfigMapFeatureinfoGenerator(wmsReconciler, wms, configMapFig) - }) if err != nil { - return operationResults, fmt.Errorf("unable to create/update resource %s: %w", smoothoperatorutils.GetObjectFullName(reconcilerClient, configMapFig), err) - } - hashedConfigMapNames.FeatureInfoGenerator = configMapFig.Name - } - - // end region ConfigMap-FeatureinfoGenerator - - // region ConfigMap-OgcWebserviceProxy - { - configMapOwp := getBareConfigMapOgcWebserviceProxy(wms) - if err = mutateConfigMapOgcWebserviceProxy(wmsReconciler, wms, configMapOwp); err != nil { return operationResults, err } - operationResults[smoothoperatorutils.GetObjectFullName(reconcilerClient, configMapOwp)], err = controllerutil.CreateOrUpdate(ctx, reconcilerClient, configMapOwp, func() error { - return mutateConfigMapOgcWebserviceProxy(wmsReconciler, wms, configMapOwp) - }) - if err != nil { - return operationResults, fmt.Errorf("unable to create/update resource %s: %w", smoothoperatorutils.GetObjectFullName(reconcilerClient, configMapOwp), err) + switch cmName { + case LegendGeneratorName: + hashedConfigMapNames.LegendGenerator = cm.Name + case FeatureInfoGeneratorName: + hashedConfigMapNames.FeatureInfoGenerator = cm.Name + case OgcWebserviceProxyName: + hashedConfigMapNames.OgcWebserviceProxy = cm.Name } - hashedConfigMapNames.OgcWebserviceProxy = configMapOwp.Name } - // end region ConfigMap-OgcWebserviceProxy } // region Deployment @@ -1231,6 +1207,21 @@ func createOrUpdateAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Con return operationResults, nil } +func getConfigMap[O pdoknlv3.WMSWFS, R Reconciler](ctx context.Context, obj O, reconciler R, name string, mutate func(R, O, *corev1.ConfigMap) error) (*corev1.ConfigMap, *controllerutil.OperationResult, error) { + reconcilerClient := getReconcilerClient(reconciler) + cm := getBareConfigMap(obj, name) + if err := mutate(reconciler, obj, cm); err != nil { + return cm, nil, err + } + or, err := controllerutil.CreateOrUpdate(ctx, reconcilerClient, cm, func() error { + return mutate(reconciler, obj, cm) + }) + if err != nil { + return cm, &or, fmt.Errorf("unable to create/update resource %s: %w", smoothoperatorutils.GetObjectFullName(reconcilerClient, cm), err) + } + return cm, &or, nil +} + // TODO fix linting (funlen) // //nolint:funlen @@ -1246,7 +1237,7 @@ func deleteAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Context, r } // ConfigMap - cm := getBareConfigMap(obj) + cm := getBareConfigMap(obj, MapserverName) err = mutateConfigMap(r, obj, cm) if err != nil { return err @@ -1282,7 +1273,7 @@ func deleteAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Context, r wmsReconciler := (*WMSReconciler)(r) // ConfigMap-LegendGenerator - cmLg := getBareConfigMapLegendGenerator(wms) + cmLg := getBareConfigMap(wms, LegendGeneratorName) err = mutateConfigMapLegendGenerator(wmsReconciler, wms, cmLg) if err != nil { return err @@ -1290,7 +1281,7 @@ func deleteAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Context, r objects = append(objects, cmLg) // ConfigMap-FeatureInfo - cmFi := getBareConfigMapFeatureinfoGenerator(wms) + cmFi := getBareConfigMap(wms, FeatureInfoGeneratorName) err = mutateConfigMapFeatureinfoGenerator(wmsReconciler, wms, cmFi) if err != nil { return err @@ -1298,7 +1289,7 @@ func deleteAllForWMSWFS[R Reconciler, O pdoknlv3.WMSWFS](ctx context.Context, r objects = append(objects, cmFi) // ConfigMap-OgcWebserviceProxy - cmOwp := getBareConfigMapOgcWebserviceProxy(wms) + cmOwp := getBareConfigMap(wms, OgcWebserviceProxyName) err = mutateConfigMapOgcWebserviceProxy(wmsReconciler, wms, cmOwp) if err != nil { return err diff --git a/internal/controller/shared_controller_test.go b/internal/controller/shared_controller_test.go index bcacf5e..9c11769 100644 --- a/internal/controller/shared_controller_test.go +++ b/internal/controller/shared_controller_test.go @@ -51,7 +51,7 @@ func getExpectedObjects[O pdoknlv3.WMSWFS](ctx context.Context, obj O, includeBl } // Add all ConfigMaps with hashed names - cm := getBareConfigMap(obj) + cm := getBareConfigMap(obj, MapserverName) hashedName, err := getHashedConfigMapNameFromClient(ctx, obj, mapserver.ConfigMapVolumeName) if err != nil { return objects, err @@ -87,7 +87,7 @@ func getExpectedObjects[O pdoknlv3.WMSWFS](ctx context.Context, obj O, includeBl if obj.Type() == pdoknlv3.ServiceTypeWMS { wms, _ := any(obj).(*pdoknlv3.WMS) - cm = getBareConfigMapLegendGenerator(wms) + cm = getBareConfigMap(wms, LegendGeneratorName) hashedName, err = getHashedConfigMapNameFromClient(ctx, obj, mapserver.ConfigMapLegendGeneratorVolumeName) if err != nil { return objects, err @@ -95,7 +95,7 @@ func getExpectedObjects[O pdoknlv3.WMSWFS](ctx context.Context, obj O, includeBl cm.Name = hashedName objects = append(objects, cm) - cm = getBareConfigMapFeatureinfoGenerator(wms) + cm = getBareConfigMap(wms, FeatureInfoGeneratorName) hashedName, err = getHashedConfigMapNameFromClient(ctx, obj, mapserver.ConfigMapFeatureinfoGeneratorVolumeName) if err != nil { return objects, err @@ -104,7 +104,7 @@ func getExpectedObjects[O pdoknlv3.WMSWFS](ctx context.Context, obj O, includeBl objects = append(objects, cm) if obj.Options().UseWebserviceProxy() { - cm = getBareConfigMapOgcWebserviceProxy(wms) + cm = getBareConfigMap(wms, OgcWebserviceProxyName) hashedName, err = getHashedConfigMapNameFromClient(ctx, obj, mapserver.ConfigMapOgcWebserviceProxyVolumeName) if err != nil { return objects, err diff --git a/internal/controller/wfs_controller.go b/internal/controller/wfs_controller.go index d88d6af..0e112ea 100644 --- a/internal/controller/wfs_controller.go +++ b/internal/controller/wfs_controller.go @@ -67,7 +67,6 @@ type WFSReconciler struct { // // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.0/pkg/reconcile -// TODO fix linting (dupl) // //nolint:dupl func (r *WFSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) { diff --git a/internal/controller/wfs_controller_test.go b/internal/controller/wfs_controller_test.go index 8c608e8..a1b895f 100644 --- a/internal/controller/wfs_controller_test.go +++ b/internal/controller/wfs_controller_test.go @@ -372,7 +372,7 @@ var _ = Describe("WFS Controller", func() { By("Reconciling the WFS and checking the configMap") reconcileWFS(controllerReconciler, wfs, typeNamespacedNameWfs) - configMap := getBareConfigMap(wfs) + configMap := getBareConfigMap(wfs, MapserverName) configMapName, err := getHashedConfigMapNameFromClient(ctx, wfs, mapserver.ConfigMapVolumeName) Expect(err).NotTo(HaveOccurred()) Eventually(func() bool { diff --git a/internal/controller/wms_controller.go b/internal/controller/wms_controller.go index e3539d7..2ae2397 100644 --- a/internal/controller/wms_controller.go +++ b/internal/controller/wms_controller.go @@ -34,7 +34,6 @@ import ( smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -78,7 +77,6 @@ type WMSReconciler struct { // // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.0/pkg/reconcile -// TODO fix linting (dupl) // //nolint:dupl func (r *WMSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) { @@ -136,15 +134,6 @@ func (r *WMSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result return result, err } -func getBareConfigMapLegendGenerator(obj *pdoknlv3.WMS) *corev1.ConfigMap { - return &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: getSuffixedName(obj, "legend-generator"), - Namespace: obj.GetNamespace(), - }, - } -} - func mutateConfigMapLegendGenerator(r *WMSReconciler, wms *pdoknlv3.WMS, configMap *corev1.ConfigMap) error { labels := addCommonLabels(wms, smoothoperatorutils.CloneOrEmptyMap(wms.GetLabels())) if err := smoothoperatorutils.SetImmutableLabels(r.Client, configMap, labels); err != nil { @@ -166,15 +155,6 @@ func mutateConfigMapLegendGenerator(r *WMSReconciler, wms *pdoknlv3.WMS, configM } -func getBareConfigMapFeatureinfoGenerator(obj *pdoknlv3.WMS) *corev1.ConfigMap { - return &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: getSuffixedName(obj, "featureinfo-generator"), - Namespace: obj.GetNamespace(), - }, - } -} - func mutateConfigMapFeatureinfoGenerator(r *WMSReconciler, wms *pdoknlv3.WMS, configMap *corev1.ConfigMap) error { labels := addCommonLabels(wms, smoothoperatorutils.CloneOrEmptyMap(wms.GetLabels())) if err := smoothoperatorutils.SetImmutableLabels(r.Client, configMap, labels); err != nil { @@ -199,15 +179,6 @@ func mutateConfigMapFeatureinfoGenerator(r *WMSReconciler, wms *pdoknlv3.WMS, co return smoothoperatorutils.AddHashSuffix(configMap) } -func getBareConfigMapOgcWebserviceProxy(obj *pdoknlv3.WMS) *corev1.ConfigMap { - return &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: getSuffixedName(obj, "ogc-webservice-proxy"), - Namespace: obj.GetNamespace(), - }, - } -} - func mutateConfigMapOgcWebserviceProxy(r *WMSReconciler, wms *pdoknlv3.WMS, configMap *corev1.ConfigMap) error { labels := addCommonLabels(wms, smoothoperatorutils.CloneOrEmptyMap(wms.GetLabels())) diff --git a/internal/controller/wms_controller_test.go b/internal/controller/wms_controller_test.go index 7cfa011..5548970 100644 --- a/internal/controller/wms_controller_test.go +++ b/internal/controller/wms_controller_test.go @@ -265,7 +265,7 @@ var _ = Describe("WMS Controller", func() { Expect(containerMapserver.StartupProbe.TimeoutSeconds).Should(Equal(int32(10))) containerOgcWebserviceProxy := deployment.Spec.Template.Spec.Containers[2] - Expect(containerOgcWebserviceProxy.Name).Should(Equal("ogc-webservice-proxy")) + Expect(containerOgcWebserviceProxy.Name).Should(Equal(OgcWebserviceProxyName)) ogcWebserviceProxyCommands := []string{"/ogc-webservice-proxy", "-h=http://127.0.0.1/", "-t=wms", "-s=/input/service-config.yaml", "-v", "-d=15"} Expect(containerOgcWebserviceProxy.Command).Should(Equal(ogcWebserviceProxyCommands)) Expect(containerOgcWebserviceProxy.Image).Should(Equal(reconcilerImages.OgcWebserviceProxyImage)) @@ -326,11 +326,11 @@ var _ = Describe("WMS Controller", func() { } Expect(capabilitiesGeneratorContainer.Env).Should(Equal(env)) - featureinfoGeneratorContainer, err := getInitContainer("featureinfo-generator", deployment) + featureinfoGeneratorContainer, err := getInitContainer(FeatureInfoGeneratorName, deployment) Expect(err).NotTo(HaveOccurred()) Expect(featureinfoGeneratorContainer.Image).Should(Equal(reconcilerImages.FeatureinfoGeneratorImage)) Expect(featureinfoGeneratorContainer.ImagePullPolicy).Should(Equal(corev1.PullIfNotPresent)) - Expect(featureinfoGeneratorContainer.Command).Should(Equal([]string{"featureinfo-generator"})) + Expect(featureinfoGeneratorContainer.Command).Should(Equal([]string{FeatureInfoGeneratorName})) volumeMounts = []corev1.VolumeMount{ {Name: "base", MountPath: "/srv/data", ReadOnly: false}, {Name: mapserver.ConfigMapFeatureinfoGeneratorVolumeName, MountPath: "/input", ReadOnly: true}, @@ -338,7 +338,7 @@ var _ = Describe("WMS Controller", func() { Expect(featureinfoGeneratorContainer.VolumeMounts).Should(Equal(volumeMounts)) Expect(len(featureinfoGeneratorContainer.Args)).Should(BeNumerically("==", 6)) - legendGeneratorContainer, err := getInitContainer("legend-generator", deployment) + legendGeneratorContainer, err := getInitContainer(LegendGeneratorName, deployment) Expect(err).NotTo(HaveOccurred()) Expect(legendGeneratorContainer.Image).Should(Equal(reconcilerImages.MapserverImage)) Expect(legendGeneratorContainer.ImagePullPolicy).Should(Equal(corev1.PullIfNotPresent)) @@ -473,7 +473,7 @@ var _ = Describe("WMS Controller", func() { } Expect(legendFixerContainer.VolumeMounts).Should(Equal(volumeMounts)) - configMap := getBareConfigMapLegendGenerator(wms) + configMap := getBareConfigMap(wms, LegendGeneratorName) configMapName, err := getHashedConfigMapNameFromClient(ctx, wms, mapserver.ConfigMapLegendGeneratorVolumeName) Expect(err).NotTo(HaveOccurred()) Eventually(func() bool { @@ -528,7 +528,7 @@ var _ = Describe("WMS Controller", func() { Expect(err).NotTo(HaveOccurred()) containerOgcWebserviceProxy := deployment.Spec.Template.Spec.Containers[2] - Expect(containerOgcWebserviceProxy.Name).Should(Equal("ogc-webservice-proxy")) + Expect(containerOgcWebserviceProxy.Name).Should(Equal(OgcWebserviceProxyName)) ogcWebserviceProxyCommands := []string{"/ogc-webservice-proxy", "-h=http://127.0.0.1/", "-t=wms", "-s=/input/service-config.yaml", "-d=15"} Expect(containerOgcWebserviceProxy.Command).Should(Equal(ogcWebserviceProxyCommands)) Expect(containerOgcWebserviceProxy.ImagePullPolicy).Should(Equal(corev1.PullIfNotPresent)) @@ -548,7 +548,7 @@ var _ = Describe("WMS Controller", func() { By("Reconciling the WMS and checking the configMap") reconcileWMS(controllerReconciler, wms, typeNamespacedNameWms) - configMap := getBareConfigMap(wms) + configMap := getBareConfigMap(wms, MapserverName) configMapName, err := getHashedConfigMapNameFromClient(ctx, wms, mapserver.ConfigMapVolumeName) Expect(err).NotTo(HaveOccurred()) Eventually(func() bool { @@ -661,7 +661,7 @@ var _ = Describe("WMS Controller", func() { By("Reconciling the WMS and checking the configMap") reconcileWMS(controllerReconciler, wms, typeNamespacedNameWms) - configMap := getBareConfigMapLegendGenerator(wms) + configMap := getBareConfigMap(wms, LegendGeneratorName) configMapName, err := getHashedConfigMapNameFromClient(ctx, wms, mapserver.ConfigMapLegendGeneratorVolumeName) Expect(err).NotTo(HaveOccurred()) Eventually(func() bool { @@ -688,7 +688,7 @@ var _ = Describe("WMS Controller", func() { By("Reconciling the WMS and checking the configMap") reconcileWMS(controllerReconciler, wms, typeNamespacedNameWms) - configMap := getBareConfigMapFeatureinfoGenerator(wms) + configMap := getBareConfigMap(wms, FeatureInfoGeneratorName) configMapName, err := getHashedConfigMapNameFromClient(ctx, wms, mapserver.ConfigMapFeatureinfoGeneratorVolumeName) Expect(err).NotTo(HaveOccurred()) Eventually(func() bool { @@ -841,7 +841,7 @@ var _ = Describe("WMS Controller", func() { Protocol: corev1.ProtocolTCP, }, { - Name: "ogc-webservice-proxy", + Name: OgcWebserviceProxyName, Port: 9111, TargetPort: intstr.FromInt32(9111), Protocol: "TCP", @@ -943,7 +943,7 @@ var _ = Describe("WMS Controller", func() { {Name: "mapfile", MountPath: "/srv/data/config/mapfile"}, {Name: mapserver.ConfigMapLegendGeneratorVolumeName, MountPath: "/input", ReadOnly: true}, } - legendGeneratorContainer, _ := getInitContainer("legend-generator", deployment) + legendGeneratorContainer, _ := getInitContainer(LegendGeneratorName, deployment) Expect(legendGeneratorContainer.VolumeMounts).Should(Equal(volumeMounts))