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,36 +560,37 @@ 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 {
|
||||||
adminRequest := &adm.UpdateEmailProviderSMTPRequest{
|
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 {
|
||||||
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
adminRequest := &adm.UpdateEmailProviderSMTPRequest{
|
||||||
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
||||||
Tls: zitadel.Spec.SMTPConfig.TLS,
|
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
||||||
Host: zitadel.Spec.SMTPConfig.Host,
|
Tls: zitadel.Spec.SMTPConfig.TLS,
|
||||||
Id: resp.Config.Id,
|
Host: zitadel.Spec.SMTPConfig.Host,
|
||||||
Password: "test",
|
Id: resp.Config.Id,
|
||||||
Description: "autogenerated by k8s-operator",
|
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
|
|
||||||
}
|
}
|
||||||
adminRequest.Password = passwordSecret
|
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
||||||
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 {
|
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
||||||
if !strings.Contains(err.Error(), "No changes") {
|
if err != nil {
|
||||||
return ctrl.Result{}, fmt.Errorf("Could not update SMTP config: %v", err)
|
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())
|
// 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