Skip to content

Commit ffef8b2

Browse files
author
Jelle Dijkstra
committed
Resolved conflicts
2 parents 3846738 + 97098ec commit ffef8b2

File tree

16 files changed

+622
-129
lines changed

16 files changed

+622
-129
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ func ConverseResources(src corev1.ResourceRequirements) *corev1.PodSpec {
8686
}
8787
}
8888

89-
func ConverseColumnAndAliasesV2ToColumnsWithAliasV3(columns []string, aliases map[string]string) []pdoknlv3.Columns {
90-
v3Columns := make([]pdoknlv3.Columns, 0)
89+
func ConverseColumnAndAliasesV2ToColumnsWithAliasV3(columns []string, aliases map[string]string) []pdoknlv3.Column {
90+
v3Columns := make([]pdoknlv3.Column, 0)
9191
for _, column := range columns {
92-
col := pdoknlv3.Columns{
92+
col := pdoknlv3.Column{
9393
Name: column,
9494
}
9595

@@ -104,7 +104,7 @@ func ConverseColumnAndAliasesV2ToColumnsWithAliasV3(columns []string, aliases ma
104104
return v3Columns
105105
}
106106

107-
func ConverseColumnsWithAliasV3ToColumnsAndAliasesV2(columns []pdoknlv3.Columns) ([]string, map[string]string) {
107+
func ConverseColumnsWithAliasV3ToColumnsAndAliasesV2(columns []pdoknlv3.Column) ([]string, map[string]string) {
108108
v2Columns := make([]string, 0)
109109
v2Aliases := make(map[string]string)
110110

api/v3/shared_types.go

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ type Data struct {
4949
}
5050

5151
type Gpkg struct {
52-
BlobKey string `json:"blobKey"`
53-
TableName string `json:"tableName"`
54-
GeometryType string `json:"geometryType"`
55-
Columns []Columns `json:"columns"`
52+
BlobKey string `json:"blobKey"`
53+
TableName string `json:"tableName"`
54+
GeometryType string `json:"geometryType"`
55+
Columns []Column `json:"columns"`
5656
}
5757

5858
// Postgis - reference to table in a Postgres database
5959
type Postgis struct {
60-
TableName string `json:"tableName"`
61-
GeometryType string `json:"geometryType"`
62-
Columns []Columns `json:"columns"`
60+
TableName string `json:"tableName"`
61+
GeometryType string `json:"geometryType"`
62+
Columns []Column `json:"columns"`
6363
}
6464

6565
type TIF struct {
@@ -69,7 +69,7 @@ type TIF struct {
6969
GetFeatureInfoIncludesClass *bool `json:"getFeatureInfoIncludesClass,omitempty"`
7070
}
7171

72-
type Columns struct {
72+
type Column struct {
7373
Name string `json:"name"`
7474
Alias *string `json:"alias,omitempty"`
7575
}
@@ -98,3 +98,36 @@ func GetBaseURLPath[T *WFS | *WMS](o T) string {
9898
parsed, _ := url.Parse(serviceUrl)
9999
return strings.TrimPrefix(parsed.Path, "/")
100100
}
101+
102+
func (d *Data) GetColumns() *[]Column {
103+
switch {
104+
case d.Gpkg != nil:
105+
return &d.Gpkg.Columns
106+
case d.Postgis != nil:
107+
return &d.Postgis.Columns
108+
default:
109+
return nil
110+
}
111+
}
112+
113+
func (d *Data) GetTableName() *string {
114+
switch {
115+
case d.Gpkg != nil:
116+
return &d.Gpkg.TableName
117+
case d.Postgis != nil:
118+
return &d.Postgis.TableName
119+
default:
120+
return nil
121+
}
122+
}
123+
124+
func (d *Data) GetGeometryType() *string {
125+
switch {
126+
case d.Gpkg != nil:
127+
return &d.Gpkg.GeometryType
128+
case d.Postgis != nil:
129+
return &d.Postgis.GeometryType
130+
default:
131+
return nil
132+
}
133+
}

api/v3/wfs_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,12 @@ type FeatureBbox struct {
117117
DefaultCRS shared_model.BBox `json:"defaultCRS"`
118118
WGS84 *shared_model.BBox `json:"wgs84,omitempty"`
119119
}
120+
121+
func (wfs *WFS) HasPostgisData() bool {
122+
for _, featureType := range wfs.Spec.Service.FeatureTypes {
123+
if featureType.Data.Postgis != nil {
124+
return true
125+
}
126+
}
127+
return false
128+
}

api/v3/zz_generated.deepcopy.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ import (
4646
)
4747

4848
const (
49-
defaultMultitoolImage = "docker.io/pdok/docker-multitool:0.9.1"
50-
defaultMapfileGeneratorImage = "docker.io/pdok/mapfile-generator:1.9.3"
49+
defaultMultitoolImage = "docker.io/pdok/docker-multitool:0.9.1"
50+
defaultMapfileGeneratorImage = "docker.io/pdok/mapfile-generator:1.9.3"
51+
defaultCapabilitiesGeneratorImage = "acrpdokprodman.azurecr.io/pdok/ogc-capabilities-generator:0.2.7"
5152
)
5253

5354
var (
@@ -76,6 +77,7 @@ func main() {
7677
var host string
7778
var multitoolImage string
7879
var mapfileGeneratorImage string
80+
var capabilitiesGeneratorImage string
7981
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
8082
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
8183
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -96,6 +98,7 @@ func main() {
9698
flag.StringVar(&host, "baseurl", "", "The host which is used in the configmap_files service.")
9799
flag.StringVar(&multitoolImage, "multitool-image", defaultMultitoolImage, "The image to use in the blob download init-container.")
98100
flag.StringVar(&mapfileGeneratorImage, "mapfile-generator-image", defaultMapfileGeneratorImage, "The image to use in the mapfile generator init-container.")
101+
flag.StringVar(&capabilitiesGeneratorImage, "capabilities-generator-image", defaultCapabilitiesGeneratorImage, "The image to use in the capabilities generator init-container.")
99102

100103
opts := zap.Options{
101104
Development: true,
@@ -232,10 +235,11 @@ func main() {
232235
os.Exit(1)
233236
}
234237
if err = (&controller.WFSReconciler{
235-
Client: mgr.GetClient(),
236-
Scheme: mgr.GetScheme(),
237-
MultitoolImage: multitoolImage,
238-
MapfileGeneratorImage: mapfileGeneratorImage,
238+
Client: mgr.GetClient(),
239+
Scheme: mgr.GetScheme(),
240+
MultitoolImage: multitoolImage,
241+
MapfileGeneratorImage: mapfileGeneratorImage,
242+
CapabilitiesGeneratorImage: capabilitiesGeneratorImage,
239243
}).SetupWithManager(mgr); err != nil {
240244
setupLog.Error(err, "unable to create controller", "controller", "WFS")
241245
os.Exit(1)

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ godebug default=go1.23
77
require (
88
github.com/onsi/ginkgo/v2 v2.21.0
99
github.com/onsi/gomega v1.35.1
10+
github.com/pdok/ogc-specifications v1.0.0-beta2
11+
github.com/pdok/smooth-operator v0.0.6
12+
github.com/traefik/traefik/v3 v3.3.4
1013
k8s.io/api v0.32.0
1114
k8s.io/apimachinery v0.32.0
1215
k8s.io/client-go v0.32.0
1316
sigs.k8s.io/controller-runtime v0.20.0
1417
sigs.k8s.io/yaml v1.4.0
15-
github.com/pdok/smooth-operator v0.0.6
16-
github.com/traefik/traefik/v3 v3.3.4
1718
)
1819

1920
replace github.com/abbot/go-http-auth => github.com/abbot/go-http-auth v0.4.0 // for github.com/traefik/traefik/v3
@@ -111,7 +112,7 @@ require (
111112
golang.org/x/term v0.27.0 // indirect
112113
golang.org/x/text v0.21.0 // indirect
113114
golang.org/x/time v0.8.0 // indirect
114-
golang.org/x/tools v0.28.0 // indirect
115+
golang.org/x/tools v0.28.0
115116
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
116117
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect
117118
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect

go.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
135135
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
136136
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
137137
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
138-
github.com/pdok/smooth-operator v0.0.4/go.mod h1:oZWFuIKJGjN/C6ocgMNfMZ7SbLQi+N0qaWj7j95Wdec=
139-
github.com/pdok/smooth-operator v0.0.5 h1:7tgMeAEG34JlW6GlfxfHH+RV7c6uE6621FXv+vzfDGo=
140-
github.com/pdok/smooth-operator v0.0.5/go.mod h1:oZWFuIKJGjN/C6ocgMNfMZ7SbLQi+N0qaWj7j95Wdec=
138+
github.com/pdok/ogc-specifications v1.0.0-beta2 h1:BSMd8HiABpKTQButuMaHDj9XKrisnd5ifL1/fM5AwyE=
139+
github.com/pdok/ogc-specifications v1.0.0-beta2/go.mod h1:rkrIwIBIUl4oyn3aMVtJLipDRtFHp3oa9dSu/MyDt1o=
141140
github.com/pdok/smooth-operator v0.0.6 h1:IwgY3X2zYA2XLw0eKmBBN1Md6gNWnoVl0i1R8/wFHvs=
142141
github.com/pdok/smooth-operator v0.0.6/go.mod h1:oZWFuIKJGjN/C6ocgMNfMZ7SbLQi+N0qaWj7j95Wdec=
143142
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -309,6 +308,7 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
309308
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
310309
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
311310
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
311+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
312312
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
313313
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
314314
k8s.io/api v0.32.0 h1:OL9JpbvAU5ny9ga2fb24X8H6xQlVp+aJMFlgtQjR9CE=

internal/controller/blobdownload/blob_download_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestGetArgsForWFS(t *testing.T) {
8282
Title: "wfs-prefetch-service-title",
8383
},
8484
Options: &v3.Options{
85-
PrefetchData: smoothoperatorutils.BoolPtr(true),
85+
PrefetchData: smoothoperatorutils.Pointer(true),
8686
},
8787
},
8888
},
@@ -99,7 +99,7 @@ func TestGetArgsForWFS(t *testing.T) {
9999
Title: "wfs-noprefetch-service-title",
100100
},
101101
Options: &v3.Options{
102-
PrefetchData: smoothoperatorutils.BoolPtr(false),
102+
PrefetchData: smoothoperatorutils.Pointer(false),
103103
},
104104
},
105105
},
@@ -205,7 +205,7 @@ func TestGetArgsForWMS(t *testing.T) {
205205
},
206206
},
207207
Options: &v3.Options{
208-
PrefetchData: smoothoperatorutils.BoolPtr(true),
208+
PrefetchData: smoothoperatorutils.Pointer(true),
209209
},
210210
},
211211
},
@@ -272,7 +272,7 @@ func TestGetArgsForWMS(t *testing.T) {
272272
},
273273
},
274274
Options: &v3.Options{
275-
PrefetchData: smoothoperatorutils.BoolPtr(true),
275+
PrefetchData: smoothoperatorutils.Pointer(true),
276276
},
277277
},
278278
},
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package capabilitiesgenerator
2+
3+
import (
4+
"encoding/xml"
5+
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
6+
"github.com/pdok/mapserver-operator/internal/controller/mapperutils"
7+
"github.com/pdok/ogc-specifications/pkg/wfs200"
8+
"github.com/pdok/ogc-specifications/pkg/wsc110"
9+
smoothoperatorv1 "github.com/pdok/smooth-operator/api/v1"
10+
)
11+
12+
const (
13+
inspireSchemaLocations = "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0 http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd"
14+
capabilitiesFilename = "/var/www/config/capabilities_wfs_200.xml"
15+
)
16+
17+
func MapWFSToCapabilitiesGeneratorInput(wfs *pdoknlv3.WFS, ownerInfo *smoothoperatorv1.OwnerInfo) (Config, error) {
18+
config := Config{
19+
Global: Global{
20+
Namespace: mapperutils.GetNamespaceURI(wfs.Spec.Service.Prefix, ownerInfo),
21+
Prefix: wfs.Spec.Service.Prefix,
22+
OnlineResourceurl: pdoknlv3.GetBaseURL(),
23+
Path: mapperutils.GetPath(wfs),
24+
Version: *mapperutils.GetLabelValueByKey(wfs.ObjectMeta.Labels, "service-version"),
25+
},
26+
Services: Services{
27+
WFS200Config: WFS200Config{
28+
Filename: capabilitiesFilename,
29+
Wfs200: wfs200.GetCapabilitiesResponse{
30+
31+
ServiceProvider: wfs200.ServiceProvider{
32+
ProviderSite: struct {
33+
Type string `xml:"xlink:type,attr" yaml:"type"`
34+
Href string `xml:"xlink:href,attr" yaml:"href"`
35+
}(struct {
36+
Type string
37+
Href string
38+
}{
39+
Type: "simple",
40+
Href: pdoknlv3.GetBaseURL(),
41+
}),
42+
},
43+
ServiceIdentification: wfs200.ServiceIdentification{
44+
Title: mapperutils.EscapeQuotes(wfs.Spec.Service.Title),
45+
Abstract: mapperutils.EscapeQuotes(wfs.Spec.Service.Abstract),
46+
AccessConstraints: wfs.Spec.Service.AccessConstraints,
47+
Keywords: &wsc110.Keywords{
48+
Keyword: wfs.Spec.Service.Keywords,
49+
},
50+
},
51+
52+
Capabilities: wfs200.Capabilities{
53+
FeatureTypeList: getFeatureTypeList(wfs),
54+
},
55+
XMLName: xml.Name{},
56+
Namespaces: wfs200.Namespaces{ // TODO
57+
XmlnsGML: "",
58+
XmlnsWFS: "",
59+
XmlnsOWS: "",
60+
XmlnsXlink: "",
61+
XmlnsXSI: "",
62+
XmlnsFes: "",
63+
XmlnsInspireCommon: "",
64+
XmlnsInspireDls: "",
65+
XmlnsPrefix: "",
66+
Version: "",
67+
SchemaLocation: "",
68+
},
69+
},
70+
},
71+
},
72+
}
73+
74+
if wfs.Spec.Service.Inspire != nil {
75+
config.Global.AdditionalSchemaLocations = inspireSchemaLocations
76+
77+
// Todo set extended capabilities
78+
config.Services.WFS200Config.Wfs200.Capabilities.OperationsMetadata = wfs200.OperationsMetadata{}
79+
}
80+
81+
return config, nil
82+
}
83+
84+
func getFeatureTypeList(wfs *pdoknlv3.WFS) (typeList wfs200.FeatureTypeList) {
85+
typeList.FeatureType = []wfs200.FeatureType{}
86+
87+
for _, fType := range wfs.Spec.Service.FeatureTypes {
88+
featureType := wfs200.FeatureType{
89+
Name: wfs.Spec.Service.Prefix + fType.Name,
90+
Title: mapperutils.EscapeQuotes(fType.Title),
91+
Abstract: mapperutils.EscapeQuotes(fType.Abstract),
92+
DefaultCRS: &wfs200.CRS{Namespace: "", Code: 1}, // Todo
93+
OtherCRS: &[]wfs200.CRS{ // Todo
94+
{Namespace: "", Code: 2},
95+
},
96+
}
97+
typeList.FeatureType = append(typeList.FeatureType, featureType)
98+
}
99+
return
100+
}

0 commit comments

Comments
 (0)