file-workspace
A workspace for reading and writing files in a project
Installation
dagger install github.com/kpenfound/dag/file-workspace@90ef4ddb55dc6dc1b453c67ca4aef66773c1ae49Entrypoint
Return Type
FileWorkspace !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | No description provided |
Example
dagger -m github.com/kpenfound/dag/file-workspace@90ef4ddb55dc6dc1b453c67ca4aef66773c1ae49 call \
--source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.FileWorkspace {
return dag.
FileWorkspace(source)
}@function
def example(source: dagger.Directory) -> dagger.FileWorkspace:
return (
dag.file_workspace(source)
)@func()
example(source: Directory): FileWorkspace {
return dag
.fileWorkspace(source)
}Types
FileWorkspace 🔗
source() 🔗
The source directory of the project
Return Type
Directory ! Example
dagger -m github.com/kpenfound/dag/file-workspace@90ef4ddb55dc6dc1b453c67ca4aef66773c1ae49 call \
--source DIR_PATH sourcefunc (m *MyModule) Example(source *dagger.Directory) *dagger.Directory {
return dag.
FileWorkspace(source).
Source()
}@function
def example(source: dagger.Directory) -> dagger.Directory:
return (
dag.file_workspace(source)
.source()
)@func()
example(source: Directory): Directory {
return dag
.fileWorkspace(source)
.source()
}read() 🔗
Read a file from the project
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | String ! | - | The path to the file |
Example
dagger -m github.com/kpenfound/dag/file-workspace@90ef4ddb55dc6dc1b453c67ca4aef66773c1ae49 call \
--source DIR_PATH read --path stringfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory, path string) string {
return dag.
FileWorkspace(source).
Read(ctx, path)
}@function
async def example(source: dagger.Directory, path: str) -> str:
return await (
dag.file_workspace(source)
.read(path)
)@func()
async example(source: Directory, path: string): Promise<string> {
return dag
.fileWorkspace(source)
.read(path)
}write() 🔗
Write a contents to a file in the project
Return Type
FileWorkspace !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | String ! | - | The path to the file |
| content | String ! | - | The content to write in the file |
Example
dagger -m github.com/kpenfound/dag/file-workspace@90ef4ddb55dc6dc1b453c67ca4aef66773c1ae49 call \
--source DIR_PATH write --path string --content stringfunc (m *MyModule) Example(source *dagger.Directory, path string, content string) *dagger.FileWorkspace {
return dag.
FileWorkspace(source).
Write(path, content)
}@function
def example(source: dagger.Directory, path: str, content: str) -> dagger.FileWorkspace:
return (
dag.file_workspace(source)
.write(path, content)
)@func()
example(source: Directory, path: string, content: string): FileWorkspace {
return dag
.fileWorkspace(source)
.write(path, content)
}listFiles() 🔗
List the files in the workspace in tree format
Return Type
String ! Example
dagger -m github.com/kpenfound/dag/file-workspace@90ef4ddb55dc6dc1b453c67ca4aef66773c1ae49 call \
--source DIR_PATH list-filesfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
FileWorkspace(source).
ListFiles(ctx)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.file_workspace(source)
.list_files()
)@func()
async example(source: Directory): Promise<string> {
return dag
.fileWorkspace(source)
.listFiles()
}