Update smtp config api
[ZITADOPER-1]
This commit is contained in:
@@ -457,22 +457,23 @@ 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if resp != nil {
|
|
||||||
|
if resp != nil && resp.SmtpConfig != nil {
|
||||||
adminRequest := &adm.UpdateSMTPConfigRequest{
|
adminRequest := &adm.UpdateSMTPConfigRequest{
|
||||||
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
||||||
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
||||||
Tls: zitadel.Spec.SMTPConfig.TLS,
|
Tls: zitadel.Spec.SMTPConfig.TLS,
|
||||||
Host: zitadel.Spec.SMTPConfig.Host,
|
Host: zitadel.Spec.SMTPConfig.Host,
|
||||||
Id: resp.SmtpConfig.Id,
|
Id: resp.SmtpConfig.Id,
|
||||||
|
Description: "autogenerated by k8s-operator",
|
||||||
}
|
}
|
||||||
var password *string
|
|
||||||
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
||||||
|
|
||||||
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
}
|
}
|
||||||
password = &passwordSecret
|
adminRequest.Password = passwordSecret
|
||||||
adminRequest.User = *zitadel.Spec.SMTPConfig.User
|
adminRequest.User = *zitadel.Spec.SMTPConfig.User
|
||||||
}
|
}
|
||||||
if zitadel.Spec.SMTPConfig.ReplyToAddress != nil {
|
if zitadel.Spec.SMTPConfig.ReplyToAddress != nil {
|
||||||
@@ -485,21 +486,13 @@ func (r *ZitadelClusterReconciler) reconcileSMTPConfig(ctx context.Context, zita
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
smtpId = resp.SmtpConfig.Id
|
smtpId = resp.SmtpConfig.Id
|
||||||
if password != nil {
|
|
||||||
if _, err = adminClient.UpdateSMTPConfigPassword(ctx, &adm.UpdateSMTPConfigPasswordRequest{
|
|
||||||
Password: *password,
|
|
||||||
}); err != nil {
|
|
||||||
if !strings.Contains(err.Error(), "No changes") {
|
|
||||||
return ctrl.Result{}, fmt.Errorf("Could not update SMTP config: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
adminRequest := &adm.AddSMTPConfigRequest{
|
adminRequest := &adm.AddSMTPConfigRequest{
|
||||||
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
SenderAddress: zitadel.Spec.SMTPConfig.SenderAddress,
|
||||||
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
SenderName: zitadel.Spec.SMTPConfig.SenderName,
|
||||||
Tls: zitadel.Spec.SMTPConfig.TLS,
|
Tls: zitadel.Spec.SMTPConfig.TLS,
|
||||||
Host: zitadel.Spec.SMTPConfig.Host,
|
Host: zitadel.Spec.SMTPConfig.Host,
|
||||||
|
Description: "autogenerated by k8s-operator",
|
||||||
}
|
}
|
||||||
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
if zitadel.Spec.SMTPConfig.User != nil && zitadel.Spec.SMTPConfig.Password != nil {
|
||||||
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
passwordSecret, err := r.RefResolver.SecretKeyRef(ctx, zitadel.Spec.SMTPConfig.Password.SecretKeyRef, zitadel.Namespace)
|
||||||
|
|||||||
Reference in New Issue
Block a user