Skip to content

Commit d36f2a8

Browse files
Merge pull request #73 from PDOK/jd/aliasses
URL aliases
2 parents 458f4de + f7baa58 commit d36f2a8

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
@@ -14,6 +14,13 @@ func ValidateUpdate[W WMSWFS](newW, oldW W, validate func(W, *[]string, *field.E
1414
warnings := []string{}
1515
allErrs := field.ErrorList{}
1616

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

1926
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
}
@@ -301,3 +306,11 @@ func (wfs *WFS) ReadinessQueryString() (string, string, error) {
301306

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

api/v3/wfs_validation.go

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

22+
err = sharedValidation.ValidateIngressRouteURLsContainsBaseURL(wfs.Spec.IngressRouteURLs, wfs.URL(), nil)
23+
if err != nil {
24+
allErrs = append(allErrs, err)
25+
}
26+
2227
ValidateWFS(wfs, &warnings, &allErrs)
2328

2429
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
}
@@ -670,3 +675,11 @@ func (wms *WMS) ReadinessQueryString() (string, string, error) {
670675

671676
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
672677
}
678+
679+
func (wms *WMS) IngressRouteURLs() smoothoperatormodel.IngressRouteURLs {
680+
if len(wms.Spec.IngressRouteURLs) == 0 {
681+
return smoothoperatormodel.IngressRouteURLs{{URL: wms.Spec.Service.URL}}
682+
}
683+
684+
return wms.Spec.IngressRouteURLs
685+
}

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
@@ -1064,6 +1064,21 @@ spec:
10641064
format: int32
10651065
type: integer
10661066
type: object
1067+
ingressRouteUrls:
1068+
description: |-
1069+
Optional list of URLs where the service can be reached
1070+
By default only the spec.service.url is used
1071+
items:
1072+
properties:
1073+
url:
1074+
pattern: ^https?://.+/.+
1075+
type: string
1076+
required:
1077+
- url
1078+
type: object
1079+
maxItems: 30
1080+
minItems: 1
1081+
type: array
10671082
lifecycle:
10681083
description: Optional lifecycle settings
10691084
properties:
@@ -1558,6 +1573,10 @@ spec:
15581573
- podSpecPatch
15591574
- service
15601575
type: object
1576+
x-kubernetes-validations:
1577+
- messageExpression: '''ingressRouteUrls should include service.url ''+self.service.url'
1578+
rule: '!has(self.ingressRouteUrls) || self.ingressRouteUrls.exists_one(x,
1579+
x.url == self.service.url)'
15611580
status:
15621581
description: OperatorStatus defines the observed state of an Atom/WFS/WMS/....
15631582
properties:

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,21 @@ spec:
10851085
format: int32
10861086
type: integer
10871087
type: object
1088+
ingressRouteUrls:
1089+
description: |-
1090+
Optional list of URLs where the service can be reached
1091+
By default only the spec.service.url is used
1092+
items:
1093+
properties:
1094+
url:
1095+
pattern: ^https?://.+/.+
1096+
type: string
1097+
required:
1098+
- url
1099+
type: object
1100+
maxItems: 30
1101+
minItems: 1
1102+
type: array
10881103
lifecycle:
10891104
description: Optional lifecycle settings
10901105
properties:
@@ -2147,6 +2162,9 @@ spec:
21472162
- podSpecPatch
21482163
- service
21492164
type: object
2165+
x-kubernetes-validations:
2166+
- messageExpression: '''ingressRouteUrls should include service.url ''+self.service.url'
2167+
rule: '!has(self.ingressRouteUrls) || self.ingressRouteUrls.exists_one(x, x.url == self.service.url)'
21502168
status:
21512169
description: OperatorStatus defines the observed state of an Atom/WFS/WMS/....
21522170
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)