Skip to content

Commit 296ecad

Browse files
committed
Setup featureinfo generator config
1 parent 27774e1 commit 296ecad

File tree

9 files changed

+407
-576
lines changed

9 files changed

+407
-576
lines changed

api/v3/wms_types.go

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ import (
3535
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3636
)
3737

38+
const (
39+
TopLayer = "topLayer"
40+
DataLayer = "dataLayer"
41+
GroupLayer = "groupLayer"
42+
)
43+
3844
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
3945
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
4046

@@ -156,16 +162,34 @@ func init() {
156162
SchemeBuilder.Register(&WMS{}, &WMSList{})
157163
}
158164

159-
func (layer *Layer) getAllLayers() (layers []Layer) {
165+
func (layer *Layer) GetAllLayers() (layers []Layer) {
160166
layers = append(layers, *layer)
161167
if layer.Layers != nil {
162168
for _, childLayer := range *layer.Layers {
163-
layers = append(layers, childLayer.getAllLayers()...)
169+
layers = append(layers, childLayer.GetAllLayers()...)
164170
}
165171
}
166172
return
167173
}
168174

175+
func (layer *Layer) GetParent(candidateLayer *Layer) *Layer {
176+
if candidateLayer.Layers == nil {
177+
return nil
178+
}
179+
180+
for _, childLayer := range *candidateLayer.Layers {
181+
if childLayer.Name == layer.Name {
182+
return candidateLayer
183+
} else {
184+
parent := layer.GetParent(&childLayer)
185+
if parent != nil {
186+
return parent
187+
}
188+
}
189+
}
190+
return nil
191+
}
192+
169193
func (layer *Layer) hasData() bool {
170194
switch {
171195
case layer.Data == nil:
@@ -188,8 +212,27 @@ func (layer *Layer) hasTIFData() bool {
188212
return layer.Data.TIF != nil && layer.Data.TIF.BlobKey != ""
189213
}
190214

215+
func (layer *Layer) GetLayerType(service *WMSService) (layerType string) {
216+
switch {
217+
case layer.hasData() && layer.Layers == nil:
218+
return DataLayer
219+
case layer.Name == service.Layer.Name:
220+
return TopLayer
221+
default:
222+
return GroupLayer
223+
}
224+
}
225+
226+
func (layer *Layer) IsDataLayer(service *WMSService) bool {
227+
return layer.GetLayerType(service) == DataLayer
228+
}
229+
230+
func (layer *Layer) IsGroupLayer(service *WMSService) bool {
231+
return layer.GetLayerType(service) == GroupLayer
232+
}
233+
191234
func (wms *WMS) GetAllLayersWithLegend() (layers []Layer) {
192-
for _, layer := range wms.Spec.Service.Layer.getAllLayers() {
235+
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
193236
if !layer.hasData() || len(layer.Styles) == 0 {
194237
continue
195238
}
@@ -205,7 +248,7 @@ func (wms *WMS) GetAllLayersWithLegend() (layers []Layer) {
205248

206249
func (wms *WMS) GetUniqueTiffBlobKeys() []string {
207250
blobKeys := map[string]bool{}
208-
for _, layer := range wms.Spec.Service.Layer.getAllLayers() {
251+
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
209252
if layer.hasTIFData() {
210253
blobKeys[layer.Data.TIF.BlobKey] = true
211254
}
@@ -236,7 +279,7 @@ func (wms *WMS) GetAuthority() *Authority {
236279
}
237280

238281
func (wms *WMS) HasPostgisData() bool {
239-
for _, layer := range wms.Spec.Service.Layer.getAllLayers() {
282+
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
240283
if layer.Data != nil && layer.Data.Postgis != nil {
241284
return true
242285
}

api/v3/wms_types_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package v3
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
func TestLayer_GetParent(t *testing.T) {
9+
childLayer2 := Layer{Name: "childlayer-2"}
10+
childLayer1 := Layer{Name: "childlayer-1", Layers: &[]Layer{childLayer2}}
11+
topLayer := Layer{Name: "toplayer", Layers: &[]Layer{childLayer1}}
12+
13+
type args struct {
14+
candidateLayer *Layer
15+
}
16+
tests := []struct {
17+
name string
18+
layer Layer
19+
args args
20+
want *Layer
21+
}{
22+
{
23+
name: "Test GetParent on layer with parent",
24+
layer: childLayer2,
25+
args: args{candidateLayer: &topLayer},
26+
want: &childLayer1,
27+
},
28+
{
29+
name: "Test GetParent on layer without parent",
30+
layer: topLayer,
31+
args: args{candidateLayer: &topLayer},
32+
want: nil,
33+
},
34+
}
35+
for _, tt := range tests {
36+
t.Run(tt.name, func(t *testing.T) {
37+
if got := tt.layer.GetParent(tt.args.candidateLayer); !reflect.DeepEqual(got, tt.want) {
38+
t.Errorf("GetParent() = %v, want %v", got, tt.want)
39+
}
40+
})
41+
}
42+
}

cmd/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
defaultMultitoolImage = "docker.io/pdok/docker-multitool:0.9.1"
5050
defaultMapfileGeneratorImage = "docker.io/pdok/mapfile-generator:1.9.3"
5151
defaultCapabilitiesGeneratorImage = "docker.io/pdok/ogc-capabilities-generator:1.0.0-beta5"
52+
defaultFeatureinfoGeneratorImage = "docker.io/pdok/featureinfo-generator:v1.4.0-beta1"
5253
)
5354

5455
var (
@@ -78,6 +79,7 @@ func main() {
7879
var multitoolImage string
7980
var mapfileGeneratorImage string
8081
var capabilitiesGeneratorImage string
82+
var featureinfoGeneratorImage string
8183
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
8284
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
8385
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -99,6 +101,7 @@ func main() {
99101
flag.StringVar(&multitoolImage, "multitool-image", defaultMultitoolImage, "The image to use in the blob download init-container.")
100102
flag.StringVar(&mapfileGeneratorImage, "mapfile-generator-image", defaultMapfileGeneratorImage, "The image to use in the mapfile generator init-container.")
101103
flag.StringVar(&capabilitiesGeneratorImage, "capabilities-generator-image", defaultCapabilitiesGeneratorImage, "The image to use in the capabilities generator init-container.")
104+
flag.StringVar(&featureinfoGeneratorImage, "featureinfo-generator-image", defaultFeatureinfoGeneratorImage, "The image to use in the featureinfo generator init-container.")
102105

103106
opts := zap.Options{
104107
Development: true,
@@ -228,8 +231,9 @@ func main() {
228231
}
229232

230233
if err = (&controller.WMSReconciler{
231-
Client: mgr.GetClient(),
232-
Scheme: mgr.GetScheme(),
234+
Client: mgr.GetClient(),
235+
Scheme: mgr.GetScheme(),
236+
FeatureinfoGeneratorImage: featureinfoGeneratorImage,
233237
}).SetupWithManager(mgr); err != nil {
234238
setupLog.Error(err, "unable to create controller", "controller", "WMS")
235239
os.Exit(1)

go.mod

Lines changed: 1 addition & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/cbroglie/mustache v1.4.0
1111
github.com/onsi/ginkgo/v2 v2.22.2
1212
github.com/onsi/gomega v1.36.2
13+
github.com/pdok/featureinfo-generator v1.4.0-beta1
1314
github.com/pdok/ogc-capabilities-generator v1.0.0-beta5
1415
github.com/pdok/ogc-specifications v1.0.0-beta4
1516
github.com/pdok/smooth-operator v0.0.9
@@ -24,190 +25,33 @@ require (
2425
replace github.com/abbot/go-http-auth => github.com/abbot/go-http-auth v0.4.0 // for github.com/traefik/traefik/v3
2526

2627
require (
27-
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
28-
4d63.com/gochecknoglobals v0.2.2 // indirect
29-
github.com/4meepo/tagalign v1.4.2 // indirect
30-
github.com/Abirdcfly/dupword v0.1.3 // indirect
31-
github.com/Antonboom/errname v1.0.0 // indirect
32-
github.com/Antonboom/nilnil v1.0.1 // indirect
33-
github.com/Antonboom/testifylint v1.5.2 // indirect
3428
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
35-
github.com/Crocmagnon/fatcontext v0.7.1 // indirect
36-
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
37-
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect
38-
github.com/Masterminds/semver/v3 v3.3.0 // indirect
39-
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
40-
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
41-
github.com/alexkohler/nakedret/v2 v2.0.5 // indirect
42-
github.com/alexkohler/prealloc v1.0.0 // indirect
43-
github.com/alingse/asasalint v0.0.11 // indirect
44-
github.com/alingse/nilnesserr v0.1.2 // indirect
45-
github.com/ashanbrown/forbidigo v1.6.0 // indirect
46-
github.com/ashanbrown/makezero v1.2.0 // indirect
4729
github.com/aws/aws-sdk-go v1.44.327 // indirect
48-
github.com/bkielbasa/cyclop v1.2.3 // indirect
49-
github.com/blizzy78/varnamelen v0.8.0 // indirect
50-
github.com/bombsimon/wsl/v4 v4.5.0 // indirect
51-
github.com/breml/bidichk v0.3.2 // indirect
52-
github.com/breml/errchkjson v0.4.0 // indirect
53-
github.com/butuzov/ireturn v0.3.1 // indirect
54-
github.com/butuzov/mirror v1.3.0 // indirect
55-
github.com/catenacyber/perfsprint v0.8.2 // indirect
56-
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
57-
github.com/charithe/durationcheck v0.0.10 // indirect
58-
github.com/chavacava/garif v0.1.0 // indirect
59-
github.com/ckaznocha/intrange v0.3.0 // indirect
60-
github.com/curioswitch/go-reassign v0.3.0 // indirect
61-
github.com/daixiang0/gci v0.13.5 // indirect
62-
github.com/denis-tingaikin/go-header v0.5.0 // indirect
63-
github.com/ettle/strcase v0.2.0 // indirect
64-
github.com/fatih/color v1.18.0 // indirect
65-
github.com/fatih/structtag v1.2.0 // indirect
66-
github.com/firefart/nonamedreturns v1.0.5 // indirect
67-
github.com/fzipp/gocyclo v0.6.0 // indirect
68-
github.com/ghostiam/protogetter v0.3.9 // indirect
6930
github.com/go-acme/lego/v4 v4.22.2 // indirect
70-
github.com/go-critic/go-critic v0.12.0 // indirect
7131
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
7232
github.com/go-kit/log v0.2.1 // indirect
7333
github.com/go-logfmt/logfmt v0.5.1 // indirect
74-
github.com/go-toolsmith/astcast v1.1.0 // indirect
75-
github.com/go-toolsmith/astcopy v1.1.0 // indirect
76-
github.com/go-toolsmith/astequal v1.2.0 // indirect
77-
github.com/go-toolsmith/astfmt v1.1.0 // indirect
78-
github.com/go-toolsmith/astp v1.1.0 // indirect
79-
github.com/go-toolsmith/strparse v1.1.0 // indirect
80-
github.com/go-toolsmith/typep v1.1.0 // indirect
81-
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
82-
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
83-
github.com/gobwas/glob v0.2.3 // indirect
84-
github.com/gofrs/flock v0.12.1 // indirect
85-
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
86-
github.com/golangci/go-printf-func-name v0.1.0 // indirect
87-
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
88-
github.com/golangci/golangci-lint v1.64.8 // indirect
89-
github.com/golangci/misspell v0.6.0 // indirect
90-
github.com/golangci/plugin-module-register v0.1.1 // indirect
91-
github.com/golangci/revgrep v0.8.0 // indirect
92-
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
9334
github.com/google/go-github/v28 v28.1.1 // indirect
9435
github.com/google/go-querystring v1.1.0 // indirect
95-
github.com/gordonklaus/ineffassign v0.1.0 // indirect
9636
github.com/gorilla/mux v1.8.1 // indirect
97-
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
98-
github.com/gostaticanalysis/comment v1.5.0 // indirect
99-
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
100-
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
101-
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
10237
github.com/hashicorp/go-version v1.7.0 // indirect
103-
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
104-
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
105-
github.com/hexops/gotextdiff v1.0.3 // indirect
10638
github.com/http-wasm/http-wasm-host-go v0.7.0 // indirect
107-
github.com/jgautheron/goconst v1.7.1 // indirect
108-
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
109-
github.com/jjti/go-spancheck v0.6.4 // indirect
110-
github.com/julz/importas v0.2.0 // indirect
111-
github.com/karamaru-alpha/copyloopvar v1.2.1 // indirect
112-
github.com/kisielk/errcheck v1.9.0 // indirect
113-
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
114-
github.com/kulti/thelper v0.6.3 // indirect
115-
github.com/kunwardeep/paralleltest v1.0.10 // indirect
116-
github.com/lasiar/canonicalheader v1.1.2 // indirect
117-
github.com/ldez/exptostd v0.4.2 // indirect
118-
github.com/ldez/gomoddirectives v0.6.1 // indirect
119-
github.com/ldez/grignotin v0.9.0 // indirect
120-
github.com/ldez/tagliatelle v0.7.1 // indirect
121-
github.com/ldez/usetesting v0.4.2 // indirect
122-
github.com/leonklingele/grouper v1.1.2 // indirect
123-
github.com/macabu/inamedparam v0.1.3 // indirect
124-
github.com/magiconair/properties v1.8.7 // indirect
125-
github.com/maratori/testableexamples v1.0.0 // indirect
126-
github.com/maratori/testpackage v1.1.1 // indirect
127-
github.com/matoous/godox v1.1.0 // indirect
12839
github.com/mattn/go-colorable v0.1.14 // indirect
12940
github.com/mattn/go-isatty v0.0.20 // indirect
130-
github.com/mattn/go-runewidth v0.0.16 // indirect
131-
github.com/mgechev/revive v1.7.0 // indirect
13241
github.com/miekg/dns v1.1.62 // indirect
133-
github.com/mitchellh/go-homedir v1.1.0 // indirect
134-
github.com/mitchellh/mapstructure v1.5.0 // indirect
135-
github.com/moricho/tparallel v0.3.2 // indirect
136-
github.com/nakabonne/nestif v0.3.1 // indirect
137-
github.com/nishanths/exhaustive v0.12.0 // indirect
138-
github.com/nishanths/predeclared v0.2.2 // indirect
139-
github.com/nunnatsa/ginkgolinter v0.19.1 // indirect
140-
github.com/olekukonko/tablewriter v0.0.5 // indirect
14142
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
142-
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
143-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
144-
github.com/polyfloyd/go-errorlint v1.7.1 // indirect
145-
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect
146-
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
147-
github.com/quasilyte/gogrep v0.5.0 // indirect
148-
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
149-
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
150-
github.com/raeperd/recvcheck v0.2.0 // indirect
151-
github.com/rivo/uniseg v0.4.7 // indirect
15243
github.com/rogpeppe/go-internal v1.14.1 // indirect
15344
github.com/rs/zerolog v1.33.0 // indirect
154-
github.com/ryancurrah/gomodguard v1.3.5 // indirect
155-
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
156-
github.com/sagikazarmark/locafero v0.4.0 // indirect
157-
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
158-
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
159-
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
160-
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
161-
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
162-
github.com/securego/gosec/v2 v2.22.2 // indirect
163-
github.com/sirupsen/logrus v1.9.3 // indirect
164-
github.com/sivchari/containedctx v1.0.3 // indirect
165-
github.com/sivchari/tenv v1.12.1 // indirect
166-
github.com/sonatard/noctx v0.1.0 // indirect
167-
github.com/sourcegraph/conc v0.3.0 // indirect
168-
github.com/sourcegraph/go-diff v0.7.0 // indirect
169-
github.com/spf13/afero v1.12.0 // indirect
170-
github.com/spf13/cast v1.7.0 // indirect
171-
github.com/spf13/viper v1.18.2 // indirect
172-
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
173-
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
174-
github.com/stretchr/objx v0.5.2 // indirect
175-
github.com/stretchr/testify v1.10.0 // indirect
176-
github.com/subosito/gotenv v1.6.0 // indirect
177-
github.com/tdakkota/asciicheck v0.4.1 // indirect
178-
github.com/tetafro/godot v1.5.0 // indirect
179-
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect
180-
github.com/timonwong/loggercheck v0.10.1 // indirect
181-
github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect
182-
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
18345
github.com/traefik/paerser v0.2.2 // indirect
184-
github.com/ultraware/funlen v0.2.0 // indirect
185-
github.com/ultraware/whitespace v0.2.0 // indirect
18646
github.com/unrolled/render v1.0.2 // indirect
187-
github.com/uudashr/gocognit v1.2.0 // indirect
188-
github.com/uudashr/iface v1.3.1 // indirect
189-
github.com/xen0n/gosmopolitan v1.2.2 // indirect
190-
github.com/yagipy/maintidx v1.0.0 // indirect
191-
github.com/yeya24/promlinter v0.3.0 // indirect
192-
github.com/ykadowak/zerologlint v0.1.5 // indirect
193-
gitlab.com/bosi/decorder v0.4.2 // indirect
194-
go-simpler.org/musttag v0.13.0 // indirect
195-
go-simpler.org/sloglint v0.9.0 // indirect
19647
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
19748
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.8.0 // indirect
19849
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.8.0 // indirect
19950
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
20051
go.opentelemetry.io/otel/log v0.8.0 // indirect
20152
go.opentelemetry.io/otel/sdk/log v0.8.0 // indirect
202-
go.uber.org/automaxprocs v1.6.0 // indirect
20353
golang.org/x/crypto v0.36.0 // indirect
204-
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
20554
golang.org/x/mod v0.24.0 // indirect
206-
gopkg.in/ini.v1 v1.67.0 // indirect
207-
gopkg.in/yaml.v2 v2.4.0 // indirect
208-
honnef.co/go/tools v0.6.1 // indirect
209-
mvdan.cc/gofumpt v0.7.0 // indirect
210-
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
21155
)
21256

21357
require (

0 commit comments

Comments
 (0)