@@ -25,19 +25,94 @@ SOFTWARE.
2525package v3
2626
2727import (
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.
3540type 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 {
75150func 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+ }
0 commit comments