MCPcopy Index your code
hub / github.com/dagger/dagger / loadWorkspaceFromRemote

Method loadWorkspaceFromRemote

engine/server/session_workspaces.go:279–308  ·  view source on GitHub ↗

loadWorkspaceFromRemote clones a git repo and detects/loads the workspace from it.

(ctx context.Context, client *daggerClient, remoteRef string)

Source from the content-addressed store, hash-verified

277
278// loadWorkspaceFromRemote clones a git repo and detects/loads the workspace from it.
279func (srv *Server) loadWorkspaceFromRemote(ctx context.Context, client *daggerClient, remoteRef string) error {
280 parsedRef, err := parseWorkspaceRemoteRef(ctx, remoteRef)
281 if err != nil {
282 return fmt.Errorf("remote workspace %q: parsing git ref: %w", remoteRef, err)
283 }
284
285 tree, err := srv.cloneGitTree(ctx, client.dag, parsedRef.cloneRef, parsedRef.version)
286 if err != nil {
287 return fmt.Errorf("remote workspace %q: %w", remoteRef, err)
288 }
289
290 resolveLocalRef := func(ws *workspace.Workspace, relPath string) string {
291 subPath := filepath.Join(ws.Root, ws.Path, relPath)
292 return core.GitRefString(parsedRef.cloneRef, subPath, parsedRef.version)
293 }
294
295 return srv.detectAndLoadWorkspaceWithRootfs(ctx, client,
296 &core.DirectoryStatFS{Dir: tree},
297 func(ctx context.Context, path string) ([]byte, error) {
298 return core.DirectoryReadFile(ctx, tree, path)
299 },
300 parsedRef.workspaceSubdir,
301 resolveLocalRef,
302 func(ws *workspace.Workspace) string {
303 return remoteWorkspaceAddress(parsedRef.cloneRef, ws.Path, parsedRef.version)
304 },
305 false, // isLocal
306 tree, // pre-built rootfs for remote
307 )
308}
309
310// detectAndLoadWorkspace is the unified core of workspace detection and module loading
311// for local workspaces.

Callers 1

Calls 6

cloneGitTreeMethod · 0.95
GitRefStringFunction · 0.92
DirectoryReadFileFunction · 0.92
parseWorkspaceRemoteRefFunction · 0.85
remoteWorkspaceAddressFunction · 0.85

Tested by

no test coverage detected