Skip to content

Commit d4adcd6

Browse files
author
Jelle Dijkstra
committed
Fixed some linting
1 parent d96dee8 commit d4adcd6

30 files changed

+186
-200
lines changed

api/v2beta1/wms_conversion.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ package v2beta1
2626

2727
import (
2828
"errors"
29-
sharedModel "github.com/pdok/smooth-operator/model"
3029
"log"
3130
"sigs.k8s.io/controller-runtime/pkg/conversion"
3231
"strconv"
3332
"strings"
3433

3534
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
35+
sharedModel "github.com/pdok/smooth-operator/model"
3636
)
3737

38-
const SERVICE_METADATA_IDENTIFIER_ANNOTATION = "pdok.nl/wms-service-metadata-uuid"
38+
const ServiceMetatdataIdentifierAnnotation = "pdok.nl/wms-service-metadata-uuid"
3939

4040
// ConvertTo converts this WMS (v2beta1) to the Hub version (v3).
4141
func (src *WMS) ConvertTo(dstRaw conversion.Hub) error {
@@ -55,7 +55,7 @@ func V3HubFromV2(src *WMS, target *pdoknlv3.WMS) {
5555
dst.Annotations = make(map[string]string)
5656
}
5757

58-
dst.Annotations[SERVICE_METADATA_IDENTIFIER_ANNOTATION] = src.Spec.Service.MetadataIdentifier
58+
dst.Annotations[ServiceMetatdataIdentifierAnnotation] = src.Spec.Service.MetadataIdentifier
5959

6060
// Set LifeCycle if defined
6161
if src.Spec.Kubernetes.Lifecycle != nil && src.Spec.Kubernetes.Lifecycle.TTLInDays != nil {
@@ -179,7 +179,7 @@ func (dst *WMS) ConvertFrom(srcRaw conversion.Hub) error {
179179
// TODO unable to fill in MetadataIdentifier here until we know how to handle non inspire services
180180
}
181181

182-
uuid, ok := src.Annotations[SERVICE_METADATA_IDENTIFIER_ANNOTATION]
182+
uuid, ok := src.Annotations[ServiceMetatdataIdentifierAnnotation]
183183
if service.MetadataIdentifier == "00000000-0000-0000-0000-000000000000" && ok {
184184
service.MetadataIdentifier = uuid
185185
}

api/v2beta1/wms_conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func TestV2ToV3(t *testing.T) {
11+
//nolint:misspell
1112
input := "apiVersion: pdok.nl/v2beta1\nkind: WMS\nmetadata:\n name: rws-nwbwegen-v1-0\n labels:\n dataset-owner: rws\n dataset: nwbwegen\n service-version: v1_0\n service-type: wms\n annotations:\n lifecycle-phase: prod\n service-bundle-id: b39c152b-393b-52f5-a50c-e1ffe904b6fb\nspec:\n general:\n datasetOwner: rws\n dataset: nwbwegen\n serviceVersion: v1_0\n kubernetes:\n healthCheck:\n boundingbox: 135134.89,457152.55,135416.03,457187.82\n resources:\n limits:\n ephemeralStorage: 1535Mi\n memory: 4G\n requests:\n cpu: 2000m\n ephemeralStorage: 1535Mi\n memory: 4G\n options:\n automaticCasing: true\n disableWebserviceProxy: false\n includeIngress: true\n validateRequests: true\n service:\n title: NWB - Wegen WMS\n abstract:\n Dit is de web map service van het Nationaal Wegen Bestand (NWB) - wegen.\n Deze dataset bevat alleen de wegvakken en hectometerpunten. Het Nationaal Wegen\n Bestand - Wegen is een digitaal geografisch bestand van alle wegen in Nederland.\n Opgenomen zijn alle wegen die worden beheerd door wegbeheerders als het Rijk,\n provincies, gemeenten en waterschappen, echter alleen voor zover deze zijn voorzien\n van een straatnaam of nummer.\n authority:\n name: rws\n url: https://www.rijkswaterstaat.nl\n dataEPSG: EPSG:28992\n extent: -59188.44333693248 304984.64144318487 308126.88473339565 858328.516489961\n inspire: true\n keywords:\n - Vervoersnetwerken\n - Menselijke gezondheid en veiligheid\n - Geluidsbelasting hoofdwegen (Richtlijn Omgevingslawaai)\n - Nationaal\n - Voertuigen\n - Verkeer\n - Wegvakken\n - Hectometerpunten\n - HVD\n - Mobiliteit\n stylingAssets:\n configMapRefs:\n - name: includes\n keys:\n - nwb_wegen_hectopunten.symbol\n - hectopunten.style\n - wegvakken.style\n blobKeys:\n - resources/fonts/liberation-sans.ttf\n layers:\n - abstract:\n Deze laag bevat de wegvakken uit het Nationaal Wegen bestand (NWB)\n en geeft gedetailleerde informatie per wegvak zoals straatnaam, wegnummer,\n routenummer, wegbeheerder, huisnummers, enz. weer.\n data:\n gpkg:\n columns:\n - objectid\n - wvk_id\n - wvk_begdat\n - jte_id_beg\n - jte_id_end\n - wegbehsrt\n - wegnummer\n - wegdeelltr\n - hecto_lttr\n - bst_code\n - rpe_code\n - admrichtng\n - rijrichtng\n - stt_naam\n - stt_bron\n - wpsnaam\n - gme_id\n - gme_naam\n - hnrstrlnks\n - hnrstrrhts\n - e_hnr_lnks\n - e_hnr_rhts\n - l_hnr_lnks\n - l_hnr_rhts\n - begafstand\n - endafstand\n - beginkm\n - eindkm\n - pos_tv_wol\n - wegbehcode\n - wegbehnaam\n - distrcode\n - distrnaam\n - dienstcode\n - dienstnaam\n - wegtype\n - wgtype_oms\n - routeltr\n - routenr\n - routeltr2\n - routenr2\n - routeltr3\n - routenr3\n - routeltr4\n - routenr4\n - wegnr_aw\n - wegnr_hmp\n - geobron_id\n - geobron_nm\n - bronjaar\n - openlr\n - bag_orl\n - frc\n - fow\n - alt_naam\n - alt_nr\n - rel_hoogte\n - st_lengthshape\n geometryType: MultiLineString\n blobKey: geopackages/rws/nwbwegen/410a6d1e-e767-41b4-ba8d-9e1e955dd013/1/nwb_wegen.gpkg\n table: wegvakken\n datasetMetadataIdentifier: a9b7026e-0a81-4813-93bd-ba49e6f28502\n keywords:\n - Vervoersnetwerken\n - Menselijke gezondheid en veiligheid\n - Geluidsbelasting hoofdwegen (Richtlijn Omgevingslawaai)\n - Nationaal\n - Voertuigen\n - Verkeer\n - Wegvakken\n maxScale: 50000.0\n minScale: 1.0\n name: wegvakken\n sourceMetadataIdentifier: 8f0497f0-dbd7-4bee-b85a-5fdec484a7ff\n styles:\n - name: wegvakken\n title: NWB - Wegvakken\n visualization: wegvakken.style\n title: Wegvakken\n visible: true\n - abstract:\n Deze laag bevat de hectopunten uit het Nationaal Wegen Bestand (NWB)\n en geeft gedetailleerde informatie per hectopunt zoals hectometrering, afstand,\n zijde en hectoletter weer.\n data:\n gpkg:\n columns:\n - objectid\n - hectomtrng\n - afstand\n - wvk_id\n - wvk_begdat\n - zijde\n - hecto_lttr\n geometryType: MultiPoint\n blobKey: geopackages/rws/nwbwegen/410a6d1e-e767-41b4-ba8d-9e1e955dd013/1/nwb_wegen.gpkg\n table: hectopunten\n datasetMetadataIdentifier: a9b7026e-0a81-4813-93bd-ba49e6f28502\n keywords:\n - Vervoersnetwerken\n - Menselijke gezondheid en veiligheid\n - Geluidsbelasting hoofdwegen (Richtlijn Omgevingslawaai)\n - Nationaal\n - Voertuigen\n - Verkeer\n - Hectometerpunten\n maxScale: 50000.0\n minScale: 1.0\n name: hectopunten\n sourceMetadataIdentifier: 8f0497f0-dbd7-4bee-b85a-5fdec484a7ff\n styles:\n - name: hectopunten\n title: NWB - Hectopunten\n visualization: hectopunten.style\n title: Hectopunten\n visible: true\n metadataIdentifier: f2437a92-ddd3-4777-a1bc-fdf4b4a7fcb8\n"
1213
var v2wms WMS
1314
err := yaml.Unmarshal([]byte(input), &v2wms)

api/v2beta1/wms_types.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,22 @@ type WMSSpec struct {
5454

5555
// WMSService is the struct for all service level fields
5656
type WMSService struct {
57-
Inspire bool `json:"inspire"`
58-
Title string `json:"title"`
59-
Abstract string `json:"abstract"`
60-
AccessConstraints string `json:"accessConstraints"`
61-
Keywords []string `json:"keywords"`
62-
MetadataIdentifier string `json:"metadataIdentifier"`
63-
Authority Authority `json:"authority"`
64-
Layers []WMSLayer `json:"layers"`
65-
DataEPSG string `json:"dataEPSG"`
66-
Extent *string `json:"extent,omitempty"`
67-
Maxsize *float64 `json:"maxSize,omitempty"`
68-
Resolution *int `json:"resolution,omitempty"`
69-
DefResolution *int `json:"defResolution,omitempty"`
70-
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
71-
Mapfile *Mapfile `json:"mapfile,omitempty"`
57+
Inspire bool `json:"inspire"`
58+
Title string `json:"title"`
59+
Abstract string `json:"abstract"`
60+
AccessConstraints string `json:"accessConstraints"`
61+
Keywords []string `json:"keywords"`
62+
MetadataIdentifier string `json:"metadataIdentifier"`
63+
Authority Authority `json:"authority"`
64+
Layers []WMSLayer `json:"layers"`
65+
//nolint:tagliatelle
66+
DataEPSG string `json:"dataEPSG"`
67+
Extent *string `json:"extent,omitempty"`
68+
Maxsize *float64 `json:"maxSize,omitempty"`
69+
Resolution *int `json:"resolution,omitempty"`
70+
DefResolution *int `json:"defResolution,omitempty"`
71+
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
72+
Mapfile *Mapfile `json:"mapfile,omitempty"`
7273
}
7374

7475
// WMSLayer is the struct for all layer level fields

api/v3/shared_types.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,11 @@ func SetHost(url string) {
125125
func GetHost(includeProtocol bool) string {
126126
if includeProtocol {
127127
return host
128-
} else {
129-
if strings.HasPrefix(host, "http") {
130-
return strings.Split(host, "://")[1]
131-
} else {
132-
return host
133-
}
128+
} else if strings.HasPrefix(host, "http") {
129+
return strings.Split(host, "://")[1]
134130
}
131+
132+
return host
135133
}
136134

137135
func GetBaseURLPath[T WMSWFS](o T) string {

api/v3/wms_types.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ type WMSService struct {
6565
OwnerInfoRef string `json:"ownerInfoRef"`
6666
Fees *string `json:"fees,omitempty"`
6767
// +kubebuilder:default="https://creativecommons.org/publicdomain/zero/1.0/deed.nl"
68-
AccessConstraints string `json:"accessConstraints"`
69-
MaxSize *int32 `json:"maxSize,omitempty"`
70-
Inspire *Inspire `json:"inspire,omitempty"`
71-
DataEPSG string `json:"dataEPSG"`
72-
Resolution *int32 `json:"resolution,omitempty"`
73-
DefResolution *int32 `json:"defResolution,omitempty"`
74-
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
75-
Mapfile *Mapfile `json:"mapfile,omitempty"`
76-
Layer Layer `json:"layer"`
68+
AccessConstraints string `json:"accessConstraints"`
69+
MaxSize *int32 `json:"maxSize,omitempty"`
70+
Inspire *Inspire `json:"inspire,omitempty"`
71+
//nolint:tagliatelle
72+
DataEPSG string `json:"dataEPSG"`
73+
Resolution *int32 `json:"resolution,omitempty"`
74+
DefResolution *int32 `json:"defResolution,omitempty"`
75+
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
76+
Mapfile *Mapfile `json:"mapfile,omitempty"`
77+
Layer Layer `json:"layer"`
7778
}
7879

7980
type StylingAssets struct {
@@ -178,7 +179,7 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {
178179

179180
allLayers := wmsService.GetAllLayers()
180181
for _, layer := range allLayers {
181-
if layer.BoundingBoxes != nil && len(layer.BoundingBoxes) > 0 {
182+
if len(layer.BoundingBoxes) > 0 {
182183
for _, bbox := range wmsService.Layer.BoundingBoxes {
183184
if boundingBox == nil {
184185
boundingBox = &bbox
@@ -191,18 +192,17 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {
191192

192193
if boundingBox != nil {
193194
return *boundingBox
194-
} else {
195-
return WMSBoundingBox{
196-
CRS: "EPSG:28992",
197-
BBox: shared_model.BBox{
198-
MinX: "-25000",
199-
MaxX: "280000",
200-
MinY: "250000",
201-
MaxY: "860000",
202-
},
203-
}
204195
}
205196

197+
return WMSBoundingBox{
198+
CRS: "EPSG:28992",
199+
BBox: shared_model.BBox{
200+
MinX: "-25000",
201+
MaxX: "280000",
202+
MinY: "250000",
203+
MaxY: "860000",
204+
},
205+
}
206206
}
207207

208208
type AnnotatedLayer struct {
@@ -281,11 +281,11 @@ func (layer *Layer) GetParent(candidateLayer *Layer) *Layer {
281281
for _, childLayer := range *candidateLayer.Layers {
282282
if childLayer.Name == layer.Name {
283283
return candidateLayer
284-
} else {
285-
parent := layer.GetParent(&childLayer)
286-
if parent != nil {
287-
return parent
288-
}
284+
}
285+
286+
parent := layer.GetParent(&childLayer)
287+
if parent != nil {
288+
return parent
289289
}
290290
}
291291
return nil

api/v3/wms_validation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func validateWMS(wms *WMS, warnings *[]string, reasons *[]string) {
106106
*reasons = append(*reasons, "layer.boundingBoxes must contain a boundingBox for CRS '"+service.DataEPSG+"' when service.dataEPSG is not 'EPSG:28992'")
107107
}
108108

109+
//nolint:nestif
109110
if !*layer.Visible {
110111
if layer.Title != nil {
111112
*warnings = append(*warnings, sharedValidation.FormatValidationWarning("layer.title is not used when layer.visible=false", wms.GroupVersionKind(), wms.GetName()))

cmd/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ const (
5656
defaultFeatureinfoGeneratorImage = "acrpdokprodman.azurecr.io/mirror/docker.io/pdok/featureinfo-generator:v1.4.0-beta1"
5757
defaultOgcWebserviceProxyImage = "acrpdokprodman.azurecr.io/pdok/ogc-webservice-proxy:0.1.8"
5858
defaultApacheExporterImage = "acrpdokprodman.azurecr.io/mirror/docker.io/lusotycoon/apache-exporter:v0.7.0"
59+
60+
EnvFalse = "false"
61+
EnvTrue = "true"
5962
)
6063

6164
var (
@@ -271,21 +274,21 @@ func main() {
271274
os.Exit(1)
272275
}
273276

274-
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
277+
if os.Getenv("ENABLE_WEBHOOKS") != EnvFalse {
275278
if err = webhookpdoknlv3.SetupWFSWebhookWithManager(mgr); err != nil {
276279
setupLog.Error(err, "unable to create webhook", "webhook", "WFS")
277280
os.Exit(1)
278281
}
279282
}
280283

281-
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
284+
if os.Getenv("ENABLE_WEBHOOKS") != EnvFalse {
282285
if err = webhookpdoknlv3.SetupWMSWebhookWithManager(mgr); err != nil {
283286
setupLog.Error(err, "unable to create webhook", "webhook", "WMS")
284287
os.Exit(1)
285288
}
286289
}
287290

288-
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
291+
if os.Getenv("ENABLE_WEBHOOKS") != EnvFalse {
289292
if err = webhookpdoknlv3.SetupWFSWebhookWithManager(mgr); err != nil {
290293
setupLog.Error(err, "unable to create webhook", "webhook", "WFS")
291294
os.Exit(1)

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: local-registry:5000/mapserver-operator
8-
newTag: v3.0.2
8+
newTag: v3.0.10

internal/controller/blobdownload/blob_download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func downloadStylingAssets(sb *strings.Builder, wms *pdoknlv3.WMS) error {
158158
return nil
159159
}
160160

161-
re := regexp.MustCompile(".*\\.(ttf)$")
161+
re := regexp.MustCompile(`.*\\.(ttf)$`)
162162
for _, blobKey := range wms.Spec.Service.StylingAssets.BlobKeys {
163163
fileName, err := getFilenameFromBlobKey(blobKey)
164164
if err != nil {

internal/controller/capabilitiesgenerator/capabilities_generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
corev1 "k8s.io/api/core/v1"
1111
)
1212

13-
func GetCapabilitiesGeneratorInitContainer[O pdoknlv3.WMSWFS](obj O, image string) (*corev1.Container, error) {
13+
func GetCapabilitiesGeneratorInitContainer[O pdoknlv3.WMSWFS](_ O, image string) (*corev1.Container, error) {
1414
initContainer := corev1.Container{
1515
Name: "capabilities-generator",
1616
Image: image,

0 commit comments

Comments
 (0)