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@v1.0.2

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@7713920d272b2f990fa50eee5a2da53829168db6 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 passes validation

Return Type
String !
Example
dagger -m github.com/kpenfound/dag/workspace@7713920d272b2f990fa50eee5a2da53829168db6 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@7713920d272b2f990fa50eee5a2da53829168db6 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@7713920d272b2f990fa50eee5a2da53829168db6 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@7713920d272b2f990fa50eee5a2da53829168db6 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@7713920d272b2f990fa50eee5a2da53829168db6 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@7713920d272b2f990fa50eee5a2da53829168db6 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)
}

readFile() 🔗

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@7713920d272b2f990fa50eee5a2da53829168db6 call \
 --base-image string --checker string read-file --path string
func (m *myModule) example(ctx context.Context, baseImage string, checker string, path string) string  {
	return dag.
			Workspace(baseImage, checker).
			ReadFile(ctx, path)
}
@function
async def example(base_image: str, checker: str, path: str) -> str:
	return await (
		dag.workspace(base_image, checker)
		.read_file(path)
	)
@func()
async example(baseImage: string, checker: string, path: string): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.readFile(path)
}

readFileLines() 🔗

Reads a files contents from the start to end line

Return Type
String !
Arguments
NameTypeDefault ValueDescription
pathString !-File path to read a file from
startInteger !-First line to read
endInteger !-Last line to read
Example
dagger -m github.com/kpenfound/dag/workspace@7713920d272b2f990fa50eee5a2da53829168db6 call \
 --base-image string --checker string read-file-lines --path string --start integer --end integer
func (m *myModule) example(ctx context.Context, baseImage string, checker string, path string, start int, end int) string  {
	return dag.
			Workspace(baseImage, checker).
			ReadFileLines(ctx, path, start, end)
}
@function
async def example(base_image: str, checker: str, path: str, start: int, end: int) -> str:
	return await (
		dag.workspace(base_image, checker)
		.read_file_lines(path, start, end)
	)
@func()
async example(baseImage: string, checker: string, path: string, start: number, end: number): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.readFileLines(path, start, end)
}

reset() 🔗

Resets the workspace to the initial state

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

search() 🔗

Searches for a pattern in the workspace files returning the file names and surrounding lines

Return Type
String !
Arguments
NameTypeDefault ValueDescription
patternString !-The pattern to search for
Example
dagger -m github.com/kpenfound/dag/workspace@7713920d272b2f990fa50eee5a2da53829168db6 call \
 --base-image string --checker string search --pattern string
func (m *myModule) example(ctx context.Context, baseImage string, checker string, pattern string) string  {
	return dag.
			Workspace(baseImage, checker).
			Search(ctx, pattern)
}
@function
async def example(base_image: str, checker: str, pattern: str) -> str:
	return await (
		dag.workspace(base_image, checker)
		.search(pattern)
	)
@func()
async example(baseImage: string, checker: string, pattern: string): Promise<string> {
	return dag
		.workspace(baseImage, checker)
		.search(pattern)
}

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@7713920d272b2f990fa50eee5a2da53829168db6 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 new 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@7713920d272b2f990fa50eee5a2da53829168db6 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)
}

writeFileLine() 🔗

Replaces a specified line of a file with new content

Return Type
Workspace !
Arguments
NameTypeDefault ValueDescription
pathString !-File path to read a file from
lineInteger !-File line to replace
contentString !-New content to replace the line
Example
dagger -m github.com/kpenfound/dag/workspace@7713920d272b2f990fa50eee5a2da53829168db6 call \
 --base-image string --checker string write-file-line --path string --line integer --content string
func (m *myModule) example(baseImage string, checker string, path string, line int, content string) *Workspace  {
	return dag.
			Workspace(baseImage, checker).
			WriteFileLine(path, line, content)
}
@function
def example(base_image: str, checker: str, path: str, line: int, content: str) -> dag.Workspace:
	return (
		dag.workspace(base_image, checker)
		.write_file_line(path, line, content)
	)
@func()
example(baseImage: string, checker: string, path: string, line: number, content: string): Workspace {
	return dag
		.workspace(baseImage, checker)
		.writeFileLine(path, line, content)
}