From e11b48fe521ca1478374291df87988d07202a8a2 Mon Sep 17 00:00:00 2001 From: Dennis Marttinen Date: Sun, 31 Mar 2024 23:08:07 +0300 Subject: [PATCH] fix: correctly validate root credentials from secret --- pkg/sidecar/sidecar.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/sidecar/sidecar.go b/pkg/sidecar/sidecar.go index 2936ddd36ea..43c050a1cb6 100644 --- a/pkg/sidecar/sidecar.go +++ b/pkg/sidecar/sidecar.go @@ -151,23 +151,23 @@ func NewSideCarController(kubeClient *kubernetes.Clientset, controllerClient *cl } data := newSecret.Data["config.env"] // validate root creds in string - rootUserMissing := true - rootPassMissing := false + rootUserFound := false + rootPwdFound := false dataStr := string(data) - if !strings.Contains(dataStr, "MINIO_ROOT_USER") { - rootUserMissing = true + if strings.Contains(dataStr, "MINIO_ROOT_USER") { + rootUserFound = true } - if !strings.Contains(dataStr, "MINIO_ACCESS_KEY") { - rootUserMissing = true + if strings.Contains(dataStr, "MINIO_ACCESS_KEY") { + rootUserFound = true } - if !strings.Contains(dataStr, "MINIO_ROOT_PASSWORD") { - rootPassMissing = true + if strings.Contains(dataStr, "MINIO_ROOT_PASSWORD") { + rootPwdFound = true } - if !strings.Contains(dataStr, "MINIO_SECRET_KEY") { - rootPassMissing = true + if strings.Contains(dataStr, "MINIO_SECRET_KEY") { + rootPwdFound = true } - if rootUserMissing || rootPassMissing { + if !rootUserFound || !rootPwdFound { log.Println("Missing root credentials in the configuration.") log.Println("MinIO won't start") os.Exit(1)