refactor: ingress is optional

This commit is contained in:
Dario Tranchitella
2022-08-22 17:46:33 +02:00
parent 08022fc780
commit 47fc9fdc63
2 changed files with 6 additions and 6 deletions

View File

@@ -30,7 +30,7 @@ func (r *KubernetesIngressResource) ShouldStatusBeUpdated(ctx context.Context, t
}
func (r *KubernetesIngressResource) ShouldCleanup(tenantControlPlane *kamajiv1alpha1.TenantControlPlane) bool {
return !tenantControlPlane.Spec.ControlPlane.Ingress.Enabled
return tenantControlPlane.Spec.ControlPlane.Ingress == nil
}
func (r *KubernetesIngressResource) CleanUp(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (bool, error) {
@@ -46,7 +46,7 @@ func (r *KubernetesIngressResource) CleanUp(ctx context.Context, tenantControlPl
}
func (r *KubernetesIngressResource) UpdateTenantControlPlaneStatus(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
if tenantControlPlane.Spec.ControlPlane.Ingress.Enabled {
if tenantControlPlane.Spec.ControlPlane.Ingress != nil {
tenantControlPlane.Status.Kubernetes.Ingress.IngressStatus = r.resource.Status
tenantControlPlane.Status.Kubernetes.Ingress.Name = r.resource.GetName()
tenantControlPlane.Status.Kubernetes.Ingress.Namespace = r.resource.GetNamespace()
@@ -54,7 +54,7 @@ func (r *KubernetesIngressResource) UpdateTenantControlPlaneStatus(ctx context.C
return nil
}
tenantControlPlane.Status.Kubernetes.Ingress = kamajiv1alpha1.KubernetesIngressStatus{}
tenantControlPlane.Status.Kubernetes.Ingress = &kamajiv1alpha1.KubernetesIngressStatus{}
return nil
}

View File

@@ -70,9 +70,9 @@ func (r *KubeadmConfigResource) UpdateTenantControlPlaneStatus(ctx context.Conte
return nil
}
func (r *KubeadmConfigResource) getControlPlaneEndpoint(ingress kamajiv1alpha1.IngressSpec, address string, port int32) string {
if hostname := ingress.Hostname; len(hostname) > 0 {
return hostname
func (r *KubeadmConfigResource) getControlPlaneEndpoint(ingress *kamajiv1alpha1.IngressSpec, address string, port int32) string {
if ingress != nil && len(ingress.Hostname) > 0 {
return ingress.Hostname
}
return fmt.Sprintf("%s:%d", address, port)