diff --git a/api/v1alpha1/ionoscloudcluster_types.go b/api/v1alpha1/ionoscloudcluster_types.go index 7c9e524..dfad53b 100644 --- a/api/v1alpha1/ionoscloudcluster_types.go +++ b/api/v1alpha1/ionoscloudcluster_types.go @@ -103,6 +103,8 @@ type IONOSCloudClusterSpec struct { // +optional ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` // +optional + // +listType=map + // +listMapKey=name Lans []IONOSLanSpec `json:"lans,omitempty"` // +optional LoadBalancer *IONOSLoadBalancerSpec `json:"loadBalancer,omitempty"` @@ -190,7 +192,11 @@ func (c *IONOSCloudCluster) LanBy(id *int32) *IONOSLanSpec { return nil } for i := range c.Spec.Lans { - if *c.Spec.Lans[i].LanID == *id { + lan := &c.Spec.Lans[i] + if lan.LanID == nil { + continue + } + if *lan.LanID == *id { return &c.Spec.Lans[i] } } @@ -203,7 +209,8 @@ func (c *IONOSCloudCluster) EnsureLan(spec IONOSLanSpec) { } for i := range c.Spec.Lans { if c.Spec.Lans[i].Name == spec.Name { - c.Spec.Lans[i] = spec + c.Spec.Lans[i].LanID = spec.LanID + c.Spec.Lans[i].Public = spec.Public return } } diff --git a/api/v1alpha1/ionoscloudmachine_types.go b/api/v1alpha1/ionoscloudmachine_types.go index c3cfbad..f7260cf 100644 --- a/api/v1alpha1/ionoscloudmachine_types.go +++ b/api/v1alpha1/ionoscloudmachine_types.go @@ -131,7 +131,8 @@ func (c *IONOSCloudMachine) EnsureNic(spec IONOSNicSpec) { } for i := range c.Spec.Nics { if c.Spec.Nics[i].LanRef.Name == spec.LanRef.Name { - c.Spec.Nics[i] = spec + c.Spec.Nics[i].PrimaryIP = spec.PrimaryIP + c.Spec.Nics[i].LanRef = spec.LanRef return } } diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ionoscloudclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ionoscloudclusters.yaml index 2bd16ec..8ae8b5b 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ionoscloudclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ionoscloudclusters.yaml @@ -77,6 +77,9 @@ spec: - public type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map loadBalancer: properties: id: