only update smtp if there is change
[ZITADOPER-7]
This commit is contained in:
@@ -362,26 +362,6 @@ func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitade
|
|||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (r *ZitadelClusterReconciler) scaleDownDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) error {
|
|
||||||
// // scale down deployment first
|
|
||||||
// deploymentKey := client.ObjectKeyFromObject(zitadel)
|
|
||||||
// var existingDep appsv1.Deployment
|
|
||||||
// err := r.Get(ctx, deploymentKey, &existingDep)
|
|
||||||
// if err != nil {
|
|
||||||
// if errors.IsNotFound(err) {
|
|
||||||
// } else {
|
|
||||||
// return fmt.Errorf("error getting Deployment: %v", err)
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// patch := client.MergeFrom(existingDep.DeepCopy())
|
|
||||||
// existingDep.Spec.Replicas = ptr.To(int32(0))
|
|
||||||
// if err := r.Patch(ctx, &existingDep, patch); err != nil {
|
|
||||||
// return fmt.Errorf("Error scaling down deployment: %v", err)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (r *ZitadelClusterReconciler) reconcileDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) (ctrl.Result, error) {
|
func (r *ZitadelClusterReconciler) reconcileDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) (ctrl.Result, error) {
|
||||||
// TODO: Reload on config changed
|
// TODO: Reload on config changed
|
||||||
key := client.ObjectKeyFromObject(zitadel)
|
key := client.ObjectKeyFromObject(zitadel)
|
||||||
@@ -580,6 +560,7 @@ func (r *ZitadelClusterReconciler) reconcileSMTPConfig(ctx context.Context, zita
|
|||||||
return ctrl.Result{}, fmt.Errorf("Error getting SMTP config: %v", err)
|
return ctrl.Result{}, fmt.Errorf("Error getting SMTP config: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if zitadel.Spec.SMTPConfig.SenderAddress != resp.Config.GetSmtp().GetSenderAddress() || zitadel.Spec.SMTPConfig.SenderName != resp.Config.GetSmtp().SenderName || zitadel.Spec.SMTPConfig.TLS != resp.Config.GetSmtp().Tls || zitadel.Spec.SMTPConfig.Host != resp.Config.GetSmtp().Host {
|
||||||
adminRequest := &adm.UpdateEmailProviderSMTPRequest{
|
adminRequest := &adm.UpdateEmailProviderSMTPRequest{
|
||||||
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
||||||
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
||||||
@@ -601,15 +582,15 @@ func (r *ZitadelClusterReconciler) reconcileSMTPConfig(ctx context.Context, zita
|
|||||||
if zitadel.Spec.SMTPConfig.ReplyToAddress != nil {
|
if zitadel.Spec.SMTPConfig.ReplyToAddress != nil {
|
||||||
adminRequest.ReplyToAddress = *zitadel.Spec.SMTPConfig.ReplyToAddress
|
adminRequest.ReplyToAddress = *zitadel.Spec.SMTPConfig.ReplyToAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = adminClient.UpdateEmailProviderSMTP(ctx, adminRequest); err != nil {
|
if _, err = adminClient.UpdateEmailProviderSMTP(ctx, adminRequest); err != nil {
|
||||||
if !strings.Contains(err.Error(), "No changes") {
|
if !strings.Contains(err.Error(), "No changes") {
|
||||||
return ctrl.Result{}, fmt.Errorf("Could not update SMTP config: %v", err)
|
return ctrl.Result{}, fmt.Errorf("Could not update SMTP config: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
patch := client.MergeFrom(zitadel.DeepCopy())
|
// patch := client.MergeFrom(zitadel.DeepCopy())
|
||||||
return ctrl.Result{}, r.Status().Patch(ctx, zitadel, patch)
|
// return ctrl.Result{}, r.Status().Patch(ctx, zitadel, patch)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user