Skip to content

Commit 1b2c91f

Browse files
Merge pull request #91 from PDOK/jd/fixes
Conversion fixes
2 parents 27dc356 + 85dab7d commit 1b2c91f

File tree

7 files changed

+54
-49
lines changed

7 files changed

+54
-49
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ func ConvertOptionsV3ToV2(src *pdoknlv3.Options) *WMSWFSOptions {
5252

5353
//nolint:gosec
5454
func ConvertAutoscaling(src Autoscaling) *pdoknlv3.HorizontalPodAutoscalerPatch {
55-
var minReplicas *int32
55+
hpa := &pdoknlv3.HorizontalPodAutoscalerPatch{}
56+
5657
if src.MinReplicas != nil {
5758
//nolint:gosec
58-
minReplicas = smoothoperatorutils.Pointer(int32(*src.MinReplicas))
59+
hpa.MinReplicas = smoothoperatorutils.Pointer(int32(*src.MinReplicas))
5960
}
6061

61-
var maxReplicas int32
6262
if src.MaxReplicas != nil {
63-
maxReplicas = int32(*src.MaxReplicas)
63+
//nolint:gosec
64+
hpa.MaxReplicas = smoothoperatorutils.Pointer(int32(*src.MaxReplicas))
6465
}
6566

6667
metrics := make([]autoscalingv2.MetricSpec, 0)
@@ -75,13 +76,10 @@ func ConvertAutoscaling(src Autoscaling) *pdoknlv3.HorizontalPodAutoscalerPatch
7576
},
7677
},
7778
})
79+
hpa.Metrics = metrics
7880
}
7981

80-
return &pdoknlv3.HorizontalPodAutoscalerPatch{
81-
MinReplicas: minReplicas,
82-
MaxReplicas: &maxReplicas,
83-
Metrics: metrics,
84-
}
82+
return hpa
8583
}
8684

