Dagger
Search

workspace

This module has been generated via dagger init and serves as a reference to
basic module structure as you get started with Dagger.

Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.

The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.

Installation

dagger install github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8

Entrypoint

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
baseImageString !"alpine"Docker base image to use for workspace container
contextDirectory -The starting context for the workspace
checkerString !"echo true"The command to check if the workspace meets requirements
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string
func (m *myModule) example(baseImage string, checker string) *Workspace  {
	return dag.
			Workspace(baseImage, checker)
}
@function
def example(base_image: str, checker: str) -> dag.Workspace:
	return (
		dag.workspace(base_image, checker)
	)
@func()
example(baseImage: string, checker: string): Workspace {
	return dag
		.workspace(baseImage, checker)
}

Types

Workspace 🔗

Workspace module for development environments

check() 🔗

Checks if the workspace meets the requirements

Return Type
String !
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string check
func (m *myModule) example(ctx context.Context, baseImage string, checker string) string  {
	return dag.
			Workspace(baseImage, checker).
			Check(ctx)
}
@function
async def example(base_image: str, checker: str) -> str:
	return await (
		dag.workspace(base_image, checker)
		.check()
	)
@func()
async example(baseImage: string, checker: string): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.check()
}

container() 🔗

Returns the container for the workspace

Return Type
Container !
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string container
func (m *myModule) example(baseImage string, checker string) *Container  {
	return dag.
			Workspace(baseImage, checker).
			Container()
}
@function
def example(base_image: str, checker: str) -> dagger.Container:
	return (
		dag.workspace(base_image, checker)
		.container()
	)
@func()
example(baseImage: string, checker: string): Container {
	return dag
		.workspace(baseImage, checker)
		.container()
}

diff() 🔗

Returns the changes in the workspace so far

Return Type
String !
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string diff
func (m *myModule) example(ctx context.Context, baseImage string, checker string) string  {
	return dag.
			Workspace(baseImage, checker).
			Diff(ctx)
}
@function
async def example(base_image: str, checker: str) -> str:
	return await (
		dag.workspace(base_image, checker)
		.diff()
	)
@func()
async example(baseImage: string, checker: string): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.diff()
}

exec() 🔗

Executes a command in the workspace. Does not return the output of the command

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
commandString !-command to execute in the workspace
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string exec --command string
func (m *myModule) example(baseImage string, checker string, command string) *Workspace  {
	return dag.
			Workspace(baseImage, checker).
			Exec(command)
}
@function
def example(base_image: str, checker: str, command: str) -> dag.Workspace:
	return (
		dag.workspace(base_image, checker)
		.exec(command)
	)
@func()
example(baseImage: string, checker: string, command: string): Workspace {
	return dag
		.workspace(baseImage, checker)
		.exec(command)
}

getExecOutput() 🔗

Returns the output of the last executed command

Return Type
String !
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string get-exec-output
func (m *myModule) example(ctx context.Context, baseImage string, checker string) string  {
	return dag.
			Workspace(baseImage, checker).
			GetExecOutput(ctx)
}
@function
async def example(base_image: str, checker: str) -> str:
	return await (
		dag.workspace(base_image, checker)
		.get_exec_output()
	)
@func()
async example(baseImage: string, checker: string): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.getExecOutput()
}

ls() 🔗

Returns the list of files in the workspace at the provided path

Return Type
[String ! ] !
Arguments
NameTypeDefault ValueDescription
pathString !-Path to get the list of files from
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string ls --path string
func (m *myModule) example(ctx context.Context, baseImage string, checker string, path string) []string  {
	return dag.
			Workspace(baseImage, checker).
			Ls(ctx, path)
}
@function
async def example(base_image: str, checker: str, path: str) -> List[str]:
	return await (
		dag.workspace(base_image, checker)
		.ls(path)
	)
@func()
async example(baseImage: string, checker: string, path: string): Promise<string[]> {
	return dag
		.workspace(baseImage, checker)
		.ls(path)
}

read() 🔗

Returns the contents of a file in the workspace at the provided path

Return Type
String !
Arguments
NameTypeDefault ValueDescription
pathString !-File path to read a file from
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string read --path string
func (m *myModule) example(ctx context.Context, baseImage string, checker string, path string) string  {
	return dag.
			Workspace(baseImage, checker).
			Read(ctx, path)
}
@function
async def example(base_image: str, checker: str, path: str) -> str:
	return await (
		dag.workspace(base_image, checker)
		.read(path)
	)
@func()
async example(baseImage: string, checker: string, path: string): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.read(path)
}

writeDirectory() 🔗

Writes the provided contents to a directory in the workspace at the provided path

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-Directory path to write a directory to
dirDirectory !-Directory contents to write
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string write-directory --path string --dir DIR_PATH
func (m *myModule) example(baseImage string, checker string, path string, dir *Directory) *Workspace  {
	return dag.
			Workspace(baseImage, checker).
			WriteDirectory(path, dir)
}
@function
def example(base_image: str, checker: str, path: str, dir: dagger.Directory) -> dag.Workspace:
	return (
		dag.workspace(base_image, checker)
		.write_directory(path, dir)
	)
@func()
example(baseImage: string, checker: string, path: string, dir: Directory): Workspace {
	return dag
		.workspace(baseImage, checker)
		.writeDirectory(path, dir)
}

writeFile() 🔗

Writes the provided contents to a file in the workspace at the provided path

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-File path to write a file to
contentsString !-File contents to write
Example
dagger -m github.com/kpenfound/dag/workspace@c6809821f7133cc03bea4290fbe81212e25338c8 call \
 --base-image string --checker string write-file --path string --contents string
func (m *myModule) example(baseImage string, checker string, path string, contents string) *Workspace  {
	return dag.
			Workspace(baseImage, checker).
			WriteFile(path, contents)
}
@function
def example(base_image: str, checker: str, path: str, contents: str) -> dag.Workspace:
	return (
		dag.workspace(base_image, checker)
		.write_file(path, contents)
	)
@func()
example(baseImage: string, checker: string, path: string, contents: string): Workspace {
	return dag
		.workspace(baseImage, checker)
		.writeFile(path, contents)
}