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
16 changes: 12 additions & 4 deletions api/v2beta1/shared_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import (
corev1 "k8s.io/api/core/v1"
)

func ConvertOptionsV2ToV3(src WMSWFSOptions) pdoknlv3.Options {
func ConvertOptionsV2ToV3(src *WMSWFSOptions) *pdoknlv3.Options {
defaults := pdoknlv3.GetDefaultOptions()

return pdoknlv3.Options{
if src == nil {
return defaults
}

return &pdoknlv3.Options{
AutomaticCasing: src.AutomaticCasing,
IncludeIngress: src.IncludeIngress,
PrefetchData: smoothoperatorutils.PointerVal(src.PrefetchData, defaults.PrefetchData),
Expand All @@ -24,8 +28,12 @@ func ConvertOptionsV2ToV3(src WMSWFSOptions) pdoknlv3.Options {
}
}

func ConvertOptionsV3ToV2(src pdoknlv3.Options) WMSWFSOptions {
return WMSWFSOptions{
func ConvertOptionsV3ToV2(src *pdoknlv3.Options) *WMSWFSOptions {
if src == nil {
src = pdoknlv3.GetDefaultOptions()
}

return &WMSWFSOptions{
AutomaticCasing: src.AutomaticCasing,
IncludeIngress: src.IncludeIngress,
PrefetchData: &src.PrefetchData,
Expand Down
8 changes: 4 additions & 4 deletions api/v2beta1/wfs_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ type WFSList struct {

// WFSSpec is the struct for all fields defined in the WFS CRD
type WFSSpec struct {
General General `json:"general"`
Service WFSService `json:"service"`
Kubernetes Kubernetes `json:"kubernetes"`
Options WMSWFSOptions `json:"options,omitempty"`
General General `json:"general"`
Service WFSService `json:"service"`
Kubernetes Kubernetes `json:"kubernetes"`
Options *WMSWFSOptions `json:"options,omitempty"`
}

// WFSService is the struct with all service specific options
Expand Down
8 changes: 4 additions & 4 deletions api/v2beta1/wms_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ type WMS struct {

// WMSSpec is the struct for all fields defined in the WMS CRD
type WMSSpec struct {
General General `json:"general"`
Service WMSService `json:"service"`
Options WMSWFSOptions `json:"options"`
Kubernetes Kubernetes `json:"kubernetes"`
General General `json:"general"`
Service WMSService `json:"service"`
Options *WMSWFSOptions `json:"options,omitempty"`
Kubernetes Kubernetes `json:"kubernetes"`
}

// WMSService is the struct for all service level fields
Expand Down
12 changes: 10 additions & 2 deletions api/v2beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions api/v3/wfs_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type WFSSpec struct {
PodSpecPatch *corev1.PodSpec `json:"podSpecPatch,omitempty"`
HorizontalPodAutoscalerPatch *HorizontalPodAutoscalerPatch `json:"horizontalPodAutoscalerPatch,omitempty"`
// TODO omitting the options field or setting an empty value results in incorrect defaulting of the options
Options Options `json:"options"`
Options *Options `json:"options,omitempty"`

// service configuration
Service WFSService `json:"service"`
Expand Down Expand Up @@ -242,7 +242,11 @@ func (wfs *WFS) HorizontalPodAutoscalerPatch() *HorizontalPodAutoscalerPatch {
}

func (wfs *WFS) Options() Options {
return wfs.Spec.Options
if wfs.Spec.Options == nil {
return *GetDefaultOptions()
}

return *wfs.Spec.Options
}

func (wfs *WFS) ID() string {
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 @@ -61,7 +61,7 @@ type WMSSpec struct {

// Optional options for the configuration of the service.
// TODO omitting the options field or setting an empty value results in incorrect defaulting of the options
Options Options `json:"options"`
Options *Options `json:"options,omitempty"`

// Service specification
Service WMSService `json:"service"`
Expand Down Expand Up @@ -569,7 +569,11 @@ func (wms *WMS) HorizontalPodAutoscalerPatch() *HorizontalPodAutoscalerPatch {
}

func (wms *WMS) Options() Options {
return wms.Spec.Options
if wms.Spec.Options == nil {
return *GetDefaultOptions()
}

return *wms.Spec.Options
}

func (wms *WMS) ID() string {
Expand Down
4 changes: 2 additions & 2 deletions api/v3/wms_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func ValidateWMS(wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
}
}

var rewriteGroupToDataLayers = wms.Spec.Options.RewriteGroupToDataLayers
var validateChildStyleNameEqual = wms.Spec.Options.ValidateChildStyleNameEqual
var rewriteGroupToDataLayers = wms.Options().RewriteGroupToDataLayers
var validateChildStyleNameEqual = wms.Options().ValidateChildStyleNameEqual

equalChildStyleNames := map[string][]string{}
if rewriteGroupToDataLayers && validateChildStyleNameEqual {
Expand Down
12 changes: 10 additions & 2 deletions api/v3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config/crd/bases/pdok.nl_wfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,6 @@ spec:
- url
type: object
required:
- options
- service
type: object
status:
Expand Down
2 changes: 0 additions & 2 deletions config/crd/bases/pdok.nl_wms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ spec:
required:
- general
- kubernetes
- options
- service
type: object
status:
Expand Down Expand Up @@ -2097,7 +2096,6 @@ spec:
- url
type: object
required:
- options
- service
type: object
status:
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/blobdownload/blob_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ func GetArgs[W pdoknlv3.WMSWFS](webservice W) (args string, err error) {
case *pdoknlv3.WFS:
if WFS, ok := any(webservice).(*pdoknlv3.WFS); ok {
createConfig(&sb)
downloadGeopackage(&sb, WFS.Spec.Options.PrefetchData)
downloadGeopackage(&sb, WFS.Options().PrefetchData)
// In case of WFS no downloads are needed for TIFFs, styling assets and legends
}
case *pdoknlv3.WMS:
if WMS, ok := any(webservice).(*pdoknlv3.WMS); ok {
createConfig(&sb)
downloadGeopackage(&sb, WMS.Spec.Options.PrefetchData)
downloadGeopackage(&sb, WMS.Options().PrefetchData)
if err = downloadTiffs(&sb, WMS); err != nil {
return "", err
}
Expand Down Expand Up @@ -139,7 +139,7 @@ func downloadGeopackage(sb *strings.Builder, prefetchData bool) {
}

func downloadTiffs(sb *strings.Builder, wms *pdoknlv3.WMS) error {
if !wms.Spec.Options.PrefetchData {
if !wms.Options().PrefetchData {
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions internal/controller/blobdownload/blob_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestGetArgsForWFS(t *testing.T) {
Service: v3.WFSService{
Title: "wfs-prefetch-service-title",
},
Options: v3.Options{
Options: &v3.Options{
PrefetchData: true,
},
},
Expand All @@ -99,7 +99,7 @@ func TestGetArgsForWFS(t *testing.T) {
Service: v3.WFSService{
Title: "wfs-noprefetch-service-title",
},
Options: v3.Options{
Options: &v3.Options{
PrefetchData: false,
},
},
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestGetArgsForWMS(t *testing.T) {
},
},
},
Options: v3.Options{
Options: &v3.Options{
PrefetchData: true,
},
},
Expand Down Expand Up @@ -272,7 +272,7 @@ func TestGetArgsForWMS(t *testing.T) {
},
},
},
Options: v3.Options{
Options: &v3.Options{
PrefetchData: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestGetInput(t *testing.T) {
args: args{
wms: &pdoknlv3.WMS{
Spec: pdoknlv3.WMSSpec{
Options: pdoknlv3.Options{
Options: &pdoknlv3.Options{
AutomaticCasing: true,
},
Service: pdoknlv3.WMSService{
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/featureinfogenerator/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
func MapWMSToFeatureinfoGeneratorInput(wms *pdoknlv3.WMS) (*featureinfo.Scheme, error) {

input := &featureinfo.Scheme{
AutomaticCasing: wms.Spec.Options.AutomaticCasing,
AutomaticCasing: wms.Options().AutomaticCasing,
Version: featureinfoGeneratorSchemaVersion,
Layers: []featureinfo.Layer{},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/legendgenerator/legend_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func GetConfigMapData(wms *pdoknlv3.WMS) map[string]string {
}

addLayerInput(wms, data)
if wms.Spec.Options.RewriteGroupToDataLayers {
if wms.Options().RewriteGroupToDataLayers {
addLegendFixerConfig(wms, data)
}
return data
Expand Down
361 changes: 47 additions & 314 deletions internal/controller/mapfilegenerator/mapfile_generator_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions internal/controller/mapfilegenerator/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func MapWFSToMapfileGeneratorInput(wfs *pdoknlv3.WFS, ownerInfo *smoothoperatorv
Extent: extent,
NamespacePrefix: wfs.Spec.Service.Prefix,
NamespaceURI: mapperutils.GetNamespaceURI(wfs.Spec.Service.Prefix, ownerInfo),
AutomaticCasing: wfs.Spec.Options.AutomaticCasing,
AutomaticCasing: wfs.Options().AutomaticCasing,
DataEPSG: wfs.Spec.Service.DefaultCrs,
// TODO Should this be a constant like in v2, or OtherCRS + default
EPSGList: defaultEpsgList, // wfs.Spec.Service.OtherCrs,
Expand Down Expand Up @@ -202,7 +202,7 @@ func MapWMSToMapfileGeneratorInput(wms *pdoknlv3.WMS, _ *smoothoperatorv1.OwnerI
MetadataID: metadataID,
DatasetOwner: &datasetOwner,
AuthorityURL: &authorityURL,
AutomaticCasing: wms.Spec.Options.AutomaticCasing,
AutomaticCasing: wms.Options().AutomaticCasing,
DataEPSG: service.DataEPSG,
EPSGList: epsgs,
},
Expand Down
72 changes: 72 additions & 0 deletions internal/controller/mapfilegenerator/test_data/expected/wfs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"service_title": "some Service title",
"service_abstract": "some \\\"Service\\\" abstract",
"service_keywords": "service-keyword-1,service-keyword-2,infoFeatureAccessService",
"service_extent": "0.0 2.0 1.0 3.0",
"service_wfs_maxfeatures": "1000",
"service_namespace_prefix": "prefix",
"service_namespace_uri": "http://prefix.geonovum.nl",
"service_onlineresource": "https://service.pdok.nl",
"service_path": "/datasetOwner/dataset/theme/wfs/v1_0",
"service_metadata_id": "metameta-meta-meta-meta-metametameta",
"automatic_casing": true,
"data_epsg": "EPSG:28992",
"service_debug_level": 0,
"epsg_list": [
"EPSG:28992",
"EPSG:25831",
"EPSG:25832",
"EPSG:3034",
"EPSG:3035",
"EPSG:3857",
"EPSG:4258",
"EPSG:4326"
],
"layers": [
{
"name": "featuretype-1-name",
"title": "featuretype-1-title",
"abstract": "feature \\\"1\\\" abstract",
"keywords": "featuretype-1-keyword-1,featuretype-1-keyword-2",
"layer_extent": "0.0 2.0 1.0 3.0",
"dataset_metadata_id": "datadata-data-data-data-datadatadata",
"columns": [
{
"name": "fuuid"
},
{
"name": "featuretype-1-column-1"
},
{
"name": "featuretype-1-column-2"
}
],
"geometry_type": "Point",
"gpkg_path": "/srv/data/gpkg/file-1.gpkg",
"tablename": "featuretype-1"
},
{
"name": "featuretype-2-name",
"title": "featuretype-2-title",
"abstract": "feature \\\"2\\\" abstract",
"keywords": "featuretype-2-keyword-1,featuretype-2-keyword-2",
"layer_extent": "0.0 2.0 1.0 3.0",
"dataset_metadata_id": "datadata-data-data-data-datadatadata",
"columns": [
{
"name": "fuuid"
},
{
"name": "featuretype-2-column-1",
"alias": "alias_featuretype-2-column-1"
},
{
"name": "featuretype-2-column-2"
}
],
"geometry_type": "MultiLine",
"tablename": "featuretype-2",
"postgis": true
}
]
}
Loading
Loading