mirror of
https://github.com/rancher/norman.git
synced 2025-06-29 16:58:05 +00:00
20 lines
358 B
Go
20 lines
358 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("1%s-%s", strings.ToLower(base), last)
|
||
|
}
|