( ctx context.Context, deps commandDeps, client DaemonClient, workspaceRef string, )
| 193 | } |
| 194 | |
| 195 | func resolveCLIWorkspaceRouteRef( |
| 196 | ctx context.Context, |
| 197 | deps commandDeps, |
| 198 | client DaemonClient, |
| 199 | workspaceRef string, |
| 200 | ) (string, error) { |
| 201 | trimmed := strings.TrimSpace(workspaceRef) |
| 202 | if trimmed == "" { |
| 203 | trimmed = strings.TrimSpace(deps.getenv("AGH_WORKSPACE")) |
| 204 | } |
| 205 | if trimmed == "" { |
| 206 | cwd, err := currentWorkingDirectory(deps) |
| 207 | if err != nil { |
| 208 | return "", err |
| 209 | } |
| 210 | trimmed = cwd |
| 211 | } |
| 212 | if !workspaceRefLooksLikePath(trimmed) { |
| 213 | return trimmed, nil |
| 214 | } |
| 215 | detail, err := client.GetWorkspace(ctx, trimmed) |
| 216 | if err != nil { |
| 217 | return "", fmt.Errorf("cli: resolve workspace %q: %w", trimmed, err) |
| 218 | } |
| 219 | workspaceID := strings.TrimSpace(detail.Workspace.ID) |
| 220 | if workspaceID == "" { |
| 221 | return "", fmt.Errorf("cli: resolve workspace %q: missing workspace id", trimmed) |
| 222 | } |
| 223 | return workspaceID, nil |
| 224 | } |
| 225 | |
| 226 | func isPathLikeWorkspaceRef(ref string) bool { |
| 227 | return filepath.IsAbs(ref) || |
no test coverage detected