Skip to content

Commit f7baa58

Browse files
author
Jelle Dijkstra
committed
URL aliases
1 parent a6db5dd commit f7baa58

File tree

19 files changed

+181
-78
lines changed

19 files changed

+181
-78
lines changed

api/v3/shared_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type WMSWFS interface {
4848

4949
// URLPath returns the configured service URL
5050
URL() smoothoperatormodel.URL
51+
IngressRouteURLs() smoothoperatormodel.IngressRouteURLs
5152

5253
GeoPackages() []*Gpkg
5354

api/v3/shared_validation.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ func ValidateUpdate[W WMSWFS](newW, oldW W, validate func(W, *[]string, *field.E
1111
warnings := []string{}
1212
allErrs := field.ErrorList{}
1313

14+
// Check that the ingressRouteUrls contain the base url and no urls have been removed
15+
err := sharedValidation.ValidateIngressRouteURLsContainsBaseURL(newW.IngressRouteURLs(), newW.URL(), nil)
16+
if err != nil {
17+
allErrs = append(allErrs, err)
18+
}
19+
sharedValidation.ValidateIngressRouteURLsNotRemoved(oldW.IngressRouteURLs(), newW.IngressRouteURLs(), &allErrs, nil)
20+
1421
sharedValidation.ValidateLabelsOnUpdate(oldW.GetLabels(), newW.GetLabels(), &allErrs)
1522

1623
path := field.NewPath("spec").Child("service").Child("url")

api/v3/wfs_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func init() {
7070
}
7171

7272
// WFSSpec vertegenwoordigt de hoofdstruct voor de YAML-configuratie
73+
// +kubebuilder:validation:XValidation:rule="!has(self.ingressRouteUrls) || self.ingressRouteUrls.exists_one(x, x.url == self.service.url)",messageExpression="'ingressRouteUrls should include service.url '+self.service.url"
7374
type WFSSpec struct {
7475
// Optional lifecycle settings
7576
Lifecycle *smoothoperatormodel.Lifecycle `json:"lifecycle,omitempty"`
@@ -86,6 +87,10 @@ type WFSSpec struct {
8687
// Custom healthcheck options
8788
HealthCheck *HealthCheckWFS `json:"healthCheck,omitempty"`
8889

90+
// Optional list of URLs where the service can be reached
91+
// By default only the spec.service.url is used
92+
IngressRouteURLs smoothoperatormodel.IngressRouteURLs `json:"ingressRouteUrls,omitempty"`
93+
8994
// service configuration
9095
Service WFSService `json:"service"`
9196
}
@@ -299,3 +304,11 @@ func (wfs *WFS) ReadinessQueryString() (string, string, error) {
299304

300305
return "SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=" + wfs.Spec.Service.FeatureTypes[0].Name + "&STARTINDEX=0&COUNT=1", "text/xml", nil
301306
}
307+
308+
func (wfs *WFS) IngressRouteURLs() smoothoperatormodel.IngressRouteURLs {
309+
if len(wfs.Spec.IngressRouteURLs) == 0 {
310+
return smoothoperatormodel.IngressRouteURLs{{URL: wfs.Spec.Service.URL}}
311+
}
312+
313+
return wfs.Spec.IngressRouteURLs
314+
}

api/v3/wfs_validation.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func (wfs *WFS) ValidateCreate() ([]string, error) {
2121
allErrs = append(allErrs, err)
2222
}
2323

24+
err = sharedValidation.ValidateIngressRouteURLsContainsBaseURL(wfs.Spec.IngressRouteURLs, wfs.URL(), nil)
25+
if err != nil {
26+
allErrs = append(allErrs, err)
27+
}
28+
2429
ValidateWFS(wfs, &warnings, &allErrs)
2530

2631
if len(allErrs) == 0 {

api/v3/wms_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
5050

5151
// WMSSpec defines the desired state of WMS.
52+
// +kubebuilder:validation:XValidation:rule="!has(self.ingressRouteUrls) || self.ingressRouteUrls.exists_one(x, x.url == self.service.url)",messageExpression="'ingressRouteUrls should include service.url '+self.service.url"
5253
type WMSSpec struct {
5354
// Optional lifecycle settings
5455
Lifecycle *smoothoperatormodel.Lifecycle `json:"lifecycle,omitempty"`
@@ -69,6 +70,10 @@ type WMSSpec struct {
6970
// Custom healthcheck options
7071
HealthCheck *HealthCheckWMS `json:"healthCheck,omitempty"`
7172

73+
// Optional list of URLs where the service can be reached
74+
// By default only the spec.service.url is used
75+
IngressRouteURLs smoothoperatormodel.IngressRouteURLs `json:"ingressRouteUrls,omitempty"`
76+
7277
// Service specification
7378
Service WMSService `json:"service"`
7479
}
@@ -669,3 +674,11 @@ func (wms *WMS) ReadinessQueryString() (string, string, error) {
669674

670675
return fmt.Sprintf("SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=%s&CRS=EPSG:28992&WIDTH=100&HEIGHT=100&LAYERS=%s&STYLES=&FORMAT=image/png", wms.HealthCheckBBox(), firstDataLayerName), "image/png", nil
671676
}
677+
678+
func (wms *WMS) IngressRouteURLs() smoothoperatormodel.IngressRouteURLs {
679+
if len(wms.Spec.IngressRouteURLs) == 0 {
680+
return smoothoperatormodel.IngressRouteURLs{{URL: wms.Spec.Service.URL}}
681+
}
682+
683+
return wms.Spec.IngressRouteURLs
684+
}

api/v3/wms_validation.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func (wms *WMS) ValidateCreate() ([]string, error) {
2121
allErrs = append(allErrs, err)
2222
}
2323

24+
err = sharedValidation.ValidateIngressRouteURLsContainsBaseURL(wms.Spec.IngressRouteURLs, wms.URL(), nil)
25+
if err != nil {
26+
allErrs = append(allErrs, err)
27+
}
28+
2429
ValidateWMS(wms, &warnings, &allErrs)
2530

2631
if len(allErrs) == 0 {

api/v3/zz_generated.deepcopy.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/pdok.nl_wfs.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,21 @@ spec:
10611061
required:
10621062
- maxReplicas
10631063
type: object
1064+
ingressRouteUrls:
1065+
description: |-
1066+
Optional list of URLs where the service can be reached
1067+
By default only the spec.service.url is used
1068+
items:
1069+
properties:
1070+
url:
1071+
pattern: ^https?://.+/.+
1072+
type: string
1073+
required:
1074+
- url
1075+
type: object
1076+
maxItems: 30
1077+
minItems: 1
1078+
type: array
10641079
lifecycle:
10651080
description: Optional lifecycle settings
10661081
properties:
@@ -1555,6 +1570,10 @@ spec:
15551570
- podSpecPatch
15561571
- service
15571572
type: object
1573+
x-kubernetes-validations:
1574+
- messageExpression: '''ingressRouteUrls should include service.url ''+self.service.url'
1575+
rule: '!has(self.ingressRouteUrls) || self.ingressRouteUrls.exists_one(x,
1576+
x.url == self.service.url)'
15581577
status:
15591578
description: OperatorStatus defines the observed state of an Atom/WFS/WMS/....
15601579
properties:

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,21 @@ spec:
10871087
required:
10881088
- maxReplicas
10891089
type: object
1090+
ingressRouteUrls:
1091+
description: |-
1092+
Optional list of URLs where the service can be reached
1093+
By default only the spec.service.url is used
1094+
items:
1095+
properties:
1096+
url:
1097+
pattern: ^https?://.+/.+
1098+
type: string
1099+
required:
1100+
- url
1101+
type: object
1102+
maxItems: 30
1103+
minItems: 1
1104+
type: array
10901105
lifecycle:
10911106
description: Optional lifecycle settings
10921107
properties:
@@ -2148,6 +2163,9 @@ spec:
21482163
- podSpecPatch
21492164
- service
21502165
type: object
2166+
x-kubernetes-validations:
2167+
- messageExpression: '''ingressRouteUrls should include service.url ''+self.service.url'
2168+
rule: '!has(self.ingressRouteUrls) || self.ingressRouteUrls.exists_one(x, x.url == self.service.url)'
21512169
status:
21522170
description: OperatorStatus defines the observed state of an Atom/WFS/WMS/....
21532171
properties:

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-beta1
1414
github.com/pdok/ogc-capabilities-generator v1.0.0-beta8
1515
github.com/pdok/ogc-specifications v1.0.0-beta9
16-
github.com/pdok/smooth-operator v0.1.1
16+
github.com/pdok/smooth-operator v0.1.2
1717
github.com/peterbourgon/ff v1.7.1
1818
github.com/stretchr/testify v1.10.0
1919
github.com/traefik/traefik/v3 v3.3.4

0 commit comments

Comments
 (0)