cmd/k8s-operator: minor fix in name gen (#10830)

Updates#cleanup

Signed-off-by: Irbe Krumina <irbe@tailscale.com>
pull/10833/head
Irbe Krumina 10 months ago committed by GitHub
parent b89c113365
commit 169778e23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
}
}

@ -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
}

Loading…
Cancel
Save