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
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// TODO: Reload on config changed
|
||||
key := client.ObjectKeyFromObject(zitadel)
|
||||
@@ -580,36 +560,37 @@ func (r *ZitadelClusterReconciler) reconcileSMTPConfig(ctx context.Context, zita
|
||||
return ctrl.Result{}, fmt.Errorf("Error getting SMTP config: %v", err)
|
||||
}
|
||||
} else {
|
||||
adminRequest := &adm.UpdateEmailProviderSMTPRequest{
|
||||
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
||||
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
||||
Tls: zitadel.Spec.SMTPConfig.TLS,
|
||||
Host: zitadel.Spec.SMTPConfig.Host,
|
||||
Id: resp.Config.Id,
|
||||
Password: "test",
|
||||
Description: "autogenerated by k8s-operator",
|
||||
}
|
||||
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
||||
|
||||
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
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{
|
||||
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
||||
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
||||
Tls: zitadel.Spec.SMTPConfig.TLS,
|
||||
Host: zitadel.Spec.SMTPConfig.Host,
|
||||
Id: resp.Config.Id,
|
||||
Password: "test",
|
||||
Description: "autogenerated by k8s-operator",
|
||||
}
|
||||
adminRequest.Password = passwordSecret
|
||||
adminRequest.User = *zitadel.Spec.SMTPConfig.User
|
||||
}
|
||||
if zitadel.Spec.SMTPConfig.ReplyToAddress != nil {
|
||||
adminRequest.ReplyToAddress = *zitadel.Spec.SMTPConfig.ReplyToAddress
|
||||
}
|
||||
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
||||
|
||||
if _, err = adminClient.UpdateEmailProviderSMTP(ctx, adminRequest); err != nil {
|
||||
if !strings.Contains(err.Error(), "No changes") {
|
||||
return ctrl.Result{}, fmt.Errorf("Could not update SMTP config: %v", err)
|
||||
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
adminRequest.Password = passwordSecret
|
||||
adminRequest.User = *zitadel.Spec.SMTPConfig.User
|
||||
}
|
||||
if zitadel.Spec.SMTPConfig.ReplyToAddress != nil {
|
||||
adminRequest.ReplyToAddress = *zitadel.Spec.SMTPConfig.ReplyToAddress
|
||||
}
|
||||
if _, err = adminClient.UpdateEmailProviderSMTP(ctx, adminRequest); err != nil {
|
||||
if !strings.Contains(err.Error(), "No changes") {
|
||||
return ctrl.Result{}, fmt.Errorf("Could not update SMTP config: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
patch := client.MergeFrom(zitadel.DeepCopy())
|
||||
return ctrl.Result{}, r.Status().Patch(ctx, zitadel, patch)
|
||||
// patch := client.MergeFrom(zitadel.DeepCopy())
|
||||
// return ctrl.Result{}, r.Status().Patch(ctx, zitadel, patch)
|
||||
}
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user