Skip to content

Commit cdef4b0

Browse files
committed
Merge reconcile branch
2 parents 5deec71 + d9f72c9 commit cdef4b0

32 files changed

+2772
-817
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
66
shared_model "github.com/pdok/smooth-operator/model"
7-
autoscalingv2 "k8s.io/api/autoscaling/v2beta1"
7+
autoscalingv2 "k8s.io/api/autoscaling/v2"
88
corev1 "k8s.io/api/core/v1"
99
)
1010

@@ -60,8 +60,11 @@ func ConverseAutoscaling(src Autoscaling) *autoscalingv2.HorizontalPodAutoscaler
6060
metrics = append(metrics, autoscalingv2.MetricSpec{
6161
Type: autoscalingv2.ResourceMetricSourceType,
6262
Resource: &autoscalingv2.ResourceMetricSource{
63-
Name: corev1.ResourceCPU,
64-
TargetAverageUtilization: Pointer(int32(*src.AverageCPUUtilization)),
63+
Name: corev1.ResourceCPU,
64+
Target: autoscalingv2.MetricTarget{
65+
Type: autoscalingv2.UtilizationMetricType,
66+
AverageUtilization: Pointer(int32(*src.AverageCPUUtilization)),
67+
},
6568
},
6669
})
6770
}
@@ -215,7 +218,7 @@ func NewV2KubernetesObject(lifecycle *shared_model.Lifecycle, podSpecPatch *core
215218

216219
if scalingSpec.Metrics != nil {
217220
kub.Autoscaling.AverageCPUUtilization = Pointer(
218-
int(*scalingSpec.Metrics[0].Resource.TargetAverageUtilization),
221+
int(*scalingSpec.Metrics[0].Resource.Target.AverageUtilization),
219222
)
220223
}
221224
}

