From 169778e23bb8e315b1cdfcb54d9d59daace4a57d Mon Sep 17 00:00:00 2001 From: Irbe Krumina Date: Fri, 12 Jan 2024 10:08:22 +0000 Subject: [PATCH] cmd/k8s-operator: minor fix in name gen (#10830) Updates#cleanup Signed-off-by: Irbe Krumina --- cmd/k8s-operator/sts.go | 6 ++---- cmd/k8s-operator/sts_test.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/k8s-operator/sts.go b/cmd/k8s-operator/sts.go index c4ad2cf1c..3104d2775 100644 --- a/cmd/k8s-operator/sts.go +++ b/cmd/k8s-operator/sts.go @@ -222,10 +222,8 @@ func statefulSetNameBase(parent string) string { if excess <= 0 { return base } - base = base[:len(base)-1-excess] // cut off the excess chars - if !strings.HasSuffix(base, "-") { // dash may have been cut by the generator - base = base + "-" - } + base = base[:len(base)-1-excess] // cut off the excess chars + base = base + "-" // re-instate the dash } } diff --git a/cmd/k8s-operator/sts_test.go b/cmd/k8s-operator/sts_test.go index a31775ee0..0d0fe746b 100644 --- a/cmd/k8s-operator/sts_test.go +++ b/cmd/k8s-operator/sts_test.go @@ -28,7 +28,7 @@ func Test_statefulSetNameBase(t *testing.T) { if _, err := b.WriteString("a"); err != nil { t.Fatalf("error writing to string builder: %v", err) } - baseLength := len(b.String()) + baseLength := b.Len() if baseLength > 43 { baseLength = 43 // currently 43 is the max base length }