Skip to content

Commit 5710fb3

Browse files
committed
fixes nil errors, test data and owning reconciling
1 parent 9669e68 commit 5710fb3

File tree

6 files changed

+41
-16
lines changed

6 files changed

+41
-16
lines changed

internal/controller/capabilitiesgenerator/mapper.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,12 @@ func MapWFSToCapabilitiesGeneratorInput(wfs *pdoknlv3.WFS, ownerInfo *smoothoper
3535
return nil, err
3636
}
3737

38-
serviceVersion := mapperutils.GetLabelValueByKey(wfs.ObjectMeta.Labels, "service-version")
39-
if serviceVersion == nil {
40-
serviceVersion = mapperutils.GetLabelValueByKey(wfs.ObjectMeta.Labels, "pdok.nl/service-version")
41-
}
4238
config := capabilitiesgenerator.Config{
4339
Global: capabilitiesgenerator.Global{
4440
Namespace: mapperutils.GetNamespaceURI(wfs.Spec.Service.Prefix, ownerInfo),
4541
Prefix: wfs.Spec.Service.Prefix,
4642
Onlineresourceurl: wfs.URL().Scheme + "://" + wfs.URL().Host,
4743
Path: wfs.URL().Path,
48-
Version: *serviceVersion,
4944
},
5045
Services: capabilitiesgenerator.Services{
5146
WFS200Config: &capabilitiesgenerator.WFS200Config{
@@ -271,19 +266,13 @@ func MapWMSToCapabilitiesGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoper
271266

272267
abstract := mapperutils.EscapeQuotes(wms.Spec.Service.Abstract)
273268

274-
serviceVersion := mapperutils.GetLabelValueByKey(wms.ObjectMeta.Labels, "service-version")
275-
if serviceVersion == nil {
276-
serviceVersion = mapperutils.GetLabelValueByKey(wms.ObjectMeta.Labels, "pdok.nl/service-version")
277-
}
278-
279269
config := capabilitiesgenerator.Config{
280270
Global: capabilitiesgenerator.Global{
281271
// Prefix is unused for the WMS, but doesn't hurt to pass it
282272
Namespace: mapperutils.GetNamespaceURI(wms.Spec.Service.Prefix, ownerInfo),
283273
Prefix: wms.Spec.Service.Prefix,
284274
Onlineresourceurl: wms.URL().Scheme + "://" + wms.URL().Host,
285275
Path: wms.URL().Path,
286-
Version: *serviceVersion,
287276
},
288277
Services: capabilitiesgenerator.Services{
289278
WMS130Config: &capabilitiesgenerator.WMS130Config{

internal/controller/shared_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ func createOrUpdateConfigMap[O pdoknlv3.WMSWFS, R Reconciler](ctx context.Contex
233233
func createOrUpdateOrDeletePodDisruptionBudget[O pdoknlv3.WMSWFS, R Reconciler](ctx context.Context, reconciler R, obj O, operationResults map[string]controllerutil.OperationResult) (err error) {
234234
reconcilerClient := getReconcilerClient(reconciler)
235235
podDisruptionBudget := getBarePodDisruptionBudget(obj)
236-
if obj.HorizontalPodAutoscalerPatch().MinReplicas != nil && obj.HorizontalPodAutoscalerPatch().MaxReplicas != nil &&
237-
*obj.HorizontalPodAutoscalerPatch().MinReplicas == 1 && *obj.HorizontalPodAutoscalerPatch().MaxReplicas == 1 {
236+
autoscalerPatch := obj.HorizontalPodAutoscalerPatch()
237+
if autoscalerPatch != nil && autoscalerPatch.MinReplicas != nil && autoscalerPatch.MaxReplicas != nil &&
238+
*autoscalerPatch.MinReplicas == 1 && *autoscalerPatch.MaxReplicas == 1 {
238239
err = reconcilerClient.Delete(ctx, podDisruptionBudget)
239240
if err == nil {
240241
operationResults[smoothoperatorutils.GetObjectFullName(reconcilerClient, podDisruptionBudget)] = "deleted"

internal/controller/wfs_controller.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ package controller
2626

2727
import (
2828
"context"
29+
traefikiov1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
30+
appsv1 "k8s.io/api/apps/v1"
31+
autoscalingv2 "k8s.io/api/autoscaling/v2"
32+
corev1 "k8s.io/api/core/v1"
33+
policyv1 "k8s.io/api/policy/v1"
34+
"sigs.k8s.io/controller-runtime/pkg/builder"
35+
"sigs.k8s.io/controller-runtime/pkg/predicate"
2936

3037
"github.com/pdok/mapserver-operator/internal/controller/types"
3138

@@ -133,6 +140,14 @@ func (r *WFSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result
133140
func (r *WFSReconciler) SetupWithManager(mgr ctrl.Manager) error {
134141
return ctrl.NewControllerManagedBy(mgr).
135142
For(&pdoknlv3.WFS{}).
143+
Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
144+
Owns(&appsv1.Deployment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
145+
Owns(&corev1.Service{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
146+
Owns(&traefikiov1alpha1.Middleware{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
147+
Owns(&traefikiov1alpha1.IngressRoute{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
148+
Owns(&autoscalingv2.HorizontalPodAutoscaler{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
149+
Owns(&policyv1.PodDisruptionBudget{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
150+
Owns(&smoothoperatorv1.OwnerInfo{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
136151
Named("wfs").
137152
Complete(r)
138153
}

internal/controller/wms_controller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ package controller
2626

2727
import (
2828
"context"
29+
traefikiov1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
30+
appsv1 "k8s.io/api/apps/v1"
31+
autoscalingv2 "k8s.io/api/autoscaling/v2"
32+
policyv1 "k8s.io/api/policy/v1"
33+
"sigs.k8s.io/controller-runtime/pkg/builder"
34+
"sigs.k8s.io/controller-runtime/pkg/predicate"
2935

3036
"github.com/pdok/mapserver-operator/internal/controller/types"
3137

@@ -214,6 +220,14 @@ func mutateConfigMapOgcWebserviceProxy(r *WMSReconciler, wms *pdoknlv3.WMS, conf
214220
func (r *WMSReconciler) SetupWithManager(mgr ctrl.Manager) error {
215221
return ctrl.NewControllerManagedBy(mgr).
216222
For(&pdoknlv3.WMS{}).
223+
Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
224+
Owns(&appsv1.Deployment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
225+
Owns(&corev1.Service{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
226+
Owns(&traefikiov1alpha1.Middleware{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
227+
Owns(&traefikiov1alpha1.IngressRoute{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
228+
Owns(&autoscalingv2.HorizontalPodAutoscaler{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
229+
Owns(&policyv1.PodDisruptionBudget{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
230+
Owns(&smoothoperatorv1.OwnerInfo{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
217231
Named("wms").
218232
Complete(r)
219233
}

internal/webhook/v3/test_data/v3_wfs.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ spec:
6767
csw:
6868
metadataIdentifier: 8ec62a28-695f-4f46-a9d5-0aeb8363a0e3
6969
data:
70-
tif:
71-
blobKey: "container/prefix/file.vrt"
72-
resample: "NEAREST"
70+
postgis:
71+
tableName: table
72+
geometryType: Point
73+
columns:
74+
- name: column

internal/webhook/v3/test_data/v3_wms.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ spec:
5454
visualization: "file.style"
5555
- name: "visible Group Layer"
5656
visible: true
57+
title: title
58+
abstract: abstract
59+
keywords:
60+
- keyword
5761
styles:
5862
- name: style
5963
title: style

0 commit comments

Comments
 (0)