Skip to content

Commit bc0b4c3

Browse files
author
Jelle Dijkstra
committed
First try
1 parent fa1a6df commit bc0b4c3

File tree

9 files changed

+39
-14
lines changed

9 files changed

+39
-14
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM docker.io/golang:1.24 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

6-
#COPY --from=repos ./smooth-operator /smooth-operator
6+
COPY --from=repos ./smooth-operator /smooth-operator
77
#COPY --from=repos ./ogc-specifications /ogc-specifications
88

99
WORKDIR /workspace

api/v2beta1/shared_conversion.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package v2beta1
22

33
import (
4-
"net/url"
5-
64
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
75
"github.com/pdok/mapserver-operator/internal/controller/constants"
86
smoothoperatormodel "github.com/pdok/smooth-operator/model"
97
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
8+
"net/url"
9+
"strings"
1010

1111
autoscalingv2 "k8s.io/api/autoscaling/v2"
1212
corev1 "k8s.io/api/core/v1"
1313
)
1414

15+
func fixUnicode(val string) string {
16+
return strings.ReplaceAll(val, "\\xF6", "ö")
17+
}
18+
1519
func ConvertOptionsV2ToV3(src *WMSWFSOptions) *pdoknlv3.Options {
1620
defaults := pdoknlv3.GetDefaultOptions()
1721

api/v2beta1/wfs_conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ func (src *WFS) ToV3(dst *pdoknlv3.WFS) error {
8989
}
9090

9191
allOtherCrs := []string{
92+
"EPSG:28992",
9293
"EPSG:25831",
9394
"EPSG:25832",
94-
"EPSG:28992",
9595
"EPSG:3034",
9696
"EPSG:3035",
9797
"EPSG:3857",

api/v2beta1/wms_conversion.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ func (src *WMS) ToV3(target *pdoknlv3.WMS) error {
9797
Prefix: src.Spec.General.Dataset,
9898
URL: *url,
9999
OwnerInfoRef: "pdok",
100-
Title: src.Spec.Service.Title,
101-
Abstract: src.Spec.Service.Abstract,
100+
Title: fixUnicode(src.Spec.Service.Title),
101+
Abstract: fixUnicode(src.Spec.Service.Abstract),
102102
Keywords: src.Spec.Service.Keywords,
103103
AccessConstraints: smoothoperatormodel.URL{URL: accessConstraints},
104104
},
@@ -393,8 +393,8 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
393393
}
394394

395395
topLayer = &pdoknlv3.Layer{
396-
Title: &v2Service.Title,
397-
Abstract: &v2Service.Abstract,
396+
Title: smoothoperatorutils.Pointer(fixUnicode(v2Service.Title)),
397+
Abstract: smoothoperatorutils.Pointer(fixUnicode(v2Service.Abstract)),
398398
Keywords: v2Service.Keywords,
399399
Layers: []pdoknlv3.Layer{},
400400
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(bbox),
@@ -522,10 +522,14 @@ func getDefaultWMSLayerBoundingBoxes(defaultBbox *pdoknlv3.WMSBoundingBox) []pdo
522522
}
523523

524524
func (v2Layer WMSLayer) MapToV3(v2Service WMSService) pdoknlv3.Layer {
525+
var abstract *string
526+
if v2Layer.Abstract != nil {
527+
abstract = smoothoperatorutils.Pointer(fixUnicode(*v2Layer.Abstract))
528+
}
525529
layer := pdoknlv3.Layer{
526530
Name: &v2Layer.Name,
527531
Title: v2Layer.Title,
528-
Abstract: v2Layer.Abstract,
532+
Abstract: abstract,
529533
Keywords: v2Layer.Keywords,
530534
LabelNoClip: v2Layer.LabelNoClip,
531535
Styles: []pdoknlv3.Style{},

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ require (
2424
sigs.k8s.io/yaml v1.4.0
2525
)
2626

27+
replace github.com/pdok/smooth-operator => ../smooth-operator
28+
2729
replace github.com/abbot/go-http-auth => github.com/abbot/go-http-auth v0.4.0 // for github.com/traefik/traefik/v3
2830

2931
require (

internal/controller/shared_controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package controller
33
import (
44
"context"
55
"fmt"
6+
ctrl "sigs.k8s.io/controller-runtime"
67
"strconv"
8+
"strings"
79
"time"
810

911
"github.com/pkg/errors"
@@ -25,6 +27,7 @@ import (
2527
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
2628
"github.com/pdok/mapserver-operator/internal/controller/types"
2729
smoothoperatorv1 "github.com/pdok/smooth-operator/api/v1"
30+
smoothoperatorstatus "github.com/pdok/smooth-operator/pkg/status"
2831
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
2932
corev1 "k8s.io/api/core/v1"
3033
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -35,15 +38,20 @@ const (
3538
InspireLabelKey = "pdok.nl/inspire"
3639
)
3740

38-
func setWatches(mgr *builder.TypedBuilder[reconcile.Request]) *builder.TypedBuilder[reconcile.Request] {
39-
return mgr.Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
41+
func createControllerManager(mgr ctrl.Manager, obj client.Object) *builder.TypedBuilder[reconcile.Request] {
42+
kind := obj.GetObjectKind().GroupVersionKind().Kind
43+
44+
controllerMgr := ctrl.NewControllerManagedBy(mgr).For(obj).Named(strings.ToLower(kind))
45+
controllerMgr.Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4046
Owns(&appsv1.Deployment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4147
Owns(&corev1.Service{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4248
Owns(&traefikiov1alpha1.Middleware{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4349
Owns(&traefikiov1alpha1.IngressRoute{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4450
Owns(&autoscalingv2.HorizontalPodAutoscaler{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4551
Owns(&policyv1.PodDisruptionBudget{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4652
Owns(&smoothoperatorv1.OwnerInfo{}, builder.WithPredicates(predicate.GenerationChangedPredicate{}))
53+
54+
return controllerMgr.Watches(&appsv1.ReplicaSet{}, smoothoperatorstatus.GetReplicaSetEventHandlerForObj(mgr, obj))
4755
}
4856

4957
func ttlExpired[O pdoknlv3.WMSWFS](obj O) bool {

internal/controller/status.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package controller
22

33
import (
44
"context"
5+
smoothoperatorstatus "github.com/pdok/smooth-operator/pkg/status"
56
"time"
67

78
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
@@ -71,6 +72,13 @@ func updateStatus[R Reconciler](ctx context.Context, r R, obj client.Object, con
7172
status = &any(obj).(*pdoknlv3.WMS).Status
7273
}
7374

75+
ps, err := smoothoperatorstatus.GetPodSummary(ctx, obj)
76+
if err != nil {
77+
lgr.Error(err, "unable to get pod summary for status update")
78+
return
79+
}
80+
status.PodSummary = ps
81+
7482
changed := false
7583
for _, condition := range conditions {
7684
if meta.SetStatusCondition(&status.Conditions, condition) {

internal/controller/wfs_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ package controller
2626

2727
import (
2828
"context"
29-
3029
"github.com/pdok/mapserver-operator/internal/controller/types"
3130

3231
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
@@ -131,5 +130,5 @@ func (r *WFSReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result
131130

132131
// SetupWithManager sets up the controller with the Manager.
133132
func (r *WFSReconciler) SetupWithManager(mgr ctrl.Manager) error {
134-
return setWatches(ctrl.NewControllerManagedBy(mgr).For(&pdoknlv3.WFS{}).Named("wfs")).Complete(r)
133+
return createControllerManager(mgr, &pdoknlv3.WFS{}).Complete(r)
135134
}

internal/controller/wms_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,5 @@ func mutateConfigMapOgcWebserviceProxy(r *WMSReconciler, wms *pdoknlv3.WMS, conf
212212

213213
// SetupWithManager sets up the controller with the Manager.
214214
func (r *WMSReconciler) SetupWithManager(mgr ctrl.Manager) error {
215-
return setWatches(ctrl.NewControllerManagedBy(mgr).For(&pdoknlv3.WMS{}).Named("wms")).Complete(r)
215+
return createControllerManager(mgr, &pdoknlv3.WMS{}).Complete(r)
216216
}

0 commit comments

Comments
 (0)