api/v2beta1/wfs_conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (src *WFS) ConvertTo(dstRaw conversion.Hub) error {
6161

6262
service := pdoknlv3.WFSService{
6363
Prefix: "",
64-
BaseURL: CreateBaseURL("https://service.pdok.nl", "wfs", src.Spec.General),
64+
URL: CreateBaseURL("https://service.pdok.nl", "wfs", src.Spec.General),
6565
OwnerInfoRef: "pdok",
6666
Title: src.Spec.Service.Title,
6767
Abstract: src.Spec.Service.Abstract,

api/v2beta1/wms_conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (src *WMS) ConvertTo(dstRaw conversion.Hub) error {
6565
dst.Spec.Options = ConverseOptionsV2ToV3(src.Spec.Options)
6666

6767
service := pdoknlv3.WMSService{
68-
BaseURL: CreateBaseURL("https://service.pdok.nl", "wms", src.Spec.General),
68+
URL: CreateBaseURL("https://service.pdok.nl", "wms", src.Spec.General),
6969
OwnerInfoRef: "pdok",
7070
Title: src.Spec.Service.Title,
7171
Abstract: src.Spec.Service.Abstract,

api/v2beta1/wms_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type StylingAssets struct {
109109
BlobKeys []string `json:"blobKeys,omitempty"`
110110
}
111111

112-
// ConfigMapRef contains all the config map name and all keys in that configmap that are relevant
112+
// ConfigMapRef contains all the config map name and all keys in that mapserver that are relevant
113113
// the Keys can be empty, so that the v1 WMS can convert to the v2beta1 WMS
114114
type ConfigMapRef struct {
115115
Name string `json:"name"`

api/v3/shared_types.go

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
package v3
22

33
import (
4+
autoscalingv2 "k8s.io/api/autoscaling/v2"
45
corev1 "k8s.io/api/core/v1"
6+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7+
"net/url"
58
"strings"
69
)
710

8-
var baseURL string
11+
var host string
12+
13+
type ServiceType string
14+
15+
const (
16+
ServiceTypeWMS ServiceType = "WMS"
17+
ServiceTypeWFS ServiceType = "WFS"
18+
)
19+
20+
type WMSWFS interface {
21+
*WFS | *WMS
22+
metav1.Object
23+
24+
Mapfile() *Mapfile
25+
PodSpecPatch() *corev1.PodSpec
26+
HorizontalPodAutoscalerPatch() *autoscalingv2.HorizontalPodAutoscalerSpec
27+
Type() ServiceType
28+
Options() *Options
29+
}
930

1031
type Mapfile struct {
1132
ConfigMapKeyRef corev1.ConfigMapKeySelector `json:"configMapKeyRef"`
@@ -73,12 +94,29 @@ type Column struct {
7394
Alias *string `json:"alias,omitempty"`
7495
}
7596

76-
func SetBaseURL(url string) {
77-
baseURL = strings.TrimSuffix(url, "/")
97+
func SetHost(url string) {
98+
host = strings.TrimSuffix(url, "/")
99+
}
100+
101+
func GetHost() string {
102+
return host
78103
}
79104

80-
func GetBaseURL() string {
81-
return baseURL
105+
func GetBaseURLPath[T *WFS | *WMS](o T) string {
106+
var serviceUrl string
107+
switch any(o).(type) {
108+
case *WFS:
109+
if WFS, ok := any(o).(*WFS); ok {
110+
serviceUrl = WFS.Spec.Service.URL
111+
}
112+
case *WMS:
113+
if WMS, ok := any(o).(*WMS); ok {
114+
serviceUrl = WMS.Spec.Service.URL
115+
}
116+
}
117+
118+
parsed, _ := url.Parse(serviceUrl)
119+
return strings.TrimPrefix(parsed.Path, "/")
82120
}
83121

84122
func (d *Data) GetColumns() *[]Column {

api/v3/wfs_types.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ package v3
2626

2727
import (
2828
shared_model "github.com/pdok/smooth-operator/model"
29-
autoscalingv2 "k8s.io/api/autoscaling/v2beta1"
29+
autoscalingv2 "k8s.io/api/autoscaling/v2"
3030
corev1 "k8s.io/api/core/v1"
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
)
@@ -79,7 +79,7 @@ type WFSSpec struct {
7979

8080
type WFSService struct {
8181
Prefix string `json:"prefix"`
82-
BaseURL string `json:"baseUrl"`
82+
URL string `json:"url"`
8383
Inspire *Inspire `json:"inspire,omitempty"`
8484
Mapfile *Mapfile `json:"mapfile,omitempty"`
8585
OwnerInfoRef string `json:"ownerInfoRef"`
@@ -126,3 +126,23 @@ func (wfs *WFS) HasPostgisData() bool {
126126
}
127127
return false
128128
}
129+
130+
func (wfs *WFS) Mapfile() *Mapfile {
131+
return wfs.Spec.Service.Mapfile
132+
}
133+
134+
func (wfs *WFS) Type() ServiceType {
135+
return ServiceTypeWFS
136+
}
137+
138+
func (wfs *WFS) PodSpecPatch() *corev1.PodSpec {
139+
return wfs.Spec.PodSpecPatch
140+
}
141+
142+
func (wfs *WFS) HorizontalPodAutoscalerPatch() *autoscalingv2.HorizontalPodAutoscalerSpec {
143+
return wfs.Spec.HorizontalPodAutoscalerPatch
144+
}
145+
146+
func (wfs *WFS) Options() *Options {
147+
return wfs.Spec.Options
148+
}

api/v3/wfs_validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (wfs *WFS) ValidateUpdate(wfsOld *WFS) ([]string, error) {
3535
}
3636

3737
// Check service.baseURL did not change
38-
if wfs.Spec.Service.BaseURL != wfsOld.Spec.Service.BaseURL {
38+
if wfs.Spec.Service.URL != wfsOld.Spec.Service.URL {
3939
reasons = append(reasons, fmt.Sprintf("service.baseURL is immutable"))
4040
}
4141

@@ -59,7 +59,7 @@ func validateWFS(wfs *WFS, warnings *[]string, reasons *[]string) {
5959

6060
service := wfs.Spec.Service
6161

62-
err := sharedValidation.ValidateBaseURL(service.BaseURL)
62+
err := sharedValidation.ValidateBaseURL(service.URL)
6363
if err != nil {
6464
*reasons = append(*reasons, fmt.Sprintf("%v", err))
6565
}

api/v3/wms_types.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ package v3
2626

2727
import (
2828
shared_model "github.com/pdok/smooth-operator/model"
29-
autoscalingv2 "k8s.io/api/autoscaling/v2beta1"
29+
autoscalingv2 "k8s.io/api/autoscaling/v2"
3030
corev1 "k8s.io/api/core/v1"
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"maps"
@@ -52,7 +52,7 @@ type WMSSpec struct {
5252
}
5353

5454
type WMSService struct {
55-
BaseURL string `json:"baseUrl"`
55+
URL string `json:"url"`
5656
Title string `json:"title"`
5757
Abstract string `json:"abstract"`
5858
Keywords []string `json:"keywords"`
@@ -233,3 +233,23 @@ func (wms *WMS) GetAuthority() *Authority {
233233

234234
return nil
235235
}
236+
237+
func (wms *WMS) Mapfile() *Mapfile {
238+
return wms.Spec.Service.Mapfile
239+
}
240+
241+
func (wms *WMS) Type() ServiceType {
242+
return ServiceTypeWMS
243+
}
244+
245+
func (wms *WMS) PodSpecPatch() *corev1.PodSpec {
246+
return wms.Spec.PodSpecPatch
247+
}
248+
249+
func (wms *WMS) HorizontalPodAutoscalerPatch() *autoscalingv2.HorizontalPodAutoscalerSpec {
250+
return wms.Spec.HorizontalPodAutoscalerPatch
251+
}
252+
253+
func (wms *WMS) Options() *Options {
254+
return wms.Spec.Options
255+
}

api/v3/zz_generated.deepcopy.go

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

cmd/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func main() {
7474
var secureMetrics bool
7575
var enableHTTP2 bool
7676
var tlsOpts []func(*tls.Config)
77-
var baseURL string
77+
var host string
7878
var multitoolImage string
7979
var mapfileGeneratorImage string
8080
var capabilitiesGeneratorImage string
@@ -95,7 +95,7 @@ func main() {
9595
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
9696
flag.BoolVar(&enableHTTP2, "enable-http2", false,
9797
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
98-
flag.StringVar(&baseURL, "baseurl", "", "The base url which is used in the mapserver service.")
98+
flag.StringVar(&host, "baseurl", "", "The host which is used in the mapserver service.")
9999
flag.StringVar(&multitoolImage, "multitool-image", defaultMultitoolImage, "The image to use in the blob download init-container.")
100100
flag.StringVar(&mapfileGeneratorImage, "mapfile-generator-image", defaultMapfileGeneratorImage, "The image to use in the mapfile generator init-container.")
101101
flag.StringVar(&capabilitiesGeneratorImage, "capabilities-generator-image", defaultCapabilitiesGeneratorImage, "The image to use in the capabilities generator init-container.")
@@ -108,11 +108,11 @@ func main() {
108108

109109
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
110110

111-
if baseURL == "" {
111+
if host == "" {
112112
setupLog.Error(errors.New("baseURL is required"), "A value for baseURL must be specified.")
113113
os.Exit(1)
114114
}
115-
pdoknlv3.SetBaseURL(baseURL)
115+
pdoknlv3.SetHost(host)
116116

117117
// if the enable-http2 flag is false (the default), http/2 should be disabled
118118
// due to its vulnerabilities. More specifically, disabling http/2 will

0 commit comments

Comments
 (0)