NormalizeWorkspaceInput converts workspace name input to standard format. Handles the following input formats: - workspace → workspace - workspace.agent → workspace.agent - owner/workspace → owner/workspace - owner--workspace → owner/workspace
(input string)
| 2486 | // - owner--workspace.agent → owner/workspace.agent |
| 2487 | // - agent.workspace.owner → owner/workspace.agent (Coder Connect format) |
| 2488 | func NormalizeWorkspaceInput(input string) string { |
| 2489 | // Handle the special Coder Connect format: agent.workspace.owner |
| 2490 | // This format uses only dots and has exactly 3 parts |
| 2491 | if strings.Count(input, ".") == 2 && !strings.Contains(input, "/") && !strings.Contains(input, "--") { |
| 2492 | parts := strings.Split(input, ".") |
| 2493 | if len(parts) == 3 { |
| 2494 | // Convert agent.workspace.owner → owner/workspace.agent |
| 2495 | return fmt.Sprintf("%s/%s.%s", parts[2], parts[1], parts[0]) |
| 2496 | } |
| 2497 | } |
| 2498 | |
| 2499 | // Convert -- separator to / separator for consistency |
| 2500 | normalized := strings.ReplaceAll(input, "--", "/") |
| 2501 | |
| 2502 | return normalized |
| 2503 | } |
| 2504 | |
| 2505 | const workspaceDescription = "The workspace ID or name in the format [owner/]workspace. If an owner is not specified, the authenticated user is used." |
| 2506 |