Skip to content

Commit a448bd3

Browse files
Merge pull request #48 from PDOK/jd/optional-options
Optional options + mapfilegenerator testfiles moved to yaml+json files
2 parents 28a2d30 + 6ebeacb commit a448bd3

31 files changed

+3515
-354
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import (
1010
corev1 "k8s.io/api/core/v1"
1111
)
1212

13-
func ConvertOptionsV2ToV3(src WMSWFSOptions) pdoknlv3.Options {
13+
func ConvertOptionsV2ToV3(src *WMSWFSOptions) *pdoknlv3.Options {
1414
defaults := pdoknlv3.GetDefaultOptions()
1515

16-
return pdoknlv3.Options{
16+
if src == nil {
17+
return defaults
18+
}
19+
20+
return &pdoknlv3.Options{
1721
AutomaticCasing: src.AutomaticCasing,
1822
IncludeIngress: src.IncludeIngress,
1923
PrefetchData: smoothoperatorutils.PointerVal(src.PrefetchData, defaults.PrefetchData),
@@ -24,8 +28,12 @@ func ConvertOptionsV2ToV3(src WMSWFSOptions) pdoknlv3.Options {
2428
}
2529
}
2630

27-
func ConvertOptionsV3ToV2(src pdoknlv3.Options) WMSWFSOptions {
28-
return WMSWFSOptions{
31+
func ConvertOptionsV3ToV2(src *pdoknlv3.Options) *WMSWFSOptions {
32+
if src == nil {
33+
src = pdoknlv3.GetDefaultOptions()
34+
}
35+
36+
return &WMSWFSOptions{
2937
AutomaticCasing: src.AutomaticCasing,
3038
IncludeIngress: src.IncludeIngress,
3139
PrefetchData: &src.PrefetchData,

api/v2beta1/wfs_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ type WFSList struct {
5454

5555
// WFSSpec is the struct for all fields defined in the WFS CRD
5656
type WFSSpec struct {
57-
General General `json:"general"`
58-
Service WFSService `json:"service"`
59-
Kubernetes Kubernetes `json:"kubernetes"`
60-
Options WMSWFSOptions `json:"options,omitempty"`
57+
General General `json:"general"`
58+
Service WFSService `json:"service"`
59+
Kubernetes Kubernetes `json:"kubernetes"`
60+
Options *WMSWFSOptions `json:"options,omitempty"`
6161
}
6262

6363
// WFSService is the struct with all service specific options

api/v2beta1/wms_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ type WMS struct {
4646

4747
// WMSSpec is the struct for all fields defined in the WMS CRD
4848
type WMSSpec struct {
49-
General General `json:"general"`
50-
Service WMSService `json:"service"`
51-
Options WMSWFSOptions `json:"options"`
52-
Kubernetes Kubernetes `json:"kubernetes"`
49+
General General `json:"general"`
50+
Service WMSService `json:"service"`
51+
Options *WMSWFSOptions `json:"options,omitempty"`
52+
Kubernetes Kubernetes `json:"kubernetes"`
5353
}
5454

5555
// WMSService is the struct for all service level fields

api/v2beta1/zz_generated.deepcopy.go

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

api/v3/wfs_types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type WFSSpec struct {
7878
PodSpecPatch *corev1.PodSpec `json:"podSpecPatch,omitempty"`
7979
HorizontalPodAutoscalerPatch *HorizontalPodAutoscalerPatch `json:"horizontalPodAutoscalerPatch,omitempty"`
8080
// TODO omitting the options field or setting an empty value results in incorrect defaulting of the options
81-
Options Options `json:"options"`
81+
Options *Options `json:"options,omitempty"`
8282

8383
// service configuration
8484
Service WFSService `json:"service"`
@@ -242,7 +242,11 @@ func (wfs *WFS) HorizontalPodAutoscalerPatch() *HorizontalPodAutoscalerPatch {
242242
}
243243

244244
func (wfs *WFS) Options() Options {
245-
return wfs.Spec.Options
245+
if wfs.Spec.Options == nil {
246+
return *GetDefaultOptions()
247+
}
248+
249+
return *wfs.Spec.Options
246250
}
247251

248252
func (wfs *WFS) ID() string {

api/v3/wms_types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type WMSSpec struct {
6161

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

6666
// Service specification
6767
Service WMSService `json:"service"`
@@ -569,7 +569,11 @@ func (wms *WMS) HorizontalPodAutoscalerPatch() *HorizontalPodAutoscalerPatch {
569569
}
570570

571571
func (wms *WMS) Options() Options {
572-
return wms.Spec.Options
572+
if wms.Spec.Options == nil {
573+
return *GetDefaultOptions()
574+
}
575+
576+
return *wms.Spec.Options
573577
}
574578

575579
func (wms *WMS) ID() string {

api/v3/wms_validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func ValidateWMS(wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
7979
}
8080
}
8181

82-
var rewriteGroupToDataLayers = wms.Spec.Options.RewriteGroupToDataLayers
83-
var validateChildStyleNameEqual = wms.Spec.Options.ValidateChildStyleNameEqual
82+
var rewriteGroupToDataLayers = wms.Options().RewriteGroupToDataLayers
83+
var validateChildStyleNameEqual = wms.Options().ValidateChildStyleNameEqual
8484

8585
equalChildStyleNames := map[string][]string{}
8686
if rewriteGroupToDataLayers && validateChildStyleNameEqual {

api/v3/zz_generated.deepcopy.go

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

config/crd/bases/pdok.nl_wfs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,6 @@ spec:
15411541
- url
15421542
type: object
15431543
required:
1544-
- options
15451544
- service
15461545
type: object
15471546
status:

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ spec:
397397
required:
398398
- general
399399
- kubernetes
400-
- options
401400
- service
402401
type: object
403402
status:
@@ -2097,7 +2096,6 @@ spec:
20972096
- url
20982097
type: object
20992098
required:
2100-
- options
21012099
- service
21022100
type: object
21032101
status:

0 commit comments

Comments
 (0)