Skip to main content
Version: 0.20.2

Workspace

@dagger.io/dagger


@dagger.io/dagger / api/client.gen / Workspace

Class: Workspace

A Dagger workspace detected from the current working directory.

Extends

  • BaseClient

Constructors

Constructor

new Workspace(ctx?, _id?, _clientId?, _findUp?, _root?): Workspace

Constructor is used for internal usage only, do not create object from it.

Parameters

ctx?

Context

_id?

WorkspaceID

_clientId?

string

_findUp?

string

_root?

string

Returns

Workspace

Overrides

BaseClient.constructor

Methods

clientId()

clientId(): Promise<string>

The client ID that owns this workspace's host filesystem.

Returns

Promise<string>


directory()

directory(path, opts?): Directory

Returns a Directory from the workspace.

Path is relative to workspace root. Use "." for the root directory.

Parameters

path

string

Location of the directory to retrieve, relative to the workspace root (e.g., "src", ".").

opts?

WorkspaceDirectoryOpts

Returns

Directory


file()

file(path): File

Returns a File from the workspace.

Path is relative to workspace root.

Parameters

path

string

Location of the file to retrieve, relative to the workspace root (e.g., "go.mod").

Returns

File


findUp()

findUp(name, opts?): Promise<string>

Search for a file or directory by walking up from the start path within the workspace.

Returns the path relative to the workspace root if found, or null if not found.

The search stops at the workspace root and will not traverse above it.

Parameters

name

string

The name of the file or directory to search for.

opts?

WorkspaceFindUpOpts

Returns

Promise<string>


id()

id(): Promise<WorkspaceID>

A unique identifier for this Workspace.

Returns

Promise<WorkspaceID>


root()

root(): Promise<string>

Absolute path to the workspace root directory.

Returns

Promise<string>