Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v3/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type WMSWFS interface {

// URL returns the configured service URL
URL() smoothoperatormodel.URL
IngressRouteURLs() smoothoperatormodel.IngressRouteURLs
IngressRouteURLs(includeServiceURLWhenEmpty bool) smoothoperatormodel.IngressRouteURLs

// DatasetMetadataIds returns list of all configured metadata identifiers configured on Layers or Featuretypes
DatasetMetadataIDs() []string
Expand Down
36 changes: 23 additions & 13 deletions api/v3/shared_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,33 @@ func ValidateUpdate[W WMSWFS](newW, oldW W, validate func(W, *[]string, *field.E
warnings := []string{}
allErrs := field.ErrorList{}

// Check that the ingressRouteUrls contain the base url and no urls have been removed
err := sharedValidation.ValidateIngressRouteURLsContainsBaseURL(newW.IngressRouteURLs(), newW.URL(), nil)
if err != nil {
allErrs = append(allErrs, err)
// Make sure no ingressRouteURLs have been removed
sharedValidation.ValidateIngressRouteURLsNotRemoved(oldW.IngressRouteURLs(true), newW.IngressRouteURLs(true), &allErrs, nil)

if len(newW.IngressRouteURLs(false)) == 0 {
// There are no ingressRouteURLs given, spec.service.url is immutable is that case.
path := field.NewPath("spec").Child("service").Child("url")
sharedValidation.CheckURLImmutability(
oldW.URL(),
newW.URL(),
&allErrs,
path,
)
} else if oldW.URL().String() != newW.URL().String() {
// Make sure both the old spec.service.url and the new one are included in the ingressRouteURLs list.
err := sharedValidation.ValidateIngressRouteURLsContainsBaseURL(newW.IngressRouteURLs(true), oldW.URL(), nil)
if err != nil {
allErrs = append(allErrs, err)
}

err = sharedValidation.ValidateIngressRouteURLsContainsBaseURL(newW.IngressRouteURLs(true), newW.URL(), nil)
if err != nil {
allErrs = append(allErrs, err)
}
}
sharedValidation.ValidateIngressRouteURLsNotRemoved(oldW.IngressRouteURLs(), newW.IngressRouteURLs(), &allErrs, nil)

sharedValidation.ValidateLabelsOnUpdate(oldW.GetLabels(), newW.GetLabels(), &allErrs)

path := field.NewPath("spec").Child("service").Child("url")
sharedValidation.CheckUrlImmutability(
oldW.URL(),
newW.URL(),
&allErrs,
path,
)

if (newW.Inspire() == nil && oldW.Inspire() != nil) || (newW.Inspire() != nil && oldW.Inspire() == nil) {
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec").Child("service").Child("inspire"), "cannot change from inspire to not inspire or the other way around"))
}
Expand Down
8 changes: 6 additions & 2 deletions api/v3/wfs_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,13 @@ func (wfs *WFS) ReadinessQueryString() (string, string, error) {
return "SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=" + wfs.Spec.Service.FeatureTypes[0].Name + "&STARTINDEX=0&COUNT=1", "text/xml", nil
}

func (wfs *WFS) IngressRouteURLs() smoothoperatormodel.IngressRouteURLs {
func (wfs *WFS) IngressRouteURLs(includeServiceURLWhenEmpty bool) smoothoperatormodel.IngressRouteURLs {
if len(wfs.Spec.IngressRouteURLs) == 0 {
return smoothoperatormodel.IngressRouteURLs{{URL: wfs.Spec.Service.URL}}
if includeServiceURLWhenEmpty {
return smoothoperatormodel.IngressRouteURLs{{URL: wfs.Spec.Service.URL}}
}

return smoothoperatormodel.IngressRouteURLs{}
}

return wfs.Spec.IngressRouteURLs
Expand Down
8 changes: 6 additions & 2 deletions api/v3/wms_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,13 @@ func (wms *WMS) ReadinessQueryString() (string, string, error) {
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
}

func (wms *WMS) IngressRouteURLs() smoothoperatormodel.IngressRouteURLs {
func (wms *WMS) IngressRouteURLs(includeServiceURLWhenEmpty bool) smoothoperatormodel.IngressRouteURLs {
if len(wms.Spec.IngressRouteURLs) == 0 {
return smoothoperatormodel.IngressRouteURLs{{URL: wms.Spec.Service.URL}}
if includeServiceURLWhenEmpty {
return smoothoperatormodel.IngressRouteURLs{{URL: wms.Spec.Service.URL}}
}

return smoothoperatormodel.IngressRouteURLs{}
}

return wms.Spec.IngressRouteURLs
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/pdok/featureinfo-generator v1.4.0-beta1
github.com/pdok/ogc-capabilities-generator v1.0.0-beta8
github.com/pdok/ogc-specifications v1.0.0-beta9
github.com/pdok/smooth-operator v0.1.2
github.com/pdok/smooth-operator v0.1.3
github.com/peterbourgon/ff v1.7.1
github.com/stretchr/testify v1.10.0
github.com/traefik/traefik/v3 v3.3.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ github.com/pdok/ogc-capabilities-generator v1.0.0-beta8 h1:8UAv64fArp8wjpwuRIzjj
github.com/pdok/ogc-capabilities-generator v1.0.0-beta8/go.mod h1:2yUZlJikf5gGH6S33FszUiI9+j85gpIINfAFsCF/eNk=
github.com/pdok/ogc-specifications v1.0.0-beta9 h1:VrdggKg4d2tSway/deztAfZTviXKX0AftfUuZTXx5j8=
github.com/pdok/ogc-specifications v1.0.0-beta9/go.mod h1:YDngwkwrWOfc5MYnEYseiv97K1Y9bZXlVzwi/8EaIl8=
github.com/pdok/smooth-operator v0.1.2 h1:ibGRgFjKysu665IUToQhs34hHhptftI+7RBFrGNw4nQ=
github.com/pdok/smooth-operator v0.1.2/go.mod h1:przwM7mBGmNPqabyhImKVZ15WL4zbqLqH4ExbuWKhWE=
github.com/pdok/smooth-operator v0.1.3 h1:Y+JvbFLlyb6pMNFVgAd8G6QsXL0Y6F0srTaROabRnm0=
github.com/pdok/smooth-operator v0.1.3/go.mod h1:przwM7mBGmNPqabyhImKVZ15WL4zbqLqH4ExbuWKhWE=
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
github.com/peterbourgon/ff v1.7.1 h1:xt1lxTG+Nr2+tFtysY7abFgPoH3Lug8CwYJMOmJRXhk=
github.com/peterbourgon/ff v1.7.1/go.mod h1:fYI5YA+3RDqQRExmFbHnBjEeWzh9TrS8rnRpEq7XIg0=
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/ingressroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func mutateIngressRoute[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, ingressRout

ingressRoute.Spec.Routes = []traefikiov1alpha1.Route{}
if obj.Type() == pdoknlv3.ServiceTypeWMS {
for _, ingressRouteURL := range obj.IngressRouteURLs() {
for _, ingressRouteURL := range obj.IngressRouteURLs(true) {
ingressRoute.Spec.Routes = append(ingressRoute.Spec.Routes, makeRoute(getLegendMatchRule(ingressRouteURL.URL), mapserverService, middlewareRef))

if obj.Options().UseWebserviceProxy() {
Expand All @@ -108,7 +108,7 @@ func mutateIngressRoute[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O, ingressRout
}
}
} else { // WFS
for _, ingressRouteURL := range obj.IngressRouteURLs() {
for _, ingressRouteURL := range obj.IngressRouteURLs(true) {
ingressRoute.Spec.Routes = append(ingressRoute.Spec.Routes, makeRoute(getMatchRule(ingressRouteURL.URL), mapserverService, middlewareRef))
}
}
Expand Down