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

Function SplitWorkspaceIdentifier

codersdk/workspaces.go:620–629  ·  view source on GitHub ↗

SplitWorkspaceIdentifier splits an identifier into owner and workspace name. A bare name defaults the owner to Me ("me"). An "owner/name" pair is accepted, and identifiers with more than one "/" are rejected.

(identifier string)

Source from the content-addressed store, hash-verified

618// "owner/name" pair is accepted, and identifiers with more than one
619// "/" are rejected.
620func SplitWorkspaceIdentifier(identifier string) (owner, name string, err error) {
621 owner, name, ok := strings.Cut(identifier, "/")
622 if !ok {
623 return Me, identifier, nil
624 }
625 if strings.Contains(name, "/") {
626 return "", "", xerrors.Errorf("invalid workspace identifier: %q", identifier)
627 }
628 return owner, name, nil
629}
630
631// ResolveWorkspace fetches a workspace by identifier, which may be a
632// UUID, a bare name (owned by the current user), or an "owner/name"

Callers 5

scheduleShowMethod · 0.92
statePullMethod · 0.92
statePushMethod · 0.92
CreateMethod · 0.92
ResolveWorkspaceMethod · 0.85

Calls 2

ContainsMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected