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
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ linters:
gomoddirectives:
replace-allow-list:
- github.com/abbot/go-http-auth
- nhooyr.io/websocket
nestif:
min-complexity: 6
exclusions:
Expand Down
33 changes: 22 additions & 11 deletions api/v3/wms_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,26 @@ func validateLayers(wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
}
}

func validateLayer(layer AnnotatedLayer, path *field.Path, groupStyles []string, layerNames *[]string, hasVisibleLayer *bool, wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
service := wms.Spec.Service

func validateLayerName(layer AnnotatedLayer, path *field.Path, layerNames *[]string, allErrs *field.ErrorList) {
var layerName string
if layer.Name == nil && len(layer.Styles) > 0 {
*allErrs = append(*allErrs, field.Invalid(
field.NewPath("spec").Child("service").Child("layer").Child("layers[*]").Child("name"),
nil,
fmt.Sprintf("layer with styles must have name. Layer name is empty and the name of the first style is: %s.", layer.Styles[0].Name),
))
}

if layer.IsGroupLayer && layer.Data != nil {
*allErrs = append(*allErrs, field.Invalid(
path.Child("data"),
layer.Data,
"must not be set on a GroupLayer",
))
}
if layer.IsTopLayer && layer.Name == nil {
layerName = "unnamed: " + TopLayer
} else {
} else if layer.Name != nil {
layerName = *layer.Name
}

Expand All @@ -113,14 +126,12 @@ func validateLayer(layer AnnotatedLayer, path *field.Path, groupStyles []string,
} else {
*layerNames = append(*layerNames, layerName)
}
}

if layer.IsGroupLayer && layer.Data != nil {
*allErrs = append(*allErrs, field.Invalid(
path.Child("data"),
layer.Data,
"must not be set on a GroupLayer",
))
}
func validateLayer(layer AnnotatedLayer, path *field.Path, groupStyles []string, layerNames *[]string, hasVisibleLayer *bool, wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
service := wms.Spec.Service

validateLayerName(layer, path, layerNames, allErrs)

validateLayerWithMapfile(layer, path, wms, warnings, allErrs)

Expand Down
20 changes: 14 additions & 6 deletions config/crd/update_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ func main() {

func updateWMSV3(crdDir string) {
path := filepath.Join(crdDir, "pdok.nl_wms.yaml")
cleanPath := filepath.Clean(path)

if _, err := os.Stat(path); os.IsNotExist(err) {
// #nosec G703 -- path is internal and sanitized
if _, err := os.Stat(cleanPath); os.IsNotExist(err) {
panic(errors.Wrap(err, "WMS v3 manifest not found"))
}

content, _ := os.ReadFile(path)
// #nosec G703 -- path is internal and sanitized
content, _ := os.ReadFile(cleanPath)
crd := &v1.CustomResourceDefinition{}
err := kyaml.Unmarshal(content, &crd)
if err != nil {
Expand All @@ -53,7 +56,8 @@ func updateWMSV3(crdDir string) {
_ = goyaml.Unmarshal(updatedContent, &rawData)
delete(rawData, "status")

f, _ := os.OpenFile(path, os.O_TRUNC|os.O_WRONLY, 0644)
// #nosec G703 -- path is internal and sanitized
f, _ := os.OpenFile(cleanPath, os.O_TRUNC|os.O_WRONLY, 0644)
defer f.Close()

enc := goyaml.NewEncoder(f)
Expand Down Expand Up @@ -117,12 +121,15 @@ func updateLayersV3(version *v1.CustomResourceDefinitionVersion) {

func updateWFSV3(crdDir string) {
path := filepath.Join(crdDir, "pdok.nl_wfs.yaml")
cleanPath := filepath.Clean(path)

if _, err := os.Stat(path); os.IsNotExist(err) {
// #nosec G703 -- path is internal and sanitized
if _, err := os.Stat(cleanPath); os.IsNotExist(err) {
panic(errors.Wrap(err, "WFS v3 manifest not found"))
}

content, _ := os.ReadFile(path)
// #nosec G703 -- path is internal and sanitized
content, _ := os.ReadFile(cleanPath)
crd := &v1.CustomResourceDefinition{}
err := kyaml.Unmarshal(content, &crd)
if err != nil {
Expand All @@ -148,7 +155,8 @@ func updateWFSV3(crdDir string) {
_ = goyaml.Unmarshal(updatedContent, &rawData)
delete(rawData, "status")

f, _ := os.OpenFile(path, os.O_TRUNC|os.O_WRONLY, 0644)
// #nosec G703 -- path is internal and sanitized
f, _ := os.OpenFile(cleanPath, os.O_TRUNC|os.O_WRONLY, 0644)
defer f.Close()

enc := goyaml.NewEncoder(f)
Expand Down
28 changes: 15 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/pdok/mapserver-operator

go 1.25
go 1.25.5

godebug default=go1.25

require (
github.com/cbroglie/mustache v1.4.0
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.37.0
github.com/onsi/ginkgo/v2 v2.28.3
github.com/onsi/gomega v1.40.0
github.com/pdok/featureinfo-generator v1.4.0
github.com/pdok/ogc-capabilities-generator v1.0.1
github.com/pdok/ogc-specifications v1.0.0
Expand All @@ -24,7 +24,10 @@ require (

replace github.com/abbot/go-http-auth => github.com/abbot/go-http-auth v0.4.0 // for github.com/traefik/traefik/v3

replace nhooyr.io/websocket => nhooyr.io/websocket v1.8.12 // for github.com/traefik/traefik/v3@v3.6.3

require (
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/aws/smithy-go v1.23.2 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/go-acme/lego/v4 v4.29.0 // indirect
Expand Down Expand Up @@ -52,11 +55,10 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
go.opentelemetry.io/otel/log v0.14.0 // indirect
go.opentelemetry.io/otel/sdk/log v0.14.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/mod v0.35.0 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
)
Expand Down Expand Up @@ -87,7 +89,7 @@ require (
github.com/google/cel-go v0.26.0 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0
github.com/google/pprof v0.0.0-20250501235452-c0086092b71a // indirect
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down Expand Up @@ -117,14 +119,14 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/oauth2 v0.33.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/term v0.42.0 // indirect
golang.org/x/text v0.36.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.38.0
golang.org/x/tools v0.44.0
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251103181224-f26f9409b101 // indirect
Expand Down
Loading
Loading