Skip to main content

Workspace

API reference

A Dagger workspace detected from the current working directory or constructed from a Directory.

Implements Node

address
Canonical Dagger address of the workspace location, or an opaque identity for synthetic workspaces.
clientId
The client ID that owns this workspace's host filesystem.
configFile
Selected native workspace config file relative to the workspace root, if any.
configRead
Read a configuration value from dagger.toml.
configWrite
Write a configuration value to dagger.toml.
cwd
Current location within the workspace root.
envCreate
Create a named workspace environment if it does not already exist.
envList
List named environments defined in the workspace configuration.
envRemove
Remove a named workspace environment.
findUp
Search for a file or directory by walking up from the start path within the workspace.
id
A unique identifier for this Workspace.
init
Initialize workspace config, creating dagger.toml.
install
Install a module into the workspace, writing dagger.toml to the host.
moduleInit
Create a new module owned by the workspace and auto-install it in dagger.toml.
uninstall
Uninstall a module from the workspace, writing dagger.toml to the host.
checks
Return all checks from modules loaded in the workspace.
directory
Returns a Directory from the workspace.
file
Returns a File from the workspace.
generators
Return all generators from modules loaded in the workspace.
git
Git state for this workspace. Errors if the workspace is not in a git repository.
migrate
Plan the explicit migration needed for the current workspace.
moduleList
List modules defined in the workspace configuration.
services
Return all services from modules loaded in the workspace.
update
Refresh workspace-managed state and return the resulting changeset.

address: String!

Canonical Dagger address of the workspace location, or an opaque identity for synthetic workspaces.

clientId: String!

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

configFile: String!

Selected native workspace config file relative to the workspace root, if any.

configRead(key: String = ""): String!

Read a configuration value from dagger.toml.

If key is empty, returns the full config.

If key points to a scalar, returns the value.

If key points to a table, returns flattened dotted-key output.

key: String = ""

Dotted key path (e.g. modules.greeter.source). Empty for full config.

configWrite(key: String!,value: String!,here: Boolean = false): String!

Write a configuration value to dagger.toml.

key: String!

Dotted key path (e.g. modules.greeter.source).

value: String!

Value to set. Bools, integers, and comma-separated arrays are auto-detected.

here: Boolean = false

Write to the workspace config directory at the workspace cwd.

cwd: String!

Current location within the workspace root.

The workspace root is returned as "/".

Relative paths in workspace APIs resolve from here.

envCreate(name: String!, here: Boolean = false): String!

Create a named workspace environment if it does not already exist.

name: String!

Environment name.

here: Boolean = false

Write to the workspace config directory at the workspace cwd.

envList: [String!]!

List named environments defined in the workspace configuration.

envRemove(name: String!, here: Boolean = false): String!

Remove a named workspace environment.

name: String!

Environment name.

here: Boolean = false

Write to the workspace config directory at the workspace cwd.

findUp(name: String!, from: String = "."): String

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

Returns the absolute workspace path if found, or null if not found.

Relative start paths resolve from the workspace cwd.

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

name: String!

The name of the file or directory to search for.

from: String = "."

Path to start the search from. Relative paths resolve from the workspace cwd; absolute paths resolve from the workspace root.

id: ID!

A unique identifier for this Workspace.

init(here: Boolean = false): String!

Initialize workspace config, creating dagger.toml.

here: Boolean = false

Create the workspace config directory at the workspace cwd instead of using the default write target.

install(ref: String!,name: String = "",here: Boolean = false): String!

Install a module into the workspace, writing dagger.toml to the host.

ref: String!

Module reference to install.

name: String = ""

Override name for the installed module entry.

here: Boolean = false

Write to the workspace config directory at the workspace cwd.

moduleInit(name: String!,sdk: String = "",source: String = "",include: [String!] = [],selfCalls: Boolean = false,here: Boolean = false): String!

Create a new module owned by the workspace and auto-install it in dagger.toml.

name: String!

Name of the new module.

sdk: String = ""

SDK to use for the new module.

source: String = ""

Source subpath within the new module.

include: [String!] = []

Additional include patterns for the module.

selfCalls: Boolean = false

Enable the self-calls experimental feature for the new module.

here: Boolean = false

Write to the workspace config directory at the workspace cwd.

uninstall(name: String!, here: Boolean = false): String!

Uninstall a module from the workspace, writing dagger.toml to the host.

name: String!

Name of the installed module entry to remove.

here: Boolean = false

Write to the workspace config directory at the workspace cwd.

checks(include: [String!],skip: [String!],noGenerate: Boolean,onlyGenerate: Boolean): CheckGroup!

Return all checks from modules loaded in the workspace.

include: [String!]

Only include checks matching the specified patterns

skip: [String!]

Skip checks matching the specified patterns

noGenerate: Boolean

When true, only return annotated check functions; exclude generate-as-checks

onlyGenerate: Boolean

When true, only return generate-as-checks; exclude annotated check functions

directory(path: String!,exclude: [String!] = [],include: [String!] = [],gitignore: Boolean = false): Directory!

Returns a Directory from the workspace.

Relative paths resolve from the workspace cwd. Absolute paths resolve from the workspace root.

path: String!

Location of the directory to retrieve. Relative paths (e.g., "src") resolve from the workspace cwd; absolute paths (e.g., "/src") resolve from the workspace root.

exclude: [String!] = []

Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).

include: [String!] = []

Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).

gitignore: Boolean = false

Apply .gitignore filter rules inside the directory.

file(path: String!): File!

Returns a File from the workspace.

Relative paths resolve from the workspace cwd. Absolute paths resolve from the workspace root.

path: String!

Location of the file to retrieve. Relative paths (e.g., "go.mod") resolve from the workspace cwd; absolute paths (e.g., "/go.mod") resolve from the workspace root.

generators(include: [String!]): GeneratorGroup!

Return all generators from modules loaded in the workspace.

include: [String!]

Only include generators matching the specified patterns

git: WorkspaceGit!

Git state for this workspace. Errors if the workspace is not in a git repository.

migrate(force: Boolean = false): WorkspaceMigration!

Plan the explicit migration needed for the current workspace.

The returned plan has an empty changeset and no steps when no migration is needed.

force: Boolean = false

moduleList(module: String = ""): [WorkspaceModule!]!

List modules defined in the workspace configuration.

module: String = ""

Optional module alias to inspect.

services(include: [String!]): UpGroup!

Return all services from modules loaded in the workspace.

include: [String!]

Only include services matching the specified patterns

update: Changeset!Experimental

Refresh workspace-managed state and return the resulting changeset.

Currently this refreshes existing lockfile entries only.

Experimental: Experimental workspace update API currently refreshes existing lockfile entries only.

References

Returned by

Accepted as an argument by