Skip to content

Commit e1c21ba

Browse files
author
Jelle Dijkstra
committed
WFS validation
1 parent c1f950e commit e1c21ba

File tree

16 files changed

+509
-658
lines changed

16 files changed

+509
-658
lines changed

PROJECT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ resources:
3333
conversion: true
3434
spoke:
3535
- v2beta1
36+
validation: true
3637
webhookVersion: v1
3738
- api:
3839
crdVersion: v1

api/v3/wfs_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ type WFSService struct {
8686
Title string `json:"title"`
8787
Abstract string `json:"abstract"`
8888
Keywords []string `json:"keywords"`
89-
Fees *string `json:"fees"`
89+
Fees *string `json:"fees,omitempty"`
9090
AccessConstraints string `json:"accessConstraints"`
9191
DefaultCrs string `json:"defaultCrs"`
9292
OtherCrs []string `json:"otherCrs,omitempty"`
93-
Bbox *Bbox `json:"bbox"`
93+
Bbox *Bbox `json:"bbox,omitempty"`
9494
// CountDefault -> wfs_maxfeatures in mapfile
95-
CountDefault *string `json:"countDefault"`
95+
CountDefault *string `json:"countDefault,omitempty"`
9696
FeatureTypes []FeatureType `json:"featureTypes"`
9797
}
9898

build-push-deploy-locally.sh

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,60 @@
11
#!/bin/bash
22

3+
function wait_for_resource() {
4+
local sleep=3
5+
local resource="$1"
6+
local name="$2"
7+
local namespace="${3:-}"
8+
local jsonpath="${4:-}"
9+
local grep="${5:-}"
10+
args=("$resource" "$name")
11+
if [ "$namespace" == "all" ]; then
12+
args+=("--all-namespaces")
13+
elif [ -n "$namespace" ]; then
14+
args+=("-n" "$namespace")
15+
fi
16+
if [ -n "$jsonpath" ]; then
17+
args+=("-o" "jsonpath=$jsonpath")
18+
fi
19+
echo "Polling for $resource $name in $namespace"
20+
if [ -z "$grep" ]; then
21+
until kubectl get "${args[@]}"; do echo "..." && sleep "$sleep"; done
22+
else
23+
until kubectl get "${args[@]}" | grep -q -- "$grep"; do echo "..." && sleep "$sleep"; done
24+
fi
25+
}
26+
327
TAG=$1
428

529
echo "Running: make generate"
630
make generate
731

832
echo ""
9-
echo "Running: build -t local-registry:5000/wfs-wms-operator:$TAG --build-context repos=./.. ."
10-
docker build -t "local-registry:5000/wfs-wms-operator:$TAG" --build-context repos=./.. .
33+
echo "Running: build -t local-registry:5000/mapserver-operator:$TAG --build-context repos=./.. ."
34+
docker build -t "local-registry:5000/mapserver-operator:$TAG" --build-context repos=./.. .
1135

1236
echo ""
13-
echo "Running: push local-registry:5000/wfs-wms-operator:$TAG"
14-
docker push "local-registry:5000/wfs-wms-operator:$TAG"
37+
echo "Running: push local-registry:5000/mapserver-operator:$TAG"
38+
docker push "local-registry:5000/mapserver-operator:$TAG"
1539

16-
echo ""
17-
echo "Installing cert-manager"
18-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.17.0/cert-manager.yaml
40+
if [[ $(kubectl get pod -l app=webhook -n cert-manager | grep "cert-manager") ]]; then
41+
echo "Cert-manager already installed"
42+
else
43+
echo ""
44+
echo "Installing cert-manager"
45+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.17.0/cert-manager.yaml
46+
fi
47+
48+
echo "Waiting for cert-manager"
49+
while [[ $(kubectl get pod -l app=webhook -n cert-manager -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do
50+
sleep 1
51+
done
52+
echo "Cert-manager ready"
1953

2054
echo ""
2155
echo "Running: make install"
2256
make install
2357

2458
echo ""
25-
echo "Running: deploy IMG=local-registry:5000/wfs-wms-operator:$TAG"
26-
make deploy "IMG=local-registry:5000/wfs-wms-operator:$TAG"
59+
echo "Running: deploy IMG=local-registry:5000/mapserver-operator:$TAG"
60+
make deploy "IMG=local-registry:5000/mapserver-operator:$TAG"

cmd/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ func main() {
233233
os.Exit(1)
234234
}
235235
}
236+
// nolint:goconst
237+
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
238+
if err = webhookpdoknlv3.SetupWFSWebhookWithManager(mgr); err != nil {
239+
setupLog.Error(err, "unable to create webhook", "webhook", "WFS")
240+
os.Exit(1)
241+
}
242+
}
236243
// +kubebuilder:scaffold:builder
237244

238245
if metricsCertWatcher != nil {

config/crd/bases/pdok.nl_wfs.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,11 +1157,8 @@ spec:
11571157
- abstract
11581158
- accessConstraints
11591159
- baseUrl
1160-
- bbox
1161-
- countDefault
11621160
- defaultCrs
11631161
- featureTypes
1164-
- fees
11651162
- keywords
11661163
- ownerInfoRef
11671164
- prefix

config/manager/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: local-registry:5000/wfs-wms-operator
8-
newTag: v3.0.17
7+
newName: local-registry:5000/mapserver-operator
8+
newTag: v3.0.9

config/samples/v3_wfs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
includeIngress: false
3838
service:
3939
prefix: ""
40-
baseUrl: https://service.pdok.nl
40+
baseUrl: https://service.pdok.nl/test
4141
inspire:
4242
serviceMetadataUrl:
4343
csw:

config/webhook/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resources:
2-
#- manifests.yaml see https://github.com/kubernetes-sigs/kubebuilder/issues/2231
2+
- manifests.yaml
33
- service.yaml
44

55
configurations:

config/webhook/manifests.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
apiVersion: admissionregistration.k8s.io/v1
3+
kind: ValidatingWebhookConfiguration
4+
metadata:
5+
name: validating-webhook-configuration
6+
webhooks:
7+
- admissionReviewVersions:
8+
- v1
9+
clientConfig:
10+
service:
11+
name: webhook-service
12+
namespace: system
13+
path: /validate-pdok-nl-v3-wfs
14+
failurePolicy: Fail
15+
name: vwfs-v3.kb.io
16+
rules:
17+
- apiGroups:
18+
- pdok.nl
19+
apiVersions:
20+
- v3
21+
operations:
22+
- CREATE
23+
- UPDATE
24+
resources:
25+
- wfs
26+
sideEffects: None

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ go 1.23.0
44

55
godebug default=go1.23
66

7+
replace (
8+
github.com/pdok/smooth-operator v0.0.2 => ../smooth-operator
9+
)
10+
711
require (
8-
github.com/cbroglie/mustache v1.4.0
912
github.com/onsi/ginkgo/v2 v2.21.0
1013
github.com/onsi/gomega v1.35.1
1114
github.com/pdok/smooth-operator v0.0.2

0 commit comments

Comments
 (0)