diff --git a/internal/controller/operator/factory/k8stools/secret_content.go b/internal/controller/operator/factory/k8stools/secret_content.go index 79355abf..06907a95 100644 --- a/internal/controller/operator/factory/k8stools/secret_content.go +++ b/internal/controller/operator/factory/k8stools/secret_content.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "strings" + "unicode" vmv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1" corev1 "k8s.io/api/core/v1" @@ -23,7 +24,7 @@ func maybeTrimSpace(s string) string { if disabledSpaceTrim { return s } - return strings.TrimSpace(s) + return strings.TrimRightFunc(s, unicode.IsSpace) } // KeyNotFoundError represents an error if expected key diff --git a/internal/controller/operator/factory/k8stools/secret_content_test.go b/internal/controller/operator/factory/k8stools/secret_content_test.go index c4ab887b..4b41ce08 100644 --- a/internal/controller/operator/factory/k8stools/secret_content_test.go +++ b/internal/controller/operator/factory/k8stools/secret_content_test.go @@ -61,7 +61,7 @@ func Test_getCredFromSecret(t *testing.T) { cacheKey: "tls-secret", cache: map[string]*corev1.Secret{}, }, - want: "password-value", + want: " password-value", predefinedObjects: []runtime.Object{ &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -108,7 +108,7 @@ func Test_getCredFromSecret(t *testing.T) { return } if got != tt.want { - t.Errorf("getCredFromSecret() got = %v, want %v", got, tt.want) + t.Errorf("getCredFromSecret() got = %q, want %q", got, tt.want) } }) }