Skip to content

Commit

Permalink
Merge pull request #110 from Kshatrix/validation
Browse files Browse the repository at this point in the history
Allow only deployment template types in Deployments
  • Loading branch information
Kshatrix authored Jul 23, 2024
2 parents e51064e + c30c8cd commit bbe5bc2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/controller/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit bbe5bc2

Please sign in to comment.