mirror of
https://github.com/rancher/norman.git
synced 2025-06-28 16:27:25 +00:00
20 lines
357 B
Go
20 lines
357 B
Go
package types
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
|
|
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
|
)
|
|
|
|
var (
|
|
lowerChars = regexp.MustCompile("[a-z]+")
|
|
)
|
|
|
|
func GenerateName(typeName string) string {
|
|
base := typeName[0:1] + lowerChars.ReplaceAllString(typeName[1:], "")
|
|
last := utilrand.String(5)
|
|
return fmt.Sprintf("%s-%s", strings.ToLower(base), last)
|
|
}
|