Skip to content

Commit

Permalink
build/secret_content: aligns secret content trim space behaviour with VM
Browse files Browse the repository at this point in the history
See this PR for details VictoriaMetrics/VictoriaMetrics#7106

Signed-off-by: f41gh7 <nik@victoriametrics.com>
  • Loading branch information
f41gh7 committed Sep 27, 2024
1 parent a9c5954 commit 1e3de8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"unicode"

vmv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
}
})
}
Expand Down

0 comments on commit 1e3de8c

Please sign in to comment.