Skip to content

Commit f7acb15

Browse files
author
Jelle Dijkstra
committed
Conversion fixes
1 parent b7de593 commit f7acb15

File tree

7 files changed

+39
-34
lines changed

7 files changed

+39
-34
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 7 additions & 9 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 {

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: 2 additions & 2 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
}

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)