greeter
via a remote git ref cannot walk into a workspace subdirectory through aDirectory argument annotated with defaultPath="/" + ignore patterns.
When loaded as github.com/dagger/dagger-test-modules/workspace-default-path/greeter@,
the module's defaultPath="/" must resolve to the repo root (where .git and
the root dagger.json live). The ignore patterns exclude everything except
workspace-default-path/target-subdir/, so workspace.Directory(
"workspace-default-path/target-subdir") must return a directory whose
contents include hello.txt.
This mirrors toolchains/java-sdk-dev's production pattern:
pub workspace: Directory! @defaultPath(path: "/") @ignorePatterns(patterns: [
"*",
"!sdk/java/runtime/images/",
...
])
workspace.directory("sdk/java/runtime/images/maven")
Installation
dagger install github.com/dagger/dagger-test-modules/workspace-default-path/greeter@572928568658e1146d6bccf63a07914d589ba952Entrypoint
Return Type
Greeter Example
dagger -m github.com/dagger/dagger-test-modules/workspace-default-path/greeter@572928568658e1146d6bccf63a07914d589ba952 call \
func (m *MyModule) Example() *dagger.Greeter {
return dag.
Greeter()
}@function
def example() -> dagger.Greeter:
return (
dag.greeter()
)@func()
example(): Greeter {
return dag
.greeter()
}Types
Greeter 🔗
read() 🔗
Read returns the contents of target-subdir/hello.txt, reached by walking into the workspace root (defaultPath=“/”) and then into the target subdirectory. The ignore patterns must re-include that subdirectory for Read to find the file.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| workspace | Directory | - | No description provided |
Example
dagger -m github.com/dagger/dagger-test-modules/workspace-default-path/greeter@572928568658e1146d6bccf63a07914d589ba952 call \
readfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Greeter().
Read(ctx)
}@function
async def example() -> str:
return await (
dag.greeter()
.read()
)@func()
async example(): Promise<string> {
return dag
.greeter()
.read()
}readCheck() 🔗
ReadCheck exposes the same subdirectory access as Read through a
check-annotated function. The production java-sdk-dev regression
surfaces via @check functions (test, lint), so this path must pass
once the bug is fixed.
Return Type
Void !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| workspace | Directory | - | No description provided |
Example
dagger -m github.com/dagger/dagger-test-modules/workspace-default-path/greeter@572928568658e1146d6bccf63a07914d589ba952 call \
read-checkfunc (m *MyModule) Example(ctx context.Context) {
return dag.
Greeter().
ReadCheck(ctx)
}@function
async def example() -> None:
return await (
dag.greeter()
.read_check()
)@func()
async example(): Promise<void> {
return dag
.greeter()
.readCheck()
}workspaceEntries() 🔗
WorkspaceEntries lists the entries at the workspace root after ignore patterns are applied. It’s a sanity check that distinguishes “workspace root doesn’t load” from “walking into a subdirectory fails” — only the latter is the target bug.
Return Type
[String ! ] !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| workspace | Directory | - | No description provided |
Example
dagger -m github.com/dagger/dagger-test-modules/workspace-default-path/greeter@572928568658e1146d6bccf63a07914d589ba952 call \
workspace-entriesfunc (m *MyModule) Example(ctx context.Context) []string {
return dag.
Greeter().
WorkspaceEntries(ctx)
}@function
async def example() -> List[str]:
return await (
dag.greeter()
.workspace_entries()
)@func()
async example(): Promise<string[]> {
return dag
.greeter()
.workspaceEntries()
}