From 05ce11c14a4de64962649643db9cbf5be54e05aa Mon Sep 17 00:00:00 2001 From: Johann Wagner Date: Fri, 12 Jul 2024 11:16:16 +0200 Subject: [PATCH] fix(controller): fix check for existing control plane endpoints in clusters --- controllers/kamajicontrolplane_controller_cluster_patch.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/controllers/kamajicontrolplane_controller_cluster_patch.go b/controllers/kamajicontrolplane_controller_cluster_patch.go index 7341a26..3f3415a 100644 --- a/controllers/kamajicontrolplane_controller_cluster_patch.go +++ b/controllers/kamajicontrolplane_controller_cluster_patch.go @@ -131,7 +131,12 @@ func (r *KamajiControlPlaneReconciler) checkGenericCluster(ctx context.Context, return errors.Wrap(err, fmt.Sprintf("cannot retrieve the %s resource", gkc.GetKind())) } - controlPlaneEndpoint := gkc.Object["spec"].(map[string]interface{})["controlPlaneEndpoint"].(map[string]interface{}) //nolint:forcetypeassert + controlPlaneEndpointUn := gkc.Object["spec"].(map[string]interface{})["controlPlaneEndpoint"] //nolint:forcetypeassert + if controlPlaneEndpointUn == nil { + return *NewUnmanagedControlPlaneAddressError(gkc.GetKind()) + } + + controlPlaneEndpoint := controlPlaneEndpointUn.(map[string]interface{}) //nolint:forcetypeassert cpHost, cpPort := controlPlaneEndpoint["host"].(string), controlPlaneEndpoint["port"].(int64) //nolint:forcetypeassert