Skip to content

Commit 056df03

Browse files
committed
Add structs for v3 WMS
1 parent 27634f3 commit 056df03

File tree

5 files changed

+187
-80
lines changed

5 files changed

+187
-80
lines changed

api/v3/shared_types.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package v3
22

3+
import corev1 "k8s.io/api/core/v1"
4+
5+
type Mapfile struct {
6+
ConfigMapKeyRef corev1.ConfigMapKeySelector `json:"configMapKeyRef"`
7+
}
8+
39
type Options struct {
4-
AutomaticCasing bool `json:"automaticCasing"`
5-
PrefetchData bool `json:"prefetchData"`
6-
IncludeIngress bool `json:"includeIngress"`
10+
AutomaticCasing bool `json:"automaticCasing"`
11+
PrefetchData bool `json:"prefetchData"`
12+
IncludeIngress bool `json:"includeIngress"`
13+
DisableWebserviceProxy bool `json:"disableWebserviceProxy"`
14+
RewriteGroupToDataLayers bool `json:"rewriteGroupToDataLayers"`
715
}
816

917
type Inspire struct {
@@ -29,6 +37,7 @@ type Custom struct {
2937
type Data struct {
3038
Gpkg *Gpkg `json:"gpkg,omitempty"`
3139
Postgis *Postgis `json:"postgis,omitempty"`
40+
TIF *TIF `json:"tif,omitempty"`
3241
}
3342

3443
type Gpkg struct {
@@ -45,6 +54,13 @@ type Postgis struct {
4554
Columns []Columns `json:"columns"`
4655
}
4756

57+
type TIF struct {
58+
BlobKey string `json:"blobKey"`
59+
Resample string `json:"resample"`
60+
Offsite string `json:"offsite"`
61+
GetFeatureInfoIncludesClass bool `json:"getFeatureInfoIncludesClass"`
62+
}
63+
4864
type Columns struct {
4965
Name string `json:"name"`
5066
Alias *string `json:"alias,omitempty"`

api/v3/wfs_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ type Service struct {
9696
FeatureTypes []FeatureType `json:"featureTypes"`
9797
}
9898

99-
type Mapfile struct {
100-
ConfigMapKeyRef corev1.ConfigMapKeySelector `json:"configMapKeyRef"`
101-
}
102-
10399
type Bbox struct {
104100
// EXTENT/wfs_extent in mapfile
105101
//nolint:tagliatelle

api/v3/wms_types.go

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,94 @@ SOFTWARE.
2525
package v3
2626

2727
import (
28+
shared_model "github.com/pdok/smooth-operator/model"
29+
autoscalingv2 "k8s.io/api/autoscaling/v2beta1"
30+
corev1 "k8s.io/api/core/v1"
2831
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32+
"maps"
33+
"slices"
2934
)
3035

3136
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
3237
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
3338

3439
// WMSSpec defines the desired state of WMS.
3540
type WMSSpec struct {
36-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
37-
// Important: Run "make" to regenerate code after modifying this file
41+
Lifecycle *shared_model.Lifecycle `json:"lifecycle"`
42+
43+
// +kubebuilder:validation:Type=object
44+
// +kubebuilder:validation:Schemaless
45+
// +kubebuilder:pruning:PreserveUnknownFields
46+
// Optional strategic merge patch for the pod in the deployment. E.g. to patch the resources or add extra env vars.
47+
PodSpecPatch *corev1.PodSpec `json:"podSpecPatch,omitempty"`
48+
HorizontalPodAutoscalerPatch *autoscalingv2.HorizontalPodAutoscalerSpec `json:"horizontalPodAutoscalerPatch"`
49+
Options *Options `json:"options"`
50+
Service WMSService `json:"service"`
51+
}
52+
53+
type WMSService struct {
54+
BaseURL string `json:"baseUrl"`
55+
Title string `json:"title"`
56+
Abstract string `json:"abstract"`
57+
Keywords []string `json:"keywords"`
58+
OwnerInfoRef string `json:"ownerInfoRef"`
59+
Fees *string `json:"fees"`
60+
AccessConstraints string `json:"accessConstraints"`
61+
MaxSize int32 `json:"maxSize"`
62+
Inspire *Inspire `json:"inspire,omitempty"`
63+
DataEPSG string `json:"dataEPSG"`
64+
Resolution float32 `json:"resolution"`
65+
DefResolution float32 `json:"defResolution"`
66+
StylingAssets StylingAssets `json:"stylingAssets"`
67+
Mapfile *Mapfile `json:"mapfile"`
68+
Layer Layer `json:"layer"`
69+
}
70+
71+
type StylingAssets struct {
72+
BlobKeys []string `json:"blobKeys"`
73+
ConfigMapRefs []corev1.ConfigMapKeySelector `json:"configMapRefs"`
74+
}
75+
76+
type Layer struct {
77+
Name string `json:"name"`
78+
Title string `json:"title"`
79+
Abstract string `json:"abstract"`
80+
Keywords []string `json:"keywords"`
81+
BoundingBoxes []WMSBoundingBox `json:"boundingBoxes"`
82+
Authority Authority `json:"authority"`
83+
DatasetMetadataURL MetadataURL `json:"datasetMetadataUrl"`
84+
MinScaleDenominator float32 `json:"minscaledenominator"`
85+
MaxScaleDenominator float32 `json:"maxscaledenominator"`
86+
Style Style `json:"style"`
87+
LabelNoClip bool `json:"labelNoClip"`
88+
Data Data `json:"data"`
89+
Layers []Layer `json:"layers"`
90+
}
3891

39-
// Foo is an example field of WMS. Edit wms_types.go to remove/update
40-
Foo string `json:"foo,omitempty"`
92+
type WMSBoundingBox struct {
93+
CRS string `json:"crs"`
94+
BBox shared_model.BBox `json:"bbox"`
95+
}
96+
97+
type Authority struct {
98+
Name string `json:"name"`
99+
URL string `json:"url"`
100+
SpatialDatasetIdentifier string `json:"spatialDatasetIdentifier"`
101+
}
102+
103+
type Style struct {
104+
Name string `json:"name"`
105+
Title string `json:"title"`
106+
Abstract string `json:"abstract"`
107+
Visualization string `json:"visualization"`
108+
Legend Legend `json:"legend"`
109+
}
110+
111+
type Legend struct {
112+
Width int32 `json:"width"`
113+
Height int32 `json:"height"`
114+
Format string `json:"format"`
115+
BlobKey string `json:"blobKey"`
41116
}
42117

43118
// WMSStatus defines the observed state of WMS.
@@ -59,8 +134,8 @@ type WMS struct {
59134
metav1.TypeMeta `json:",inline"`
60135
metav1.ObjectMeta `json:"metadata,omitempty"`
61136

62-
Spec WMSSpec `json:"spec,omitempty"`
63-
Status WMSStatus `json:"status,omitempty"`
137+
Spec WMSSpec `json:"spec,omitempty"`
138+
Status shared_model.OperatorStatus `json:"status,omitempty"`
64139
}
65140

66141
// +kubebuilder:object:root=true
@@ -75,3 +150,20 @@ type WMSList struct {
75150
func init() {
76151
SchemeBuilder.Register(&WMS{}, &WMSList{})
77152
}
153+
154+
func (wms *WMS) GetUniqueTiffBlobKeys() []string {
155+
blobKeys := map[string]bool{}
156+
157+
if wms.Spec.Service.Layer.Data.TIF != nil && wms.Spec.Service.Layer.Data.TIF.BlobKey != "" {
158+
blobKeys[wms.Spec.Service.Layer.Data.TIF.BlobKey] = true
159+
}
160+
161+
if len(wms.Spec.Service.Layer.Layers) > 0 {
162+
for _, layer := range wms.Spec.Service.Layer.Layers {
163+
if layer.Data.TIF != nil && layer.Data.TIF.BlobKey != "" {
164+
blobKeys[layer.Data.TIF.BlobKey] = true
165+
}
166+
}
167+
}
168+
return slices.Collect(maps.Keys(blobKeys))
169+
}

go.mod

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ go 1.23.0
44

55
godebug default=go1.23
66

7-
replace github.com/pdok/smooth-operator => ../smooth-operator
8-
97
require (
8+
github.com/cbroglie/mustache v1.4.0
109
github.com/onsi/ginkgo/v2 v2.21.0
1110
github.com/onsi/gomega v1.35.1
12-
github.com/pdok/smooth-operator v1.0.0
11+
github.com/pdok/smooth-operator v0.0.2-0.20250311150606-315e84363ede
1312
k8s.io/api v0.32.0
1413
k8s.io/apimachinery v0.32.0
1514
k8s.io/client-go v0.32.0
@@ -28,7 +27,7 @@ require (
2827
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
2928
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
3029
github.com/felixge/httpsnoop v1.0.4 // indirect
31-
github.com/fsnotify/fsnotify v1.7.0 // indirect
30+
github.com/fsnotify/fsnotify v1.8.0 // indirect
3231
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
3332
github.com/go-logr/logr v1.4.2 // indirect
3433
github.com/go-logr/stdr v1.2.2 // indirect
@@ -41,7 +40,7 @@ require (
4140
github.com/golang/protobuf v1.5.4 // indirect
4241
github.com/google/btree v1.1.3 // indirect
4342
github.com/google/cel-go v0.22.0 // indirect
44-
github.com/google/gnostic-models v0.6.8 // indirect
43+
github.com/google/gnostic-models v0.6.9 // indirect
4544
github.com/google/go-cmp v0.6.0 // indirect
4645
github.com/google/gofuzz v1.2.0 // indirect
4746
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
@@ -63,38 +62,38 @@ require (
6362
github.com/spf13/pflag v1.0.5 // indirect
6463
github.com/stoewer/go-strcase v1.3.0 // indirect
6564
github.com/x448/float16 v0.8.4 // indirect
66-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
67-
go.opentelemetry.io/otel v1.28.0 // indirect
65+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
66+
go.opentelemetry.io/otel v1.29.0 // indirect
6867
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
6968
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
70-
go.opentelemetry.io/otel/metric v1.28.0 // indirect
69+
go.opentelemetry.io/otel/metric v1.29.0 // indirect
7170
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
72-
go.opentelemetry.io/otel/trace v1.28.0 // indirect
71+
go.opentelemetry.io/otel/trace v1.29.0 // indirect
7372
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
7473
go.uber.org/multierr v1.11.0 // indirect
7574
go.uber.org/zap v1.27.0 // indirect
76-
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
77-
golang.org/x/net v0.30.0 // indirect
78-
golang.org/x/oauth2 v0.23.0 // indirect
79-
golang.org/x/sync v0.8.0 // indirect
80-
golang.org/x/sys v0.26.0 // indirect
81-
golang.org/x/term v0.25.0 // indirect
82-
golang.org/x/text v0.19.0 // indirect
83-
golang.org/x/time v0.7.0 // indirect
84-
golang.org/x/tools v0.26.0 // indirect
75+
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
76+
golang.org/x/net v0.33.0 // indirect
77+
golang.org/x/oauth2 v0.24.0 // indirect
78+
golang.org/x/sync v0.10.0 // indirect
79+
golang.org/x/sys v0.28.0 // indirect
80+
golang.org/x/term v0.27.0 // indirect
81+
golang.org/x/text v0.21.0 // indirect
82+
golang.org/x/time v0.8.0 // indirect
83+
golang.org/x/tools v0.28.0 // indirect
8584
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
86-
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
87-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect
88-
google.golang.org/grpc v1.65.0 // indirect
89-
google.golang.org/protobuf v1.35.1 // indirect
85+
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect
86+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
87+
google.golang.org/grpc v1.67.1 // indirect
88+
google.golang.org/protobuf v1.35.2 // indirect
9089
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9190
gopkg.in/inf.v0 v0.9.1 // indirect
9291
gopkg.in/yaml.v3 v3.0.1 // indirect
9392
k8s.io/apiextensions-apiserver v0.32.0 // indirect
9493
k8s.io/apiserver v0.32.0 // indirect
9594
k8s.io/component-base v0.32.0 // indirect
9695
k8s.io/klog/v2 v2.130.1 // indirect
97-
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
96+
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect
9897
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
9998
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect
10099
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect

0 commit comments

Comments
 (0)