From 820f283ddcad1296b1059ab3baa85cb5aef34b6d Mon Sep 17 00:00:00 2001 From: iyuroch Date: Sun, 10 Apr 2022 20:50:51 +0300 Subject: [PATCH] Revert "add required user and pass" This reverts commit 351f238e6c4eb2a559c7a308eb8e4a472f88de64. --- controllers/factory/alertmanager/config.go | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/controllers/factory/alertmanager/config.go b/controllers/factory/alertmanager/config.go index dac9ca8f..0aa84f53 100644 --- a/controllers/factory/alertmanager/config.go +++ b/controllers/factory/alertmanager/config.go @@ -744,22 +744,27 @@ func (cb *configBuilder) buildHTTPConfig(httpCfg *operatorv1beta1.HTTPConfig) (y func (cb *configBuilder) buildBasicAuth(basicAuth *operatorv1beta1.BasicAuth) (yaml.MapSlice, error) { var r yaml.MapSlice - u, err := cb.fetchSecretValue(&basicAuth.Username) - if err != nil { - return nil, err - } - r = append(r, yaml.MapItem{ - Key: "username", - Value: string(u), - }) - p, err := cb.fetchSecretValue(&basicAuth.Password) - if err != nil { - return nil, err - } - r = append(r, yaml.MapItem{ - Key: "password", - Value: string(p), - }) + + if basicAuth.Username != nil { + u, err := cb.fetchSecretValue(&basicAuth.Username) + if err != nil { + return nil, err + } + r = append(r, yaml.MapItem{ + Key: "username", + Value: string(u), + }) + } + if basicAuth.Password != nil { + p, err := cb.fetchSecretValue(&basicAuth.Password) + if err != nil { + return nil, err + } + r = append(r, yaml.MapItem{ + Key: "password", + Value: string(p), + }) + } if len(basicAuth.PasswordFile) > 0 { r = append(r, yaml.MapItem{ Key: "password_file",