MCPcopy Index your code
hub / github.com/coder/coder / generatedWorkspaceName

Function generatedWorkspaceName

coderd/x/chatd/chattool/createworkspace.go:706–725  ·  view source on GitHub ↗
(seed string)

Source from the content-addressed store, hash-verified

704}
705
706func generatedWorkspaceName(seed string) string {
707 base := codersdk.UsernameFrom(strings.TrimSpace(strings.ToLower(seed)))
708 if strings.TrimSpace(base) == "" {
709 base = "workspace"
710 }
711
712 suffix := strings.ReplaceAll(uuid.NewString(), "-", "")[:4]
713 if len(base) > 27 {
714 base = strings.Trim(base[:27], "-")
715 }
716 if base == "" {
717 base = "workspace"
718 }
719
720 name := fmt.Sprintf("%s-%s", base, suffix)
721 if err := codersdk.NameValid(name); err == nil {
722 return name
723 }
724 return namesgenerator.NameDigitWith("-")
725}

Callers 1

CreateWorkspaceFunction · 0.85

Calls 3

UsernameFromFunction · 0.92
NameValidFunction · 0.92
NameDigitWithFunction · 0.92

Tested by

no test coverage detected