Dagger
Search

workspace

No long description provided.

Installation

dagger install github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78

Entrypoint

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
checkerContainer -A builder container, for verifying that the code builds, tests run etc. Container spec: - Workspace will be mounted to container workdir - Container default args will be executed. - Exit code 0 is considered a successful check. Otherwise a failure.
startDirectory -Initial state to start the workspace from By default the workspace starts empty
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
func (m *myModule) example() *Workspace  {
	return dag.
			Workspace()
}
@function
def example() -> dag.Workspace:
	return (
		dag.workspace()
	)
@func()
example(): Workspace {
	return dag
		.workspace()
}

Types

Workspace 🔗

A workspace for editing files and checking the result

dir() 🔗

An immutable snapshot of the workspace contents

Return Type
Directory !
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 dir
func (m *myModule) example() *Directory  {
	return dag.
			Workspace().
			Dir()
}
@function
def example() -> dagger.Directory:
	return (
		dag.workspace()
		.dir()
	)
@func()
example(): Directory {
	return dag
		.workspace()
		.dir()
}

check() 🔗

Check that the current contents is valid This is done by executed an externally-provided checker container with the workspace mounted. If there is no checker, the check will always pass

Return Type
String !
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 check
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Workspace().
			Check(ctx)
}
@function
async def example() -> str:
	return await (
		dag.workspace()
		.check()
	)
@func()
async example(): Promise<string> {
	return dag
		.workspace()
		.check()
}

diff() 🔗

Return all changes to the workspace since the start of the session, in unified diff format, with the following convention: - before/ is the start state - after/ is the current state

Return Type
String !
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 diff
func (m *myModule) example(ctx context.Context) string  {
	return dag.
			Workspace().
			Diff(ctx)
}
@function
async def example() -> str:
	return await (
		dag.workspace()
		.diff()
	)
@func()
async example(): Promise<string> {
	return dag
		.workspace()
		.diff()
}

checkpoint() 🔗

Checkpoint the current state of the workspace, with a description of the changes made.

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
descriptionString !-No description provided
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 checkpoint --description string
func (m *myModule) example(description string) *Workspace  {
	return dag.
			Workspace().
			Checkpoint(description)
}
@function
def example(description: str) -> dag.Workspace:
	return (
		dag.workspace()
		.checkpoint(description)
	)
@func()
example(description: string): Workspace {
	return dag
		.workspace()
		.checkpoint(description)
}

history() 🔗

Return a history of all checkpoints so far, from first to last

Return Type
[String ! ] !
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 history
func (m *myModule) example(ctx context.Context) []string  {
	return dag.
			Workspace().
			History(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.workspace()
		.history()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.workspace()
		.history()
}

reset() 🔗

Reset the workspace to its starting state. Warning: this will wipe all changes made during the current session

Return Type
Workspace !
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 reset
func (m *myModule) example() *Workspace  {
	return dag.
			Workspace().
			Reset()
}
@function
def example() -> dag.Workspace:
	return (
		dag.workspace()
		.reset()
	)
@func()
example(): Workspace {
	return dag
		.workspace()
		.reset()
}

write() 🔗

Write to a file in the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-The path of the file to write
contentsString !-The contents to write
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 write --path string --contents string
func (m *myModule) example(path string, contents string) *Workspace  {
	return dag.
			Workspace().
			Write(path, contents)
}
@function
def example(path: str, contents: str) -> dag.Workspace:
	return (
		dag.workspace()
		.write(path, contents)
	)
@func()
example(path: string, contents: string): Workspace {
	return dag
		.workspace()
		.write(path, contents)
}

copyDir() 🔗

Copy an entire directory into the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-The target path
dirDirectory !-The directory to copy at the target path. Existing content is overwritten at the file granularity.
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 copy-dir --path string --dir DIR_PATH
func (m *myModule) example(path string, dir *Directory) *Workspace  {
	return dag.
			Workspace().
			CopyDir(path, dir)
}
@function
def example(path: str, dir: dagger.Directory) -> dag.Workspace:
	return (
		dag.workspace()
		.copy_dir(path, dir)
	)
@func()
example(path: string, dir: Directory): Workspace {
	return dag
		.workspace()
		.copyDir(path, dir)
}

read() 🔗

Read the contents of a file in thw workspace

Return Type
String !
Arguments
NameTypeDefault ValueDescription
pathString !-No description provided
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 read --path string
func (m *myModule) example(ctx context.Context, path string) string  {
	return dag.
			Workspace().
			Read(ctx, path)
}
@function
async def example(path: str) -> str:
	return await (
		dag.workspace()
		.read(path)
	)
@func()
async example(path: string): Promise<string> {
	return dag
		.workspace()
		.read(path)
}

rm() 🔗

Remove a file from the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-No description provided
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 rm --path string
func (m *myModule) example(path string) *Workspace  {
	return dag.
			Workspace().
			Rm(path)
}
@function
def example(path: str) -> dag.Workspace:
	return (
		dag.workspace()
		.rm(path)
	)
@func()
example(path: string): Workspace {
	return dag
		.workspace()
		.rm(path)
}

rmDir() 🔗

Remove a directory from the workspace

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-No description provided
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 rm-dir --path string
func (m *myModule) example(path string) *Workspace  {
	return dag.
			Workspace().
			RmDir(path)
}
@function
def example(path: str) -> dag.Workspace:
	return (
		dag.workspace()
		.rm_dir(path)
	)
@func()
example(path: string): Workspace {
	return dag
		.workspace()
		.rmDir(path)
}

listDir() 🔗

List the contents of a directory in the workspace

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
pathString "/"Path of the target directory
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 list-dir
func (m *myModule) example(ctx context.Context) []string  {
	return dag.
			Workspace().
			ListDir(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.workspace()
		.list_dir()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.workspace()
		.listDir()
}

walk() 🔗

Walk all files in the workspace (optionally filtered by a glob pattern), and return their path.

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
patternString "**"A glob pattern to filter files. Only matching files will be included. The glob format is the same as Dockerfile/buildkit
Example
dagger -m github.com/shykes/melvin/workspace@2cbe8a14772fedf250c33e992a5e73b2f1d2ee78 call \
 walk
func (m *myModule) example(ctx context.Context) []string  {
	return dag.
			Workspace().
			Walk(ctx)
}
@function
async def example() -> List[str]:
	return await (
		dag.workspace()
		.walk()
	)
@func()
async example(): Promise<string[]> {
	return dag
		.workspace()
		.walk()
}