workspace
No long description provided.
Installation
dagger install github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a
Entrypoint
Return Type
Workspace !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
checker | Container | - | 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. |
start | Directory | - | Initial state to start the workspace from By default the workspace starts empty |
Example
dagger -m github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a 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@794ff988e989e15a263d2c66358709a407633e7a 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@794ff988e989e15a263d2c66358709a407633e7a 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@794ff988e989e15a263d2c66358709a407633e7a 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()
}
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@794ff988e989e15a263d2c66358709a407633e7a 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
Name | Type | Default Value | Description |
---|---|---|---|
path | String ! | - | The path of the file to write |
contents | String ! | - | The contents to write |
Example
dagger -m github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a 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)
}
read() 🔗
Read the contents of a file in thw workspace
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
path | String ! | - | No description provided |
Example
dagger -m github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a 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
Name | Type | Default Value | Description |
---|---|---|---|
path | String ! | - | No description provided |
Example
dagger -m github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a 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
Name | Type | Default Value | Description |
---|---|---|---|
path | String ! | - | No description provided |
Example
dagger -m github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a 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
Name | Type | Default Value | Description |
---|---|---|---|
path | String | "/" | Path of the target directory |
Example
dagger -m github.com/shykes/melvin/workspace@794ff988e989e15a263d2c66358709a407633e7a 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
Name | Type | Default Value | Description |
---|---|---|---|
pattern | String | "**" | 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@794ff988e989e15a263d2c66358709a407633e7a 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()
}