MCPcopy Create free account
hub / github.com/dagger/dagger / readWorkspaceLockState

Function readWorkspaceLockState

engine/server/session.go:1761–1782  ·  view source on GitHub ↗
(ctx context.Context, bk interface {
	ReadCallerHostFile(ctx context.Context, path string) ([]byte, error)
}, ws *core.Workspace)

Source from the content-addressed store, hash-verified

1759}
1760
1761func readWorkspaceLockState(ctx context.Context, bk interface {
1762 ReadCallerHostFile(ctx context.Context, path string) ([]byte, error)
1763}, ws *core.Workspace) (*workspace.Lock, error) {
1764 lockPath, err := workspaceLockPath(ws)
1765 if err != nil {
1766 return nil, err
1767 }
1768
1769 data, err := bk.ReadCallerHostFile(ctx, lockPath)
1770 if err != nil {
1771 if isWorkspaceLockNotFound(err) {
1772 return workspace.NewLock(), nil
1773 }
1774 return nil, fmt.Errorf("reading lock: %w", err)
1775 }
1776
1777 lock, err := workspace.ParseLock(data)
1778 if err != nil {
1779 return nil, fmt.Errorf("parsing lock: %w", err)
1780 }
1781 return lock, nil
1782}
1783
1784func isWorkspaceLockNotFound(err error) bool {
1785 return errors.Is(err, os.ErrNotExist) || status.Code(err) == codes.NotFound

Callers 2

flushWorkspaceLocksMethod · 0.70

Calls 5

NewLockFunction · 0.92
ParseLockFunction · 0.92
workspaceLockPathFunction · 0.85
isWorkspaceLockNotFoundFunction · 0.70
ReadCallerHostFileMethod · 0.45

Tested by

no test coverage detected