From 095024c179aee07852584214f53d9fd5adbfa0b2 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Tue, 18 Oct 2022 15:49:30 -0400 Subject: [PATCH] dnsSafeShortid (#79) --- controller/util.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/controller/util.go b/controller/util.go index e2f403a1..9b911294 100644 --- a/controller/util.go +++ b/controller/util.go @@ -48,7 +48,21 @@ func createToken() (string, error) { } func createServiceName() (string, error) { - return shortid.Generate() + return dnsSafeShortId() +} + +func dnsSafeShortId() (string, error) { + sid, err := shortid.Generate() + if err != nil { + return "", err + } + for sid[0] == '-' || sid[0] == '_' { + sid, err = shortid.Generate() + if err != nil { + return "", err + } + } + return sid, nil } func hashPassword(raw string) string {