Skip to content

Commit e032337

Browse files
authored
Merge pull request #65 from PDOK/wr/linting
Wr/linting
2 parents 57d7165 + 765eada commit e032337

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+584
-728
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"fmt"
55

66
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
7-
shared_model "github.com/pdok/smooth-operator/model"
7+
"github.com/pdok/mapserver-operator/internal/controller/constants"
8+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
89
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
10+
911
autoscalingv2 "k8s.io/api/autoscaling/v2"
1012
corev1 "k8s.io/api/core/v1"
1113
)
@@ -93,7 +95,7 @@ func ConvertResources(src corev1.ResourceRequirements) *corev1.PodSpec {
9395
return &corev1.PodSpec{
9496
Containers: []corev1.Container{
9597
{
96-
Name: "mapserver",
98+
Name: constants.MapserverName,
9799
Resources: targetResources,
98100
},
99101
},
@@ -207,7 +209,7 @@ func ConvertV3DataToV2(v3 pdoknlv3.Data) Data {
207209
return v2
208210
}
209211

210-
func NewV2KubernetesObject(lifecycle *shared_model.Lifecycle, podSpecPatch *corev1.PodSpec, scalingSpec *pdoknlv3.HorizontalPodAutoscalerPatch) Kubernetes {
212+
func NewV2KubernetesObject(lifecycle *smoothoperatormodel.Lifecycle, podSpecPatch *corev1.PodSpec, scalingSpec *pdoknlv3.HorizontalPodAutoscalerPatch) Kubernetes {
211213
kub := Kubernetes{}
212214

213215
if lifecycle != nil && lifecycle.TTLInDays != nil {

api/v2beta1/wfs_conversion.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ package v2beta1
2727
import (
2828
"log"
2929

30+
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
31+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
3032
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
3133

32-
sharedModel "github.com/pdok/smooth-operator/model"
33-
3434
"sigs.k8s.io/controller-runtime/pkg/conversion"
35-
36-
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
3735
)
3836

3937
// ConvertTo converts this WFS (v2beta1) to the Hub version (v3).
@@ -51,7 +49,7 @@ func (src *WFS) ToV3(dst *pdoknlv3.WFS) error {
5149

5250
// Set LifeCycle if defined
5351
if src.Spec.Kubernetes.Lifecycle != nil && src.Spec.Kubernetes.Lifecycle.TTLInDays != nil {
54-
dst.Spec.Lifecycle = &sharedModel.Lifecycle{
52+
dst.Spec.Lifecycle = &smoothoperatormodel.Lifecycle{
5553
TTLInDays: smoothoperatorutils.Pointer(int32(*src.Spec.Kubernetes.Lifecycle.TTLInDays)),
5654
}
5755
}
@@ -104,11 +102,11 @@ func (src *WFS) ToV3(dst *pdoknlv3.WFS) error {
104102

105103
if src.Spec.Service.Extent != nil && *src.Spec.Service.Extent != "" {
106104
service.Bbox = &pdoknlv3.Bbox{
107-
DefaultCRS: sharedModel.ExtentToBBox(*src.Spec.Service.Extent),
105+
DefaultCRS: smoothoperatormodel.ExtentToBBox(*src.Spec.Service.Extent),
108106
}
109107
} else {
110108
service.Bbox = &pdoknlv3.Bbox{
111-
DefaultCRS: sharedModel.BBox{
109+
DefaultCRS: smoothoperatormodel.BBox{
112110
MinX: "-25000",
113111
MaxX: "280000",
114112
MinY: "250000",
@@ -155,7 +153,7 @@ func convertV2FeatureTypeToV3(src FeatureType) pdoknlv3.FeatureType {
155153

156154
if src.Extent != nil {
157155
featureTypeV3.Bbox = &pdoknlv3.FeatureBbox{
158-
DefaultCRS: sharedModel.ExtentToBBox(*src.Extent),
156+
DefaultCRS: smoothoperatormodel.ExtentToBBox(*src.Extent),
159157
}
160158
}
161159

api/v2beta1/wms_conversion.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import (
3030
"strconv"
3131
"strings"
3232

33+
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
34+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
3335
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
34-
"sigs.k8s.io/controller-runtime/pkg/conversion"
3536

36-
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
37-
sharedModel "github.com/pdok/smooth-operator/model"
37+
"sigs.k8s.io/controller-runtime/pkg/conversion"
3838
)
3939

4040
const ServiceMetatdataIdentifierAnnotation = "pdok.nl/wms-service-metadata-uuid"
@@ -60,7 +60,7 @@ func (src *WMS) ToV3(target *pdoknlv3.WMS) {
6060

6161
// Set LifeCycle if defined
6262
if src.Spec.Kubernetes.Lifecycle != nil && src.Spec.Kubernetes.Lifecycle.TTLInDays != nil {
63-
dst.Spec.Lifecycle = &sharedModel.Lifecycle{
63+
dst.Spec.Lifecycle = &smoothoperatormodel.Lifecycle{
6464
TTLInDays: smoothoperatorutils.Pointer(int32(*src.Spec.Kubernetes.Lifecycle.TTLInDays)),
6565
}
6666
}
@@ -151,7 +151,7 @@ func convertHealthCheckToV3(v2 *HealthCheck) *pdoknlv3.HealthCheckWMS {
151151
}
152152
case v2.Boundingbox != nil:
153153
return &pdoknlv3.HealthCheckWMS{
154-
Boundingbox: smoothoperatorutils.Pointer(sharedModel.ExtentToBBox(strings.ReplaceAll(*v2.Boundingbox, ",", " "))),
154+
Boundingbox: smoothoperatorutils.Pointer(smoothoperatormodel.ExtentToBBox(strings.ReplaceAll(*v2.Boundingbox, ",", " "))),
155155
}
156156
}
157157
}
@@ -247,8 +247,8 @@ func (dst *WMS) ConvertFrom(srcRaw conversion.Hub) error {
247247
if service.Extent == nil {
248248
service.Extent = l.Extent
249249
} else {
250-
bbox := smoothoperatorutils.Pointer(sharedModel.ExtentToBBox(*service.Extent)).DeepCopy()
251-
bbox.Combine(sharedModel.ExtentToBBox(*l.Extent))
250+
bbox := smoothoperatorutils.Pointer(smoothoperatormodel.ExtentToBBox(*service.Extent)).DeepCopy()
251+
bbox.Combine(smoothoperatormodel.ExtentToBBox(*l.Extent))
252252
service.Extent = smoothoperatorutils.Pointer(bbox.ToExtent())
253253
}
254254
}
@@ -344,7 +344,7 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
344344
bboxStringList := strings.Split(*v2Service.Extent, " ")
345345
bbox := pdoknlv3.WMSBoundingBox{
346346
CRS: v2Service.DataEPSG,
347-
BBox: sharedModel.BBox{
347+
BBox: smoothoperatormodel.BBox{
348348
MinX: bboxStringList[0],
349349
MaxX: bboxStringList[2],
350350
MinY: bboxStringList[1],
@@ -421,12 +421,12 @@ func (v2Layer WMSLayer) MapToV3(v2Service WMSService) pdoknlv3.Layer {
421421
if v2Layer.Extent != nil {
422422
layer.BoundingBoxes = append(layer.BoundingBoxes, pdoknlv3.WMSBoundingBox{
423423
CRS: v2Service.DataEPSG,
424-
BBox: sharedModel.ExtentToBBox(*v2Layer.Extent),
424+
BBox: smoothoperatormodel.ExtentToBBox(*v2Layer.Extent),
425425
})
426426
} else if v2Service.Extent != nil {
427427
layer.BoundingBoxes = append(layer.BoundingBoxes, pdoknlv3.WMSBoundingBox{
428428
CRS: v2Service.DataEPSG,
429-
BBox: sharedModel.ExtentToBBox(*v2Service.Extent),
429+
BBox: smoothoperatormodel.ExtentToBBox(*v2Service.Extent),
430430
})
431431
}
432432

api/v3/shared_validation.go

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

33
import (
4-
"github.com/pdok/smooth-operator/model"
4+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
55
sharedValidation "github.com/pdok/smooth-operator/pkg/validation"
6+
67
apierrors "k8s.io/apimachinery/pkg/api/errors"
78
"k8s.io/apimachinery/pkg/util/validation/field"
89
)
@@ -14,17 +15,17 @@ func ValidateUpdate[W WMSWFS](newW, oldW W, validate func(W, *[]string, *field.E
1415
sharedValidation.ValidateLabelsOnUpdate(oldW.GetLabels(), newW.GetLabels(), &allErrs)
1516

1617
path := field.NewPath("spec").Child("service").Child("url")
17-
oldURL, err := model.ParseURL(oldW.URLPath())
18+
oldURL, err := smoothoperatormodel.ParseURL(oldW.URLPath())
1819
if err != nil {
1920
allErrs = append(allErrs, field.InternalError(path, err))
2021
}
21-
newURL, err := model.ParseURL(oldW.URLPath())
22+
newURL, err := smoothoperatormodel.ParseURL(oldW.URLPath())
2223
if err != nil {
2324
allErrs = append(allErrs, field.InternalError(path, err))
2425
}
2526
sharedValidation.CheckUrlImmutability(
26-
model.URL{URL: oldURL},
27-
model.URL{URL: newURL},
27+
smoothoperatormodel.URL{URL: oldURL},
28+
smoothoperatormodel.URL{URL: newURL},
2829
&allErrs,
2930
path,
3031
)

api/v3/wfs_types.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import (
2929
"slices"
3030
"strings"
3131

32-
shared_model "github.com/pdok/smooth-operator/model"
32+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
33+
3334
corev1 "k8s.io/api/core/v1"
3435
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3536
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -51,8 +52,8 @@ type WFS struct {
5152
metav1.TypeMeta `json:",inline"`
5253
metav1.ObjectMeta `json:"metadata,omitempty"`
5354

54-
Spec WFSSpec `json:"spec,omitempty"`
55-
Status shared_model.OperatorStatus `json:"status,omitempty"`
55+
Spec WFSSpec `json:"spec,omitempty"`
56+
Status smoothoperatormodel.OperatorStatus `json:"status,omitempty"`
5657
}
5758

5859
// +kubebuilder:object:root=true
@@ -71,7 +72,7 @@ func init() {
7172
// WFSSpec vertegenwoordigt de hoofdstruct voor de YAML-configuratie
7273
type WFSSpec struct {
7374
// Optional lifecycle settings
74-
Lifecycle *shared_model.Lifecycle `json:"lifecycle,omitempty"`
75+
Lifecycle *smoothoperatormodel.Lifecycle `json:"lifecycle,omitempty"`
7576

7677
// +kubebuilder:validation:Type=object
7778
// +kubebuilder:validation:Schemaless
@@ -174,7 +175,7 @@ type Bbox struct {
174175
// EXTENT/wfs_extent in mapfile
175176
//nolint:tagliatelle
176177
// +kubebuilder:validation:Type=object
177-
DefaultCRS shared_model.BBox `json:"defaultCRS"`
178+
DefaultCRS smoothoperatormodel.BBox `json:"defaultCRS"`
178179
}
179180

180181
// FeatureType defines a WFS feature
@@ -214,11 +215,11 @@ type FeatureBbox struct {
214215
// DefaultCRS defines the feature’s bounding box in the service’s own CRS
215216
//nolint:tagliatelle
216217
// +kubebuilder:validation:Type=object
217-
DefaultCRS shared_model.BBox `json:"defaultCRS"`
218+
DefaultCRS smoothoperatormodel.BBox `json:"defaultCRS"`
218219

219220
// WGS84, if provided, gives the same bounding box reprojected into EPSG:4326.
220221
// +kubebuilder:validation:Type=object
221-
WGS84 *shared_model.BBox `json:"wgs84,omitempty"`
222+
WGS84 *smoothoperatormodel.BBox `json:"wgs84,omitempty"`
222223
}
223224

224225
func (wfs *WFS) HasPostgisData() bool {

api/v3/wfs_validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package v3
33
import (
44
"strings"
55

6+
sharedValidation "github.com/pdok/smooth-operator/pkg/validation"
7+
68
apierrors "k8s.io/apimachinery/pkg/api/errors"
79
"k8s.io/apimachinery/pkg/runtime/schema"
810
"k8s.io/apimachinery/pkg/util/validation/field"
9-
10-
sharedValidation "github.com/pdok/smooth-operator/pkg/validation"
1111
)
1212

1313
func (wfs *WFS) ValidateCreate() ([]string, error) {

api/v3/wms_types.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import (
3232
"sort"
3333
"strings"
3434

35-
"k8s.io/apimachinery/pkg/runtime/schema"
35+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
3636

37-
shared_model "github.com/pdok/smooth-operator/model"
3837
corev1 "k8s.io/api/core/v1"
3938
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
39+
"k8s.io/apimachinery/pkg/runtime/schema"
4040
)
4141

4242
const (
@@ -51,7 +51,7 @@ const (
5151
// WMSSpec defines the desired state of WMS.
5252
type WMSSpec struct {
5353
// Optional lifecycle settings
54-
Lifecycle *shared_model.Lifecycle `json:"lifecycle,omitempty"`
54+
Lifecycle *smoothoperatormodel.Lifecycle `json:"lifecycle,omitempty"`
5555

5656
// +kubebuilder:validation:Type=object
5757
// +kubebuilder:validation:Schemaless
@@ -144,7 +144,7 @@ type HealthCheckWMS struct {
144144
// +kubebuilder:validation:Pattern=(image/png|text/xml|text/html)
145145
Mimetype *string `json:"mimetype,omitempty"`
146146

147-
Boundingbox *shared_model.BBox `json:"boundingbox,omitempty"`
147+
Boundingbox *smoothoperatormodel.BBox `json:"boundingbox,omitempty"`
148148
}
149149

150150
// +kubebuilder:validation:XValidation:message="Either blobKeys or configMapRefs is required",rule="has(self.blobKeys) || has(self.configMapRefs)"
@@ -226,8 +226,8 @@ type Layer struct {
226226
}
227227

228228
type WMSBoundingBox struct {
229-
CRS string `json:"crs"`
230-
BBox shared_model.BBox `json:"bbox"`
229+
CRS string `json:"crs"`
230+
BBox smoothoperatormodel.BBox `json:"bbox"`
231231
}
232232

233233
func (wmsBoundingBox *WMSBoundingBox) ToExtent() string {
@@ -294,8 +294,8 @@ type WMS struct {
294294
metav1.TypeMeta `json:",inline"`
295295
metav1.ObjectMeta `json:"metadata,omitempty"`
296296

297-
Spec WMSSpec `json:"spec,omitempty"`
298-
Status shared_model.OperatorStatus `json:"status,omitempty"`
297+
Spec WMSSpec `json:"spec,omitempty"`
298+
Status smoothoperatormodel.OperatorStatus `json:"status,omitempty"`
299299
}
300300

301301
// +kubebuilder:object:root=true
@@ -333,7 +333,7 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {
333333

334334
return WMSBoundingBox{
335335
CRS: "EPSG:28992",
336-
BBox: shared_model.BBox{
336+
BBox: smoothoperatormodel.BBox{
337337
MinX: "-25000",
338338
MaxX: "280000",
339339
MinY: "250000",

api/v3/wms_types_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import (
55
"testing"
66

77
"github.com/google/go-cmp/cmp"
8-
"github.com/pdok/smooth-operator/model"
8+
9+
smoothoperatormodel "github.com/pdok/smooth-operator/model"
910
smoothoperatorutils "github.com/pdok/smooth-operator/pkg/util"
1011
)
1112

1213
func TestLayer_setInheritedBoundingBoxes(t *testing.T) {
1314
first28992BoundingBox := WMSBoundingBox{
1415
CRS: "EPSG:28992",
15-
BBox: model.BBox{
16+
BBox: smoothoperatormodel.BBox{
1617
MinX: "482.06",
1718
MaxX: "306602.42",
1819
MinY: "284182.97",
@@ -21,7 +22,7 @@ func TestLayer_setInheritedBoundingBoxes(t *testing.T) {
2122
}
2223
first4326BoundingBox := WMSBoundingBox{
2324
CRS: "EPSG:4326",
24-
BBox: model.BBox{
25+
BBox: smoothoperatormodel.BBox{
2526
MinX: "2.35417303",
2627
MaxX: "7.5553525",
2728
MinY: "50.71447164",
@@ -30,15 +31,15 @@ func TestLayer_setInheritedBoundingBoxes(t *testing.T) {
3031
}
3132
first4258BoundingBox := WMSBoundingBox{
3233
CRS: "EPSG:4258",
33-
BBox: model.BBox{
34+
BBox: smoothoperatormodel.BBox{
3435
MinX: "2.354173",
3536
MaxX: "7.5553527",
3637
MinY: "50.71447",
3738
MaxY: "55.66948",
3839
}}
3940
second28992BoundingBox := WMSBoundingBox{
4041
CRS: "EPSG:28992",
41-
BBox: model.BBox{
42+
BBox: smoothoperatormodel.BBox{
4243
MinX: "0.00",
4344
MaxX: "310000.00",
4445
MinY: "275000.00",

cmd/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"flag"
2323
"os"
2424

25-
"github.com/pdok/mapserver-operator/internal/controller/mapserver"
25+
"github.com/pdok/mapserver-operator/internal/controller/types"
2626

2727
"github.com/go-logr/zapr"
2828
"github.com/pdok/smooth-operator/pkg/integrations/logging"
@@ -145,7 +145,7 @@ func main() {
145145
pdoknlv3.SetHost(host)
146146
mapfilegenerator.SetDebugLevel(mapserverDebugLevel)
147147
controller.SetUptimeOperatorAnnotations(setUptimeOperatorAnnotations)
148-
mapserver.SetStorageClassName(storageClassName)
148+
controller.SetStorageClassName(storageClassName)
149149

150150
// if the enable-http2 flag is false (the default), http/2 should be disabled
151151
// due to its vulnerabilities. More specifically, disabling http/2 will
@@ -198,7 +198,7 @@ func main() {
198198
if err = (&controller.WMSReconciler{
199199
Client: mgr.GetClient(),
200200
Scheme: mgr.GetScheme(),
201-
Images: controller.Images{
201+
Images: types.Images{
202202
MultitoolImage: multitoolImage,
203203
MapfileGeneratorImage: mapfileGeneratorImage,
204204
MapserverImage: mapserverImage,
@@ -214,7 +214,7 @@ func main() {
214214
if err = (&controller.WFSReconciler{
215215
Client: mgr.GetClient(),
216216
Scheme: mgr.GetScheme(),
217-
Images: controller.Images{
217+
Images: types.Images{
218218
MultitoolImage: multitoolImage,
219219
MapfileGeneratorImage: mapfileGeneratorImage,
220220
MapserverImage: mapserverImage,

0 commit comments

Comments
 (0)