11package v2beta1
22
33import (
4- "fmt "
4+ "net/url "
55
66 pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
77 "github.com/pdok/mapserver-operator/internal/controller/constants"
@@ -80,7 +80,7 @@ func ConvertAutoscaling(src Autoscaling) *pdoknlv3.HorizontalPodAutoscalerPatch
8080 }
8181}
8282
83- func ConvertResources (src corev1.ResourceRequirements ) * corev1.PodSpec {
83+ func ConvertResources (src corev1.ResourceRequirements ) corev1.PodSpec {
8484 targetResources := src
8585
8686 if src .Requests != nil {
@@ -92,7 +92,7 @@ func ConvertResources(src corev1.ResourceRequirements) *corev1.PodSpec {
9292 delete (targetResources .Limits , "ephemeralStorage" )
9393 }
9494
95- return & corev1.PodSpec {
95+ return corev1.PodSpec {
9696 Containers : []corev1.Container {
9797 {
9898 Name : constants .MapserverName ,
@@ -209,7 +209,7 @@ func ConvertV3DataToV2(v3 pdoknlv3.Data) Data {
209209 return v2
210210}
211211
212- func NewV2KubernetesObject (lifecycle * smoothoperatormodel.Lifecycle , podSpecPatch * corev1.PodSpec , scalingSpec * pdoknlv3.HorizontalPodAutoscalerPatch ) Kubernetes {
212+ func NewV2KubernetesObject (lifecycle * smoothoperatormodel.Lifecycle , podSpecPatch corev1.PodSpec , scalingSpec * pdoknlv3.HorizontalPodAutoscalerPatch ) Kubernetes {
213213 kub := Kubernetes {}
214214
215215 if lifecycle != nil && lifecycle .TTLInDays != nil {
@@ -218,9 +218,7 @@ func NewV2KubernetesObject(lifecycle *smoothoperatormodel.Lifecycle, podSpecPatc
218218 }
219219 }
220220
221- if podSpecPatch != nil {
222- kub .Resources = & podSpecPatch .Containers [0 ].Resources
223- }
221+ kub .Resources = & podSpecPatch .Containers [0 ].Resources
224222
225223 if scalingSpec != nil {
226224 kub .Autoscaling = & Autoscaling {
@@ -259,16 +257,20 @@ func LabelsToV2General(labels map[string]string) General {
259257 return general
260258}
261259
262- func CreateBaseURL (host string , kind string , general General ) string {
263- URI := fmt .Sprintf ("%s/%s" , general .DatasetOwner , general .Dataset )
260+ func CreateBaseURL (host string , kind string , general General ) (* smoothoperatormodel.URL , error ) {
261+ baseURL , err := url .Parse (host + "/" )
262+ if err != nil {
263+ return nil , err
264+ }
265+ baseURL = baseURL .JoinPath (general .DatasetOwner , general .Dataset )
264266 if general .Theme != nil {
265- URI += "/" + * general .Theme
267+ baseURL = baseURL . JoinPath ( * general .Theme )
266268 }
267- URI += "/" + kind
269+ baseURL = baseURL . JoinPath ( kind )
268270
269271 if general .ServiceVersion != nil {
270- URI += "/" + * general .ServiceVersion
272+ baseURL = baseURL . JoinPath ( * general .ServiceVersion )
271273 }
272274
273- return fmt . Sprintf ( "%s/%s" , host , URI )
275+ return & smoothoperatormodel. URL { URL : baseURL }, nil
274276}
0 commit comments