8785
func ConvertResources(src corev1.ResourceRequirements) corev1.PodSpec {
@@ -168,7 +166,7 @@ func ConvertV2DataToV3(v2 Data) pdoknlv3.Data {
168166
if v2.Tif != nil {
169167
v3.TIF = &pdoknlv3.TIF{
170168
BlobKey: v2.Tif.BlobKey,
171-
Resample: *v2.Tif.Resample,
169+
Resample: smoothoperatorutils.PointerVal(v2.Tif.Resample, "NEAREST"),
172170
Offsite: v2.Tif.Offsite,
173171
GetFeatureInfoIncludesClass: smoothoperatorutils.PointerVal(v2.Tif.GetFeatureInfoIncludesClass, false),
174172
}

api/v2beta1/wfs_conversion.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,23 @@ func (src *WFS) ToV3(dst *pdoknlv3.WFS) error {
8888
}
8989
}
9090

91-
if err != nil {
92-
return err
91+
allOtherCrs := []string{
92+
"EPSG:25831",
93+
"EPSG:25832",
94+
"EPSG:28992",
95+
"EPSG:3034",
96+
"EPSG:3035",
97+
"EPSG:3857",
98+
"EPSG:4258",
99+
"EPSG:4326",
100+
}
101+
otherCrs := []string{}
102+
for _, cr := range allOtherCrs {
103+
if cr != src.Spec.Service.DataEPSG {
104+
otherCrs = append(otherCrs, cr)
105+
}
93106
}
107+
94108
service := pdoknlv3.WFSService{
95109
BaseService: pdoknlv3.BaseService{
96110
Prefix: src.Spec.General.Dataset,
@@ -102,16 +116,8 @@ func (src *WFS) ToV3(dst *pdoknlv3.WFS) error {
102116
Fees: nil,
103117
AccessConstraints: smoothoperatormodel.URL{URL: accessConstraints},
104118
},
105-
DefaultCrs: src.Spec.Service.DataEPSG,
106-
OtherCrs: []string{
107-
"EPSG:25831",
108-
"EPSG:25832",
109-
"EPSG:3034",
110-
"EPSG:3035",
111-
"EPSG:3857",
112-
"EPSG:4258",
113-
"EPSG:4326",
114-
},
119+
DefaultCrs: src.Spec.Service.DataEPSG,
120+
OtherCrs: otherCrs,
115121
FeatureTypes: make([]pdoknlv3.FeatureType, 0),
116122
}
117123

api/v2beta1/wms_conversion.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ func (src *WMS) ToV3(target *pdoknlv3.WMS) error {
158158
if len(src.Spec.Service.StylingAssets.ConfigMapRefs) == 1 {
159159
for _, layer := range src.Spec.Service.Layers {
160160
for _, style := range layer.Styles {
161-
if style.Visualization != nil && !slices.Contains(src.Spec.Service.StylingAssets.ConfigMapRefs[0].Keys, *style.Visualization) {
162-
src.Spec.Service.StylingAssets.ConfigMapRefs[0].Keys = append(src.Spec.Service.StylingAssets.ConfigMapRefs[0].Keys, *style.Visualization)
161+
if style.Visualization != nil && !slices.Contains(service.StylingAssets.ConfigMapRefs[0].Keys, *style.Visualization) {
162+
service.StylingAssets.ConfigMapRefs[0].Keys = append(service.StylingAssets.ConfigMapRefs[0].Keys, *style.Visualization)
163163
}
164164
}
165165
}
@@ -440,45 +440,45 @@ func getDefaultWMSLayerBoundingBoxes(defaultBbox *pdoknlv3.WMSBoundingBox) []pdo
440440
CRS: "EPSG:25831",
441441
BBox: smoothoperatormodel.BBox{
442442
MinX: "-470271",
443-
MinY: "5.56231e+06",
443+
MinY: "5562310",
444444
MaxX: "795163",
445-
MaxY: "6.18197e+06",
445+
MaxY: "6181970",
446446
},
447447
},
448448
{
449449
CRS: "EPSG:25832",
450450
BBox: smoothoperatormodel.BBox{
451451
MinX: "62461.6",
452-
MinY: "5.56555e+06",
452+
MinY: "5565550",
453453
MaxX: "397827",
454-
MaxY: "6.19042e+06",
454+
MaxY: "6190420",
455455
},
456456
},
457457
{
458458
CRS: "EPSG:3034",
459459
BBox: smoothoperatormodel.BBox{
460-
MinX: "2.61336e+06",
461-
MinY: "3.509e+06",
462-
MaxX: "3.22007e+06",
463-
MaxY: "3.84003e+06",
460+
MinX: "2613360",
461+
MinY: "3509000",
462+
MaxX: "3220070",
463+
MaxY: "3840030",
464464
},
465465
},
466466
{
467467
CRS: "EPSG:3035",
468468
BBox: smoothoperatormodel.BBox{
469-
MinX: "3.01676e+06",
470-
MinY: "3.81264e+06",
471-
MaxX: "3.64485e+06",
472-
MaxY: "4.15586e+06",
469+
MinX: "3016760",
470+
MinY: "3812640",
471+
MaxX: "3644850",
472+
MaxY: "4155860",
473473
},
474474
},
475475
{
476476
CRS: "EPSG:3857",
477477
BBox: smoothoperatormodel.BBox{
478478
MinX: "281318",
479-
MinY: "6.48322e+06",
479+
MinY: "6483220",
480480
MaxX: "820873",
481-
MaxY: "7.50311e+06",
481+
MaxY: "7503110",
482482
},
483483
},
484484
{

api/v3/wfs_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ func (s WFSService) KeywordsIncludingInspireKeyword() []string {
136136

137137
// HealthCheck is the struct with all fields to configure custom healthchecks
138138
type HealthCheckWFS struct {
139-
// +kubebuilder:validation:XValidation:rule="self.contains('Service=WFS')",message="a valid healthcheck contains 'Service=WFS'"
140-
// +kubebuilder:validation:XValidation:rule="self.contains('Request=')",message="a valid healthcheck contains 'Request='"
139+
// +kubebuilder:validation:XValidation:rule="self.lowerAscii().contains('service=wfs')",message="a valid healthcheck contains 'Service=WFS'"
140+
// +kubebuilder:validation:XValidation:rule="self.lowerAscii().contains('request=')",message="a valid healthcheck contains 'Request='"
141141
Querystring string `json:"querystring"`
142142
// +kubebuilder:validation:Pattern=(image/png|text/xml|text/html)
143143
Mimetype string `json:"mimetype"`

api/v3/wms_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ func (wmsService WMSService) KeywordsIncludingInspireKeyword() []string {
155155
// +kubebuilder:validation:XValidation:rule="(has(self.boundingbox) || has(self.querystring)) && !(has(self.querystring) && has(self.boundingbox))", message="healthcheck should have exactly 1 of querystring + mimetype or boundingbox"
156156
// +kubebuilder:validation:XValidation:rule="(has(self.boundingbox) || has(self.mimetype)) && !(has(self.mimetype) && has(self.boundingbox))", message="healthcheck should have exactly 1 of querystring + mimetype or boundingbox"
157157
type HealthCheckWMS struct {
158-
// +kubebuilder:validation:XValidation:rule="self.contains('Service=WMS')",message="a valid healthcheck contains 'Service=WMS'"
159-
// +kubebuilder:validation:XValidation:rule="self.contains('Request=')",message="a valid healthcheck contains 'Request='"
158+
// +kubebuilder:validation:XValidation:rule="self.lowerAscii().contains('service=wms')",message="a valid healthcheck contains 'SERVICE=WMS'"
159+
// +kubebuilder:validation:XValidation:rule="self.lowerAscii().contains('request=')",message="a valid healthcheck contains 'REQUEST='"
160160
Querystring *string `json:"querystring,omitempty"`
161161
// +kubebuilder:validation:Pattern=(image/png|text/xml|text/html)
162162
Mimetype *string `json:"mimetype,omitempty"`
@@ -216,7 +216,8 @@ type Layer struct {
216216

217217
// Whether or not the layer is visible. At least one of the layers must be visible.
218218
// +kubebuilder:default:=true
219-
Visible bool `json:"visible,omitempty"`
219+
// +kubebuilder:validation:Optional
220+
Visible bool `json:"visible"`
220221

221222
// TODO ??
222223
Authority *Authority `json:"authority,omitempty"`

config/crd/bases/pdok.nl_wfs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ spec:
4949
type: string
5050
x-kubernetes-validations:
5151
- message: a valid healthcheck contains 'Service=WFS'
52-
rule: self.contains('Service=WFS')
52+
rule: self.lowerAscii().contains('service=wfs')
5353
- message: a valid healthcheck contains 'Request='
54-
rule: self.contains('Request=')
54+
rule: self.lowerAscii().contains('request=')
5555
required:
5656
- mimetype
5757
- querystring

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ spec:
7373
querystring:
7474
type: string
7575
x-kubernetes-validations:
76-
- message: a valid healthcheck contains 'Service=WMS'
77-
rule: self.contains('Service=WMS')
78-
- message: a valid healthcheck contains 'Request='
79-
rule: self.contains('Request=')
76+
- message: a valid healthcheck contains 'SERVICE=WMS'
77+
rule: self.lowerAscii().contains('service=wms')
78+
- message: a valid healthcheck contains 'REQUEST='
79+
rule: self.lowerAscii().contains('request=')
8080
type: object
8181
x-kubernetes-validations:
8282
- message: mimetype is required when a querystring is used

0 commit comments

Comments
 (0)