buildCoreWorkspace converts the internal workspace detection result into the public core.Workspace. For local workspaces, it stores the host path (directories are resolved lazily). For remote, it stores the prebuiltRootfs.
( ctx context.Context, _ *daggerClient, detected *workspace.Workspace, isLocal bool, prebuiltRootfs dagql.ObjectResult[*core.Directory], address string, )
| 576 | // the public core.Workspace. For local workspaces, it stores the host path |
| 577 | // (directories are resolved lazily). For remote, it stores the prebuiltRootfs. |
| 578 | func (srv *Server) buildCoreWorkspace( |
| 579 | ctx context.Context, |
| 580 | _ *daggerClient, |
| 581 | detected *workspace.Workspace, |
| 582 | isLocal bool, |
| 583 | prebuiltRootfs dagql.ObjectResult[*core.Directory], |
| 584 | address string, |
| 585 | ) (*core.Workspace, error) { |
| 586 | // Capture the current client ID for routing host filesystem operations. |
| 587 | clientMetadata, err := engine.ClientMetadataFromContext(ctx) |
| 588 | if err != nil { |
| 589 | return nil, fmt.Errorf("client metadata: %w", err) |
| 590 | } |
| 591 | |
| 592 | coreWS := &core.Workspace{ |
| 593 | Address: address, |
| 594 | Path: detected.Path, |
| 595 | ClientID: clientMetadata.ClientID, |
| 596 | } |
| 597 | if coreWS.Address == "" { |
| 598 | coreWS.Address = localWorkspaceAddress(detected.Root, detected.Path) |
| 599 | } |
| 600 | |
| 601 | if isLocal { |
| 602 | // Local: store host path only. Directories are resolved lazily |
| 603 | // via per-call host.directory() in resolveRootfs. |
| 604 | coreWS.SetHostPath(detected.Root) |
| 605 | } else { |
| 606 | // Remote: store the cloned git tree. |
| 607 | coreWS.SetRootfs(prebuiltRootfs) |
| 608 | } |
| 609 | |
| 610 | return coreWS, nil |
| 611 | } |
| 612 | |
| 613 | func localWorkspaceAddress(root, workspacePath string) string { |
| 614 | workspaceDir := filepath.Join(root, workspacePath) |
no test coverage detected