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)
| 618 | // "owner/name" pair is accepted, and identifiers with more than one |
| 619 | // "/" are rejected. |
| 620 | func 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" |
no test coverage detected