Skip to content

Commit 1a27ff9

Browse files
Merge pull request #105 from PDOK/jd/status-subresource
Status subresource
2 parents fdf7e06 + 21d65f2 commit 1a27ff9

File tree

13 files changed

+139
-15
lines changed

13 files changed

+139
-15
lines changed

api/v2beta1/shared_conversion.go

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

33
import (
44
"net/url"
5+
"strings"
56

67
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
78
"github.com/pdok/mapserver-operator/internal/controller/constants"
@@ -12,6 +13,10 @@ import (
1213
corev1 "k8s.io/api/core/v1"
1314
)
1415

16+
func fixUnicode(val string) string {
17+
return strings.ReplaceAll(val, "\\xF6", "ö")
18+
}
19+
1520
func ConvertOptionsV2ToV3(src *WMSWFSOptions) *pdoknlv3.Options {
1621
defaults := pdoknlv3.GetDefaultOptions()
1722

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{},

api/v3/wfs_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ import (
4646
// versionName=v3
4747
// +kubebuilder:resource:path=wfs
4848
// +kubebuilder:resource:categories=pdok
49+
// +kubebuilder:printcolumn:name="ReadyPods",type=integer,JSONPath=`.status.podSummary[0].ready`
50+
// +kubebuilder:printcolumn:name="DesiredPods",type=integer,JSONPath=`.status.podSummary[0].total`
51+
// +kubebuilder:printcolumn:name="ReconcileStatus",type=string,JSONPath=`.status.conditions[?(@.type == "Reconciled")].reason`
4952

5053
// WFS is the Schema for the wfs API.
5154
type WFS struct {

api/v3/wms_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ const (
5555
// versionName=v3
5656
// +kubebuilder:resource:path=wms
5757
// +kubebuilder:resource:categories=pdok
58+
// +kubebuilder:printcolumn:name="ReadyPods",type=integer,JSONPath=`.status.podSummary[0].ready`
59+
// +kubebuilder:printcolumn:name="DesiredPods",type=integer,JSONPath=`.status.podSummary[0].total`
60+
// +kubebuilder:printcolumn:name="ReconcileStatus",type=string,JSONPath=`.status.conditions[?(@.type == "Reconciled")].reason`
5861

5962
// WMS is the Schema for the wms API.
6063
type WMS struct {

config/crd/bases/pdok.nl_wfs.yaml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ spec:
1616
singular: wfs
1717
scope: Namespaced
1818
versions:
19-
- name: v3
19+
- additionalPrinterColumns:
20+
- jsonPath: .status.podSummary[0].ready
21+
name: ReadyPods
22+
type: integer
23+
- jsonPath: .status.podSummary[0].total
24+
name: DesiredPods
25+
type: integer
26+
- jsonPath: .status.conditions[?(@.type == "Reconciled")].reason
27+
name: ReconcileStatus
28+
type: string
29+
name: v3
2030
schema:
2131
openAPIV3Schema:
2232
description: WFS is the Schema for the wfs API.
@@ -1138,6 +1148,33 @@ spec:
11381148
type: string
11391149
description: The result of creating or updating of each derived resource for this Atom.
11401150
type: object
1151+
podSummary:
1152+
description: Summary of status of pods that belong to this resource
1153+
items:
1154+
properties:
1155+
available:
1156+
format: int32
1157+
type: integer
1158+
generation:
1159+
format: int32
1160+
type: integer
1161+
ready:
1162+
format: int32
1163+
type: integer
1164+
total:
1165+
format: int32
1166+
type: integer
1167+
unavailable:
1168+
format: int32
1169+
type: integer
1170+
required:
1171+
- available
1172+
- generation
1173+
- ready
1174+
- total
1175+
- unavailable
1176+
type: object
1177+
type: array
11411178
type: object
11421179
required:
11431180
- spec

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ spec:
1616
singular: wms
1717
scope: Namespaced
1818
versions:
19-
- name: v3
19+
- additionalPrinterColumns:
20+
- jsonPath: .status.podSummary[0].ready
21+
name: ReadyPods
22+
type: integer
23+
- jsonPath: .status.podSummary[0].total
24+
name: DesiredPods
25+
type: integer
26+
- jsonPath: .status.conditions[?(@.type == "Reconciled")].reason
27+
name: ReconcileStatus
28+
type: string
29+
name: v3
2030
schema:
2131
openAPIV3Schema:
2232
description: WMS is the Schema for the wms API.
@@ -1721,6 +1731,33 @@ spec:
17211731
type: string
17221732
description: The result of creating or updating of each derived resource for this Atom.
17231733
type: object
1734+
podSummary:
1735+
description: Summary of status of pods that belong to this resource
1736+
items:
1737+
properties:
1738+
available:
1739+
format: int32
1740+
type: integer
1741+
generation:
1742+
format: int32
1743+
type: integer
1744+
ready:
1745+
format: int32
1746+
type: integer
1747+
total:
1748+
format: int32
1749+
type: integer
1750+
unavailable:
1751+
format: int32
1752+
type: integer
1753+
required:
1754+
- available
1755+
- generation
1756+
- ready
1757+
- total
1758+
- unavailable
1759+
type: object
1760+
type: array
17241761
type: object
17251762
required:
17261763
- spec

config/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ rules:
3535
- list
3636
- update
3737
- watch
38+
- apiGroups:
39+
- apps
40+
resources:
41+
- replicasets
42+
verbs:
43+
- get
44+
- list
45+
- watch
3846
- apiGroups:
3947
- autoscaling
4048
resources:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/pdok/featureinfo-generator v1.4.0
1414
github.com/pdok/ogc-capabilities-generator v1.0.1
1515
github.com/pdok/ogc-specifications v1.0.0
16-
github.com/pdok/smooth-operator v1.0.0
16+
github.com/pdok/smooth-operator v1.1.1
1717
github.com/peterbourgon/ff v1.7.1
1818
github.com/stretchr/testify v1.10.0
1919
github.com/traefik/traefik/v3 v3.4.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ github.com/pdok/ogc-capabilities-generator v1.0.1 h1:7cKgdcWO4y+M9a2hW8ONhmBxGER
152152
github.com/pdok/ogc-capabilities-generator v1.0.1/go.mod h1:Fnq2i1X3Aufjx/ptQ34c9knw1mDMUAQt0MTBscqX0/M=
153153
github.com/pdok/ogc-specifications v1.0.0 h1:YqVqKwgOrPprTuRcNrFJeUuxSHOIeOSQStBcYJZUGcA=
154154
github.com/pdok/ogc-specifications v1.0.0/go.mod h1:YDngwkwrWOfc5MYnEYseiv97K1Y9bZXlVzwi/8EaIl8=
155-
github.com/pdok/smooth-operator v1.0.0 h1:Gp5DG2FQ3uujxWQX/647ZcyVk2EhNZPBD+lMxpLHotI=
156-
github.com/pdok/smooth-operator v1.0.0/go.mod h1:przwM7mBGmNPqabyhImKVZ15WL4zbqLqH4ExbuWKhWE=
155+
github.com/pdok/smooth-operator v1.1.1 h1:nKLXYnZooORpBzDwjl69WplVf+2y4pu8j8qVzvepbJU=
156+
github.com/pdok/smooth-operator v1.1.1/go.mod h1:tqr/CDCXZHNzQzQVlSAnCmsPlx9tWAObsj8hg9mSSEU=
157157
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
158158
github.com/peterbourgon/ff v1.7.1 h1:xt1lxTG+Nr2+tFtysY7abFgPoH3Lug8CwYJMOmJRXhk=
159159
github.com/peterbourgon/ff v1.7.1/go.mod h1:fYI5YA+3RDqQRExmFbHnBjEeWzh9TrS8rnRpEq7XIg0=

internal/controller/shared_controller.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"strings"
88
"time"
99

10+
ctrl "sigs.k8s.io/controller-runtime"
11+
1012
"github.com/pkg/errors"
1113

1214
traefikiov1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
@@ -26,6 +28,7 @@ import (
2628
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
2729
"github.com/pdok/mapserver-operator/internal/controller/types"
2830
smoothoperatorv1 "github.com/pdok/smooth-operator/api/v1"
31+
smoothoperatorstatus "github.com/pdok/smooth-operator/pkg/status"
2932
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
3033
corev1 "k8s.io/api/core/v1"
3134
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -36,16 +39,26 @@ const (
3639
InspireLabelKey = "pdok.nl/inspire"
3740
)
3841

39-
func setWatches(mgr *builder.TypedBuilder[reconcile.Request]) *builder.TypedBuilder[reconcile.Request] {
40-
return mgr.Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
42+
func createControllerManager(mgr ctrl.Manager, obj client.Object) *builder.TypedBuilder[reconcile.Request] {
43+
var kind string
44+
switch any(obj).(type) {
45+
case *pdoknlv3.WMS:
46+
kind = "WMS"
47+
case *pdoknlv3.WFS:
48+
kind = "WFS"
49+
}
50+
51+
controllerMgr := ctrl.NewControllerManagedBy(mgr).For(obj).Named(strings.ToLower(kind))
52+
controllerMgr.Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4153
Owns(&appsv1.Deployment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
42-
WithEventFilter(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.LabelChangedPredicate{})).
4354
Owns(&corev1.Service{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4455
Owns(&traefikiov1alpha1.Middleware{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4556
Owns(&traefikiov1alpha1.IngressRoute{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4657
Owns(&autoscalingv2.HorizontalPodAutoscaler{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4758
Owns(&policyv1.PodDisruptionBudget{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
4859
Owns(&smoothoperatorv1.OwnerInfo{}, builder.WithPredicates(predicate.GenerationChangedPredicate{}))
60+
61+
return controllerMgr.Watches(&appsv1.ReplicaSet{}, smoothoperatorstatus.GetReplicaSetEventHandlerForObj(mgr, kind))
4962
}
5063

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

0 commit comments

Comments
 (0)