From c30c8cd0ba5977a7271ab2fdd1b178d9c9d92fe8 Mon Sep 17 00:00:00 2001 From: Andrei Pavlov Date: Tue, 23 Jul 2024 20:40:01 +0700 Subject: [PATCH] Allow only deployment template types in Deployments Signed-off-by: Andrei Pavlov --- internal/controller/deployment_controller.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/controller/deployment_controller.go b/internal/controller/deployment_controller.go index da3c1c13a..e8de54df5 100644 --- a/internal/controller/deployment_controller.go +++ b/internal/controller/deployment_controller.go @@ -126,6 +126,17 @@ func (r *DeploymentReconciler) Update(ctx context.Context, l logr.Logger, deploy }) return ctrl.Result{}, err } + templateType := template.Status.Type + if templateType != hmc.TemplateTypeDeployment { + errMsg := "only templates of 'deployment' type are supported" + apimeta.SetStatusCondition(deployment.GetConditions(), metav1.Condition{ + Type: hmc.TemplateReadyCondition, + Status: metav1.ConditionFalse, + Reason: hmc.FailedReason, + Message: errMsg, + }) + return ctrl.Result{}, fmt.Errorf(errMsg) + } if !template.Status.Valid { errMsg := "provided template is not marked as valid" apimeta.SetStatusCondition(deployment.GetConditions(), metav1.Condition{