diff --git a/.dagger/modules/e2e/dagger-module.toml b/.dagger/modules/e2e/dagger-module.toml
new file mode 100644
index 0000000..e3a0aaa
--- /dev/null
+++ b/.dagger/modules/e2e/dagger-module.toml
@@ -0,0 +1,9 @@
+name = "e2e"
+engineVersion = "latest"
+
+[runtime]
+ source = "dang"
+
+[[dependencies]]
+ name = "java-sdk"
+ source = "../../.."
diff --git a/.dagger/modules/e2e/fixtures/discover/java-fork/dagger-module.toml b/.dagger/modules/e2e/fixtures/discover/java-fork/dagger-module.toml
new file mode 100644
index 0000000..7bd1c76
--- /dev/null
+++ b/.dagger/modules/e2e/fixtures/discover/java-fork/dagger-module.toml
@@ -0,0 +1,8 @@
+name = "java-fork"
+engineVersion = "latest"
+
+[runtime]
+ source = "github.com/eunomie/dagger/sdk/java@v0.21.4-dev"
+
+[codegen]
+ automaticGitignore = false
diff --git a/.dagger/modules/e2e/fixtures/discover/java-legacy/dagger-module.toml b/.dagger/modules/e2e/fixtures/discover/java-legacy/dagger-module.toml
new file mode 100644
index 0000000..7d8bd29
--- /dev/null
+++ b/.dagger/modules/e2e/fixtures/discover/java-legacy/dagger-module.toml
@@ -0,0 +1,5 @@
+name = "java-legacy"
+engineVersion = "latest"
+
+[runtime]
+ source = "java"
diff --git a/.dagger/modules/e2e/fixtures/discover/java-ref/dagger-module.toml b/.dagger/modules/e2e/fixtures/discover/java-ref/dagger-module.toml
new file mode 100644
index 0000000..d336ccf
--- /dev/null
+++ b/.dagger/modules/e2e/fixtures/discover/java-ref/dagger-module.toml
@@ -0,0 +1,8 @@
+name = "java-ref"
+engineVersion = "latest"
+
+[runtime]
+ source = "github.com/dagger/dagger/sdk/java"
+
+[codegen]
+ automaticGitignore = false
diff --git a/.dagger/modules/e2e/fixtures/discover/java/dagger-module.toml b/.dagger/modules/e2e/fixtures/discover/java/dagger-module.toml
new file mode 100644
index 0000000..b0d92ee
--- /dev/null
+++ b/.dagger/modules/e2e/fixtures/discover/java/dagger-module.toml
@@ -0,0 +1,8 @@
+name = "java"
+engineVersion = "latest"
+
+[runtime]
+ source = "java"
+
+[codegen]
+ automaticGitignore = false
diff --git a/.dagger/modules/e2e/fixtures/discover/not-java/dagger-module.toml b/.dagger/modules/e2e/fixtures/discover/not-java/dagger-module.toml
new file mode 100644
index 0000000..bbb5cdf
--- /dev/null
+++ b/.dagger/modules/e2e/fixtures/discover/not-java/dagger-module.toml
@@ -0,0 +1,8 @@
+name = "not-java"
+engineVersion = "latest"
+
+[runtime]
+ source = "go"
+
+[codegen]
+ automaticGitignore = false
diff --git a/.dagger/modules/e2e/main.dang b/.dagger/modules/e2e/main.dang
new file mode 100644
index 0000000..32ec162
--- /dev/null
+++ b/.dagger/modules/e2e/main.dang
@@ -0,0 +1,69 @@
+"""
+End-to-end checks for the Java SDK helper module.
+"""
+type E2e {
+ let outputRoot: String! = ".dagger/modules/e2e/out"
+
+ """Fail the current check when a condition is false."""
+ let assert(condition: Boolean!, message: String!): Void {
+ if (condition == false) { raise message }
+ null
+ }
+
+ """Return true when a list contains the exact string."""
+ let contains(values: [String!]!, want: String!): Boolean! {
+ values.filter { value => value == want }.length > 0
+ }
+
+ """Assert that a changeset added a path."""
+ let assertAdded(changes: Changeset!, path: String!): Void {
+ assert(contains(changes.addedPaths, path), "expected added path: " + path)
+ }
+
+ """Assert that a string contains a substring."""
+ let assertContains(value: String!, want: String!, message: String!): Void {
+ assert(value.contains(want), message)
+ }
+
+ """
+ init should scaffold a new-style module: builtin "java" SDK, generated files
+ checked in and codegen skipped at runtime (both from automaticGitignore=false),
+ and a two-pass pom defaulting dagger.proc=none.
+ """
+ pub initCheck(ws: Workspace!): Void @check {
+ let p = outputRoot + "/init-default"
+ let changes = javaSdk.init(ws, name: "init-default", path: p)
+
+ assertAdded(changes, p + "/dagger.json")
+ assertAdded(changes, p + "/pom.xml")
+
+ let cfg = changes.layer.file(p + "/dagger.json").contents
+ assertContains(cfg, "\"source\": \"java\"", "init should use the builtin java SDK")
+ assertContains(cfg, "\"automaticGitignore\": false", "init should check in generated files and disable codegen at runtime")
+
+ let pom = changes.layer.file(p + "/pom.xml").contents
+ assertContains(pom, "none", "pom should default dagger.proc to none")
+
+ null
+ }
+
+ """
+ modules discovery should recognise the Java SDK in any source form — the
+ builtin "java", a "github.com/dagger/dagger/sdk/java" ref, and a fork ref like
+ "github.com/eunomie/dagger/sdk/java@..." — while excluding legacy java modules
+ (no automaticGitignore=false) and non-java modules. This is what lets the
+ helper work against dev/fork engines, where "java" is resolved to a git ref.
+ """
+ pub modulesDiscoveryCheck(ws: Workspace!): Void @check {
+ let base = ".dagger/modules/e2e/fixtures/discover"
+ let found = javaSdk.modules(ws)
+
+ assert(contains(found, base + "/java"), "should discover the builtin \"java\" SDK source")
+ assert(contains(found, base + "/java-ref"), "should discover the github.com/dagger/dagger/sdk/java source")
+ assert(contains(found, base + "/java-fork"), "should discover a fork .../sdk/java@[ source")
+ assert(contains(found, base + "/java-legacy") == false, "legacy java module (no automaticGitignore=false) must be excluded")
+ assert(contains(found, base + "/not-java") == false, "non-java module must be excluded")
+
+ null
+ }
+}
diff --git a/.dagger/modules/packager/dagger-module.toml b/.dagger/modules/packager/dagger-module.toml
new file mode 100644
index 0000000..41d053d
--- /dev/null
+++ b/.dagger/modules/packager/dagger-module.toml
@@ -0,0 +1,9 @@
+name = "packager"
+engineVersion = "v1.0.0-0"
+
+[runtime]
+ source = "dang"
+
+[[dependencies]]
+ name = "polyfill"
+ source = "github.com/dagger/sdk-sdk/polyfill"
diff --git a/.dagger/modules/packager/main.dang b/.dagger/modules/packager/main.dang
new file mode 100644
index 0000000..d13ecce
--- /dev/null
+++ b/.dagger/modules/packager/main.dang
@@ -0,0 +1,46 @@
+"""
+Pre-build committable build assets for the Java SDK.
+
+Some assets are expensive to rebuild from source on every `dagger generate`: the
+Dagger codegen Maven plugin in particular costs ~10s to compile and assemble each
+time. `generate` builds those assets once and writes them under `prebuilt/` so
+they can be checked in; the SDK then installs the committed jar instead of
+recompiling the plugin. Run this explicitly (`dagger generate packager`) to
+refresh the assets when the SDK sources that produce them change.
+"""
+type Packager {
+ """Maven container used to build the assets (pinned digest, matches the SDK)."""
+ let mvn: Container! {
+ container.from("maven:3.9.9-eclipse-temurin-21-alpine@sha256:4cbb8bf76c46b97e028998f2486ed014759a8e932480431039bdb93dffe6813e")
+ }
+
+ """The vendored Java SDK Maven reactor, read from the workspace root."""
+ let sdkSource(ws: Workspace!): Directory! {
+ ws.directory("/", include: ["sdk/**"]).directory("sdk")
+ }
+
+ """
+ Build the Dagger codegen Maven plugin and return a directory holding the
+ packaged jar under a stable, version-independent name.
+ """
+ let codegenPluginJar(ws: Workspace!): Directory! {
+ mvn
+ .withoutEntrypoint
+ .withMountedCache("/root/.m2", cacheVolume("sdk-java-maven-m2"))
+ .withDirectory("/dagger-io", sdkSource(ws))
+ .withWorkdir("/dagger-io")
+ .withExec(["mvn", "--projects", "dagger-codegen-maven-plugin", "--also-make", "package", "-T1C", "-Dmaven.test.skip=true", "-Dfmt.skip=true", "--no-transfer-progress"])
+ .withExec(["sh", "-c", "mkdir -p /out && cp dagger-codegen-maven-plugin/target/dagger-codegen-maven-plugin-*.jar /out/dagger-codegen-maven-plugin.jar"])
+ .directory("/out")
+ }
+
+ """
+ Build all committable assets and write them under `prebuilt/` at the workspace
+ root (runs at `dagger generate`).
+ """
+ pub generate(ws: Workspace!): Changeset! @generate {
+ polyfill.workspace(ws).fork
+ .withDirectory("prebuilt", codegenPluginJar(ws))
+ .changes
+ }
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b677c60
--- /dev/null
+++ b/README.md
@@ -0,0 +1,70 @@
+# Dagger Java SDK
+
+The user experience for authoring Dagger modules in Java.
+
+Modules created with this tool use a **self-contained** layout: the Dagger Java
+SDK is vendored into the module as real, buildable source, all generated files
+are committed to version control, and **no code generation runs at module load
+time** — the runtime just builds and packages the module.
+
+> This repository owns both halves of the Java SDK. The root Dang module
+> (`main.dang` / `mod.dang`) owns code generation and scaffolding, and runs at
+> `dagger generate` time. The module *runtime* (the SDK contract: building and
+> packaging Java modules) is the build/package-only Go module under `runtime/`;
+> new modules reference it as `github.com/dagger/java-sdk/runtime`.
+
+## Install
+
+```sh
+dagger workspace install github.com/dagger/java-sdk
+```
+
+## Create a module
+
+```sh
+dagger call java-sdk init --name=my-module
+dagger generate
+```
+
+`init` scaffolds a new module:
+
+```
+/
+ dagger.json # sdk.source=java; codegen.automaticGitignore=false
+ pom.xml # two-pass build; dagger.proc defaults to "none"
+ src/main/java/io/dagger/modules//.java
+ src/main/java/io/dagger/modules//package-info.java
+```
+
+`dagger generate` (or `dagger call java-sdk generate --path=`) fills in
+the generated, committed sources:
+
+```
+ src/generated/java/io/dagger/gen/entrypoint/Entrypoint.java # generated entrypoint
+ sdk/src/main/java/... # vendored SDK library
+ sdk/src/processor/java/... # vendored annotation processor
+ sdk/src/generated/java/... # client bindings (from the engine schema)
+```
+
+Because everything is committed and the pom defaults `dagger.proc=none`, the
+module builds with a plain `mvn package` (no annotation processor at build time)
+— in an IDE or CI, without Dagger.
+
+## How generation works
+
+`generate` runs Maven in containers it controls: it builds the vendored codegen
+plugin, generates the client bindings from the engine's introspection schema,
+vendors the SDK library and annotation processor as source, and runs the
+processor once to produce the entrypoint. It does not delegate code generation
+back to the engine.
+
+## The codegen flag
+
+`init` sets, in the module's `dagger.json`:
+
+- `codegen.automaticGitignore: false`
+
+This single flag carries two meanings: the generated files are committed (not
+git-ignored), and — because the committed files can be trusted — the builtin
+runtime skips codegen at module load and only builds/packages the committed
+sources.
diff --git a/dagger-module.toml b/dagger-module.toml
new file mode 100644
index 0000000..8b57fcb
--- /dev/null
+++ b/dagger-module.toml
@@ -0,0 +1,10 @@
+name = "java-sdk"
+engineVersion = "v1.0.0-0"
+
+[runtime]
+ source = "dang"
+
+[[dependencies]]
+ name = "polyfill"
+ source = "github.com/dagger/sdk-sdk/polyfill@main"
+ pin = "a16466390cacd68bd72f7ae9910d990966fb2226"
diff --git a/dagger.lock b/dagger.lock
new file mode 100644
index 0000000..23a6613
--- /dev/null
+++ b/dagger.lock
@@ -0,0 +1,4 @@
+[["version","1"]]
+["","git.head",["https://github.com/dagger/dang-sdk"],"6c63cd08652f87c903f3b6fbc5e2fc26505b067a","float"]
+["","git.head",["https://github.com/dagger/go"],"5683fb4f7e2e909a453eba727fb982077d5d11b5","float"]
+["","git.head",["https://github.com/dagger/go-sdk"],"0d7261b1f889a28a12e9ad8cbbca1e5fe9747f68","float"]
\ No newline at end of file
diff --git a/dagger.toml b/dagger.toml
new file mode 100644
index 0000000..0dc8a84
--- /dev/null
+++ b/dagger.toml
@@ -0,0 +1,46 @@
+[modules.go]
+source = "github.com/dagger/go"
+
+# Go version used for the default Go base image.
+# settings.version = ""
+# Base image used for Go test, generate, and helper containers.
+# settings.base = "alpine:latest"
+# Extra workspace-root include patterns mounted for each module's Go commands.
+# settings.includeExtraFiles = [""]
+# Module roots to lint. A bare pattern selects, a "!"-prefixed pattern
+# settings.lint = [""]
+# Module roots to test. Same selection rules as `lint`.
+# settings.test = [""]
+# Module roots to run go generate in. Same selection rules as `lint`.
+# settings.generate = [""]
+
+[modules.dagger-go-sdk]
+source = "github.com/dagger/go-sdk"
+
+# Marker filename that skips generate when found at or above a Go SDK module root.
+# settings.skipGenerateFilename = ""
+
+[modules.dagger-go-sdk.as-sdk]
+name = "go"
+
+[[modules.dagger-go-sdk.as-sdk.modules]]
+path = "./runtime"
+
+
+[modules.dagger-dang-sdk]
+source = "github.com/dagger/dang-sdk"
+
+# Marker filename that skips generate when found at or above a Dang SDK module root.
+# settings.skipGenerateFilename = ""
+
+[modules.dagger-dang-sdk.as-sdk]
+name = "dang"
+
+[[modules.dagger-dang-sdk.as-sdk.modules]]
+path = "."
+
+[[modules.dagger-dang-sdk.as-sdk.modules]]
+path = ".dagger/modules/packager"
+
+[modules.packager]
+source = ".dagger/modules/packager"
diff --git a/main.dang b/main.dang
index 3e0d79b..c7ed4ba 100644
--- a/main.dang
+++ b/main.dang
@@ -1,227 +1,73 @@
"""
-SDK helper module skeleton generated by sdk-sdk.
+Manage Dagger modules that use the Java SDK (new self-contained code organisation).
+
+Modules created by `init` use the self-contained layout: the Java SDK is vendored
+as source and code is generated into the module (see `generate`), and the module
+runtime is this repository's build/package-only runtime
+(`github.com/dagger/java-sdk/runtime`). Because the generated files are committed,
+the runtime skips codegen at module load and just builds and packages the
+committed sources.
"""
type JavaSdk {
"""
- Stage a new runtime module.
+ Runtime source written into the dagger-module.toml of new Java modules.
"""
- pub init(
- ws: Workspace!,
- name: String!,
- path: String! = "",
- template: String! = "",
- ignoreGenerated: Boolean! = false,
- ): Changeset! {
- let modulePath = if (path == "") {
- defaultModulePath(ws, name)
- } else {
- cleanModulePath(path)
- }
- let configPath = if (modulePath == ".") { "dagger.json" } else { modulePath + "/dagger.json" }
- let fork = polyfill.workspace(ws).fork
-
- if (ws.directory("/", include: [configPath]).exists(configPath)) {
- raise "module already exists: " + modulePath
- }
-
- fork
- .withNewFile(configPath, initConfig(name, template, ignoreGenerated))
- .changes
- }
-
- """
- Return a module handle.
-
- When `findUp` is true, `path` may point inside the module.
- """
- pub mod(ws: Workspace!, path: String! = ".", findUp: Boolean! = true): JavaSdkModule! {
- let modulePath = if (findUp) {
- let foundConfigPath = ws.findUp("dagger.json", path)
- if (foundConfigPath == null) {
- raise "no Dagger module found containing path: " + path
- } else {
- modulePathForConfig(foundConfigPath.trimPrefix("/"))
- }
- } else {
- cleanModulePath(path)
- }
-
- JavaSdkModule(
- ws: ws,
- modulePath: modulePath,
- moduleSourcePath: if (findUp) { "/" + modulePath } else { modulePath },
- )
- }
-
- """
- Return the default new module path for `init`.
- """
- let defaultModulePath(ws: Workspace!, name: String!): String! {
- let daggerDir = ws.findUp(".dagger", ".")
- if (daggerDir == null) {
- ".dagger/modules/" + name
- } else {
- daggerDir.trimPrefix("/") + "/modules/" + name
- }
- }
+ pub targetRuntime: String! { "github.com/dagger/java-sdk/runtime" }
"""
- Return the module path for a dagger.json path.
+ Marker filename that skips generate when found at or above a Java SDK module root.
"""
- let modulePathForConfig(configPath: String!): String! {
- if (configPath == "dagger.json") {
- "."
- } else {
- configPath.trimSuffix("/dagger.json")
- }
- }
+ pub skipGenerateFilename: String! = ".dagger-java-sdk-skip-generate"
"""
- Return a valid module path relative to the workspace.
+ Initialize Java-owned files for a new Dagger module.
"""
- let cleanModulePath(path: String!): String! {
+ pub initModule(
+ ws: Workspace!,
+ name: String!,
+ path: String!,
+ ): Changeset! {
let rawPath = path.trimPrefix("./").trimPrefix("/")
-
- if (rawPath == "" or rawPath == ".") {
+ let modPath = if (rawPath == "" or rawPath == ".") {
"."
- } else if (
- rawPath == ".."
- or rawPath.trimPrefix("../") != rawPath
- or rawPath.contains("/../")
- or rawPath.trimSuffix("/..") != rawPath
- ) {
+ } else if (rawPath == ".." or rawPath.trimPrefix("../") != rawPath) {
raise "path escapes workspace: " + rawPath
} else {
rawPath.trimSuffix("/")
}
- }
- """
- Return the initial dagger.json for a new runtime module.
- """
- let initConfig(name: String!, template: String!, ignoreGenerated: Boolean!): String! {
- raise "TODO: implement SDK-specific init config and template selection"
+ polyfill.workspace(ws).fork.withDirectory(modPath, renderedTemplate(name, "default")).changes
}
-}
-
-"""
-SDK module handle skeleton.
-"""
-type JavaSdkModule {
- let ws: Workspace!
- let modulePath: String!
- let moduleSourcePath: String!
"""
- Module path relative to the current workspace.
+ Render a Java init template, substituting the requested module name.
"""
- pub path: String! {
- modulePath
+ let renderedTemplate(name: String!, template: String!): Directory! {
+ container
+ .from("golang:1.25-alpine")
+ .withoutEntrypoint
+ .withMountedCache("/go/pkg/mod", cacheVolume("go-mod"))
+ .withMountedCache("/root/.cache/go-build", cacheVolume("go-build"))
+ .withDirectory(
+ "/helper",
+ currentModule.source.directory("helpers/render-java-template"),
+ )
+ .withDirectory("/template", currentModule.source.directory("templates/" + template))
+ .withWorkdir("/helper")
+ .withExec(["go", "build", "-o", "/usr/local/bin/render-java-template", "."])
+ .withExec(["render-java-template", name, "/template", "/rendered"])
+ .directory("/rendered")
}
"""
- Return the module dependency manager.
+ Generate all discovered new-style Java SDK modules (runs at `dagger generate`).
"""
- pub dependencies: JavaSdkDependencies! {
- JavaSdkDependencies(
- ws: ws,
- moduleSourcePath: moduleSourcePath,
+ pub generateAll(ws: Workspace!): Changeset! @generate {
+ changeset.withChangesets(
+ currentModule.asSDK.modules.{{path}}
+ .map { m => Mod(path: m.path, ws: ws, skipGenerateFilename: skipGenerateFilename) }
+ .filter { mod => mod.skipGenerate(ws) == false }
+ .map { mod => mod.generate(ws) },
)
}
-
- """
- Manage this module's required Dagger engine version.
- """
- pub engine: JavaSdkEngine! {
- JavaSdkEngine(
- ws: ws,
- moduleSourcePath: moduleSourcePath,
- )
- }
-}
-
-"""
-SDK dependency manager skeleton.
-"""
-type JavaSdkDependencies {
- let ws: Workspace!
- let moduleSourcePath: String!
-
- """
- Return configured dependency names.
- """
- pub list: [String!]! {
- moduleSource.config.dependencies
- }
-
- """
- Stage a dependency in dagger.json.
- """
- pub add(source: String!, name: String! = ""): Changeset! {
- moduleSource.config.withDependency(source, name).fork.changes
- }
-
- """
- Remove a dependency from dagger.json by name or source.
- """
- pub remove(name: String!): Changeset! {
- moduleSource.config.withoutDependency(name).fork.changes
- }
-
- """
- Update one dependency by name or source, or all remote dependencies.
- """
- pub update(name: String! = ""): Changeset! {
- moduleSource.config.withUpdatedDependencies(name).fork.changes
- }
-
- """
- Source of the module whose dependencies are managed.
- """
- let moduleSource: PolyfillModuleSource! {
- polyfill.workspace(ws).moduleSource(moduleSourcePath)
- }
-}
-
-"""
-SDK engine manager skeleton.
-"""
-type JavaSdkEngine {
- let ws: Workspace!
- let moduleSourcePath: String!
-
- """
- The configured Dagger engine version, without a leading "v".
- """
- pub required: String! {
- moduleSource.config.requiredEngineVersion
- }
-
- """
- Configure this module to require the given Dagger engine version.
- """
- pub require(version: String!): Changeset! {
- moduleSource.config.withRequiredEngineVersion(version).fork.changes
- }
-
- """
- Configure this module to require the current Dagger engine version.
- """
- pub requireCurrent: Changeset! {
- moduleSource.config.withCurrentEngineVersion.fork.changes
- }
-
- """
- Configure this module to require the latest stable Dagger engine version.
- """
- pub requireLatest: Changeset! {
- moduleSource.config.withLatestEngineVersion.fork.changes
- }
-
- """
- Source of the module whose engine version is managed.
- """
- let moduleSource: PolyfillModuleSource! {
- polyfill.workspace(ws).moduleSource(moduleSourcePath)
- }
}
diff --git a/mod.dang b/mod.dang
new file mode 100644
index 0000000..a6c3579
--- /dev/null
+++ b/mod.dang
@@ -0,0 +1,200 @@
+"""
+A Dagger module that uses the Java SDK.
+"""
+type Mod {
+ """
+ Workspace-relative path of this module root.
+ """
+ pub path: String!
+
+ """
+ Workspace containing this module.
+ """
+ let ws: Workspace!
+
+ """
+ Marker filename that skips generate when found at or above this module root.
+ """
+ let skipGenerateFilename: String!
+
+ """
+ Whether this module or an ancestor contains the configured generate skip marker.
+ """
+ pub skipGenerate(ws: Workspace!): Boolean! {
+ hasMarker(ws, skipGenerateFilename)
+ }
+
+ """
+ Whether this module root or an ancestor containes a marker filename.
+ """
+ let hasMarker(ws: Workspace!, filename: String!): Boolean! {
+ let markerPath = ws.findUp(name: filename, from: path)
+ markerPath != null
+ }
+
+ """
+ Generate this module.
+ If the generate skip marker is present, the changeset is empty.
+ """
+ pub generate(ws: Workspace!): Changeset! {
+ if (skipGenerate(ws)) {
+ polyfill.workspace(ws).fork.changes
+ } else {
+ generateModule(ws, path).changes
+ }
+ }
+
+ """
+ Maven container used for codegen (pinned digest, matches the builtin runtime).
+ """
+ let mvn: Container! {
+ container.from("maven:3.9.9-eclipse-temurin-21-alpine@sha256:4cbb8bf76c46b97e028998f2486ed014759a8e932480431039bdb93dffe6813e")
+ }
+
+ """
+ The vendored Java SDK Maven reactor shipped with this module.
+ """
+ let sdkSourceDir: Directory! { currentModule.source.directory("sdk") }
+
+ """
+ Vendor the Java SDK as buildable source for a module:
+ src/main/java the hand-written SDK library
+ src/processor/java the annotation processor that generates the entrypoint
+ src/generated/java the client bindings generated from the engine schema
+ src/processor/resources/META-INF/services/...Processor
+ The returned directory is dropped at /sdk.
+ """
+ let prebuiltCodegenPlugin: String! { "prebuilt/dagger-codegen-maven-plugin.jar" }
+
+ """
+ A maven container with the codegen plugin available in the local repository.
+
+ When the prebuilt plugin jar has been committed (see the packager module), it
+ is installed directly — skipping the ~10s compile of the plugin from source.
+ Otherwise the plugin is built from the vendored sources as a fallback.
+ """
+ let codegenBase(introspectionJSON: File!): Container! {
+ let base = mvn
+ .withoutEntrypoint
+ .withMountedCache("/root/.m2", cacheVolume("sdk-java-maven-m2"))
+ .withMountedFile("/schema.json", introspectionJSON)
+ .withDirectory("/dagger-io", sdkSourceDir)
+ .withWorkdir("/dagger-io")
+
+ if (currentModule.source.exists(prebuiltCodegenPlugin)) {
+ base
+ .withMountedFile("/codegen-plugin.jar", currentModule.source.file(prebuiltCodegenPlugin))
+ .withExec(["mvn", "install:install-file", "-Dfile=/dagger-io/pom.xml", "-Dpackaging=pom", "-DpomFile=/dagger-io/pom.xml", "--no-transfer-progress"])
+ .withExec(["mvn", "install:install-file", "-Dfile=/codegen-plugin.jar", "-DpomFile=/dagger-io/dagger-codegen-maven-plugin/pom.xml", "--no-transfer-progress"])
+ } else {
+ base.withExec(["mvn", "--projects", "dagger-codegen-maven-plugin", "--also-make", "install", "-T1C", "-Dmaven.test.skip=true", "-Dfmt.skip=true", "--no-transfer-progress"])
+ }
+ }
+
+ let vendoredSdk(introspectionJSON: File!): Directory! {
+ let built = codegenBase(introspectionJSON)
+ .withExec(["mvn", "--projects", "dagger-java-sdk", "generate-sources", "-Ddaggerengine.schema=/schema.json", "-Dfmt.skip=true", "--no-transfer-progress"])
+
+ directory
+ .withDirectory("src/main/java", built.directory("/dagger-io/dagger-java-sdk/src/main/java"))
+ .withDirectory(
+ "src/processor/java",
+ built.directory("/dagger-io/dagger-java-annotation-processor/src/main/java"),
+ )
+ .withDirectory(
+ "src/generated/java",
+ built.directory("/dagger-io/dagger-java-sdk/target/generated-sources/dagger"),
+ )
+ .withNewFile(
+ "src/processor/resources/META-INF/services/javax.annotation.processing.Processor",
+ "io.dagger.annotation.processor.DaggerModuleAnnotationProcessor\n",
+ )
+ }
+
+ """
+ Compile the module with the annotation processor enabled (proc=full) so it
+ emits io.dagger.gen.entrypoint.Entrypoint, and return the generated-sources
+ directory (the entrypoint) for vendoring under /src/generated/java.
+ """
+ let generatedEntrypoint(moduleDir: Directory!, name: String!): Directory! {
+ mvn
+ .withoutEntrypoint
+ .withMountedCache("/root/.m2", cacheVolume("sdk-java-maven-m2"))
+ .withDirectory("/module", moduleDir)
+ .withWorkdir("/module")
+ .withEnvVariable("_DAGGER_JAVA_SDK_MODULE_NAME", name)
+ .withExec(["mvn", "compile", "-Ddagger.proc=full", "--no-transfer-progress"])
+ .directory("/module/target/generated-sources/annotations")
+ }
+
+ """
+ Stage the vendored SDK + generated entrypoint for one module.
+ """
+ let generateModule(ws: Workspace!, modPathArg: String!): PolyfillWorkspaceFork! {
+ let pws = polyfill.workspace(ws)
+ let modSource = pws.moduleSource(modPathArg)
+ let name = modSource.core.moduleName
+ let vendored = vendoredSdk(modSource.core.introspectionSchemaJSON)
+
+ # the module as committed, with the freshly vendored SDK overlaid and any
+ # stale generated entrypoint dropped, so the processor regenerates it
+ let baseDir = moduleDir(ws, modPathArg)
+ .withoutDirectory("sdk/src")
+ .withDirectory("sdk", vendored)
+ .withoutDirectory("src/generated")
+ let entrypoint = generatedEntrypoint(baseDir, name)
+
+ pws
+ .fork
+ .withDirectory(joinPath(modPathArg, "sdk"), vendored)
+ .withDirectory(joinPath(modPathArg, "src/generated/java"), entrypoint)
+ }
+
+ """
+ The module's committed source directory, workspace-rooted.
+ """
+ let moduleDir(ws: Workspace!, modPathArg: String!): Directory! {
+ if (modPathArg == ".") {
+ ws.directory("/", include: ["**"])
+ } else {
+ ws.directory("/", include: [modPathArg + "/**"]).directory(modPathArg)
+ }
+ }
+
+ """
+ Join a module path with a sub-path, handling the root (".") module.
+ """
+ let joinPath(modPathArg: String!, sub: String!): String! {
+ if (modPathArg == ".") { sub } else { modPathArg + "/" + sub }
+ }
+
+ """
+ Return the default new module path for `init`.
+ """
+ let defaultModulePath(ws: Workspace!, name: String!): String! {
+ let daggerDir = ws.findUp(".dagger", ".")
+ if (daggerDir == null) {
+ ".dagger/modules/" + name
+ } else {
+ daggerDir.trimPrefix("/") + "/modules/" + name
+ }
+ }
+
+ """
+ Return a valid module path relative to the workspace.
+ """
+ let cleanModulePath(path: String!): String! {
+ let rawPath = path.trimPrefix("./").trimPrefix("/")
+
+ if (rawPath == "" or rawPath == ".") {
+ "."
+ } else if (rawPath == ".."
+ or rawPath.trimPrefix("../") != rawPath
+ or rawPath.contains("/../")
+ or rawPath.trimSuffix("/..") != rawPath) {
+ raise "path escapes workspace: " + rawPath
+ } else {
+ rawPath.trimSuffix("/")
+ }
+ }
+}
diff --git a/prebuilt/dagger-codegen-maven-plugin.jar b/prebuilt/dagger-codegen-maven-plugin.jar
new file mode 100644
index 0000000..042e71e
Binary files /dev/null and b/prebuilt/dagger-codegen-maven-plugin.jar differ
diff --git a/runtime/.gitattributes b/runtime/.gitattributes
new file mode 100644
index 0000000..d3384f5
--- /dev/null
+++ b/runtime/.gitattributes
@@ -0,0 +1,3 @@
+/dagger.gen.go linguist-generated
+/internal/dagger/** linguist-generated
+/internal/telemetry/** linguist-generated
diff --git a/runtime/.gitignore b/runtime/.gitignore
new file mode 100644
index 0000000..f10862a
--- /dev/null
+++ b/runtime/.gitignore
@@ -0,0 +1 @@
+/.env
diff --git a/runtime/README.md b/runtime/README.md
new file mode 100644
index 0000000..d6308d4
--- /dev/null
+++ b/runtime/README.md
@@ -0,0 +1,30 @@
+# Java SDK runtime (build/package-only)
+
+This is the Java module runtime, relocated from `dagger/dagger`'s
+`sdk/java/runtime` with code generation removed. New Java modules reference it as
+their runtime (`github.com/dagger/java-sdk/runtime`); the root Dang module
+(`main.dang`) sets it via `targetRuntime`.
+
+## What it does
+
+It only **fetches dependencies, builds, and packages** a Java module from its
+committed sources — it does not generate code.
+
+`ModuleRuntime` mounts the module, runs `mvn clean package -DskipTests`, and
+returns a JRE container that runs the resulting jar. New-style modules are
+self-contained: the Java SDK is vendored as source under `/sdk/` and the
+entrypoint is committed under `/src/generated/java`, so a plain
+`mvn package` (the module pom defaults `dagger.proc=none`) compiles them together
+and only downloads third-party dependencies.
+
+## What owns code generation instead
+
+Code generation lives in this repository's root Dang module (`main.dang` /
+`mod.dang`) and runs at `dagger generate` time. New-style modules commit the
+generated files, so the engine skips codegen at module load — this runtime never
+regenerates them.
+
+`Codegen` here is an intentional no-op (returns the module source unchanged): the
+SDK runtime contract still includes it, but generation is owned by `generate`.
+The committed `dagger.gen.go` must be regenerated (`dagger develop`) whenever the
+runtime's own Go API changes.
diff --git a/runtime/dagger-module.toml b/runtime/dagger-module.toml
new file mode 100644
index 0000000..be78fca
--- /dev/null
+++ b/runtime/dagger-module.toml
@@ -0,0 +1,5 @@
+name = "java-sdk-runtime"
+engineVersion = "v1.0.0-0"
+
+[runtime]
+ source = "go"
diff --git a/runtime/dagger.gen.go b/runtime/dagger.gen.go
new file mode 100644
index 0000000..2a083a9
--- /dev/null
+++ b/runtime/dagger.gen.go
@@ -0,0 +1,306 @@
+// Code generated by dagger. DO NOT EDIT.
+
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "log/slog"
+ "os"
+ "sort"
+
+ telemetry "github.com/dagger/otel-go"
+ "github.com/vektah/gqlparser/v2/gqlerror"
+ "go.opentelemetry.io/otel"
+ "go.opentelemetry.io/otel/sdk/resource"
+ semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
+ "go.opentelemetry.io/otel/trace"
+
+ "java-sdk-runtime/internal/dagger"
+
+ "github.com/dagger/querybuilder"
+)
+
+var dag = dagger.Connect()
+
+func Tracer() trace.Tracer {
+ return otel.Tracer("dagger.io/sdk.go")
+}
+
+// used for local MarshalJSON implementations
+var marshalCtx = context.Background()
+
+// called by main()
+func setMarshalContext(ctx context.Context) {
+ marshalCtx = ctx
+ dagger.SetMarshalContext(ctx)
+}
+
+type DaggerObject interface {
+ querybuilder.GraphQLMarshaller
+ ID(ctx context.Context) (dagger.ID, error)
+}
+
+type ExecError = dagger.ExecError
+
+// ptr returns a pointer to the given value.
+func ptr[T any](v T) *T {
+ return &v
+}
+
+// convertSlice converts a slice of one type to a slice of another type using a
+// converter function
+func convertSlice[I any, O any](in []I, f func(I) O) []O {
+ out := make([]O, len(in))
+ for i, v := range in {
+ out[i] = f(v)
+ }
+ return out
+}
+
+func (r JavaSdkRuntime) MarshalJSON() ([]byte, error) {
+ var concrete struct {
+ SDKSourceDir *dagger.Directory
+ MavenErrors bool
+ MavenDebugLogging bool
+ }
+ concrete.SDKSourceDir = r.SDKSourceDir
+ concrete.MavenErrors = r.MavenErrors
+ concrete.MavenDebugLogging = r.MavenDebugLogging
+ return json.Marshal(&concrete)
+}
+
+func (r *JavaSdkRuntime) UnmarshalJSON(bs []byte) error {
+ var concrete struct {
+ SDKSourceDir *dagger.Directory
+ MavenErrors bool
+ MavenDebugLogging bool
+ }
+ err := json.Unmarshal(bs, &concrete)
+ if err != nil {
+ return err
+ }
+ r.SDKSourceDir = concrete.SDKSourceDir
+ r.MavenErrors = concrete.MavenErrors
+ r.MavenDebugLogging = concrete.MavenDebugLogging
+ return nil
+}
+
+func main() {
+ ctx := context.Background()
+
+ // Direct slog to the new stderr. This is only for dev time debugging, and
+ // runtime errors/warnings.
+ slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
+ Level: slog.LevelWarn,
+ })))
+
+ if err := dispatch(ctx); err != nil {
+ os.Exit(2)
+ }
+}
+
+func convertError(rerr error) *dagger.Error {
+ if gqlErr := findSingleGQLError(rerr); gqlErr != nil {
+ dagErr := dag.Error(gqlErr.Message)
+ if gqlErr.Extensions != nil {
+ keys := make([]string, 0, len(gqlErr.Extensions))
+ for k := range gqlErr.Extensions {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+ for _, k := range keys {
+ val, err := json.Marshal(gqlErr.Extensions[k])
+ if err != nil {
+ fmt.Println("failed to marshal error value:", err)
+ }
+ dagErr = dagErr.WithValue(k, dagger.JSON(val))
+ }
+ }
+ return dagErr
+ }
+ return dag.Error(rerr.Error())
+}
+
+func findSingleGQLError(rerr error) *gqlerror.Error {
+ switch x := rerr.(type) {
+ case *gqlerror.Error:
+ return x
+ case interface{ Unwrap() []error }:
+ return nil
+ case interface{ Unwrap() error }:
+ return findSingleGQLError(x.Unwrap())
+ default:
+ return nil
+ }
+}
+func dispatch(ctx context.Context) (rerr error) {
+ ctx = telemetry.InitEmbedded(ctx, resource.NewWithAttributes(
+ semconv.SchemaURL,
+ semconv.ServiceNameKey.String("dagger-go-sdk"),
+ // TODO version?
+ ))
+ defer telemetry.Close()
+
+ // A lot of the "work" actually happens when we're marshalling the return
+ // value, which entails getting object IDs, which happens in MarshalJSON,
+ // which has no ctx argument, so we use this lovely global variable.
+ setMarshalContext(ctx)
+
+ fnCall := dag.CurrentFunctionCall()
+ defer func() {
+ if rerr != nil {
+ if err := fnCall.ReturnError(ctx, convertError(rerr)); err != nil {
+ fmt.Println("failed to return error:", err, "\noriginal error:", rerr)
+ }
+ }
+ }()
+
+ parentName, err := fnCall.ParentName(ctx)
+ if err != nil {
+ return fmt.Errorf("get parent name: %w", err)
+ }
+ fnName, err := fnCall.Name(ctx)
+ if err != nil {
+ return fmt.Errorf("get fn name: %w", err)
+ }
+ parentJson, err := fnCall.Parent(ctx)
+ if err != nil {
+ return fmt.Errorf("get fn parent: %w", err)
+ }
+ fnArgs, err := fnCall.InputArgs(ctx)
+ if err != nil {
+ return fmt.Errorf("get fn args: %w", err)
+ }
+
+ inputArgs := map[string][]byte{}
+ for _, fnArg := range fnArgs {
+ argName, err := fnArg.Name(ctx)
+ if err != nil {
+ return fmt.Errorf("get fn arg name: %w", err)
+ }
+ argValue, err := fnArg.Value(ctx)
+ if err != nil {
+ return fmt.Errorf("get fn arg value: %w", err)
+ }
+ inputArgs[argName] = []byte(argValue)
+ }
+
+ result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs)
+ if err != nil {
+ return err
+ }
+ resultBytes, err := json.Marshal(result)
+ if err != nil {
+ return fmt.Errorf("marshal: %w", err)
+ }
+
+ if err := fnCall.ReturnValue(ctx, dagger.JSON(resultBytes)); err != nil {
+ return fmt.Errorf("store return value: %w", err)
+ }
+ return nil
+}
+func invoke(ctx context.Context, parentJSON []byte, parentName string, fnName string, inputArgs map[string][]byte) (_ any, err error) {
+ _ = inputArgs
+ switch parentName {
+ case "JavaSdkRuntime":
+ switch fnName {
+ case "Codegen":
+ var parent JavaSdkRuntime
+ err = json.Unmarshal(parentJSON, &parent)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
+ }
+ var modSource *dagger.ModuleSource
+ if inputArgs["modSource"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["modSource"]), &modSource)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg modSource", err))
+ }
+ }
+ var introspectionJson *dagger.File
+ if inputArgs["introspectionJSON"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["introspectionJSON"]), &introspectionJson)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg introspectionJSON", err))
+ }
+ }
+ return (*JavaSdkRuntime).Codegen(&parent, ctx, modSource, introspectionJson)
+ case "JavaImage":
+ var parent JavaSdkRuntime
+ err = json.Unmarshal(parentJSON, &parent)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
+ }
+ return (*JavaSdkRuntime).JavaImage(&parent), nil
+ case "MavenImage":
+ var parent JavaSdkRuntime
+ err = json.Unmarshal(parentJSON, &parent)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
+ }
+ return (*JavaSdkRuntime).MavenImage(&parent), nil
+ case "ModuleRuntime":
+ var parent JavaSdkRuntime
+ err = json.Unmarshal(parentJSON, &parent)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
+ }
+ var modSource *dagger.ModuleSource
+ if inputArgs["modSource"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["modSource"]), &modSource)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg modSource", err))
+ }
+ }
+ var introspectionJson *dagger.File
+ if inputArgs["introspectionJSON"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["introspectionJSON"]), &introspectionJson)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg introspectionJSON", err))
+ }
+ }
+ return (*JavaSdkRuntime).ModuleRuntime(&parent, ctx, modSource, introspectionJson)
+ case "WithConfig":
+ var parent JavaSdkRuntime
+ err = json.Unmarshal(parentJSON, &parent)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
+ }
+ var mavenErrors bool
+ if inputArgs["mavenErrors"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["mavenErrors"]), &mavenErrors)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg mavenErrors", err))
+ }
+ }
+ var mavenDebugLogging bool
+ if inputArgs["mavenDebugLogging"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["mavenDebugLogging"]), &mavenDebugLogging)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg mavenDebugLogging", err))
+ }
+ }
+ return (*JavaSdkRuntime).WithConfig(&parent, mavenErrors, mavenDebugLogging), nil
+ case "":
+ var parent JavaSdkRuntime
+ err = json.Unmarshal(parentJSON, &parent)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal parent object", err))
+ }
+ var sdkSourceDir *dagger.Directory
+ if inputArgs["sdkSourceDir"] != nil {
+ err = json.Unmarshal([]byte(inputArgs["sdkSourceDir"]), &sdkSourceDir)
+ if err != nil {
+ panic(fmt.Errorf("%s: %w", "failed to unmarshal input arg sdkSourceDir", err))
+ }
+ }
+ return New(sdkSourceDir)
+ default:
+ return nil, fmt.Errorf("unknown function %s", fnName)
+ }
+ default:
+ return nil, fmt.Errorf("unknown object %s", parentName)
+ }
+}
diff --git a/runtime/go.mod b/runtime/go.mod
new file mode 100644
index 0000000..a319add
--- /dev/null
+++ b/runtime/go.mod
@@ -0,0 +1,56 @@
+module java-sdk-runtime
+
+go 1.26.1
+
+require (
+ github.com/Khan/genqlient v0.8.1
+ github.com/dagger/otel-go v1.41.0
+ github.com/vektah/gqlparser/v2 v2.5.33
+ go.opentelemetry.io/otel v1.44.0
+ go.opentelemetry.io/otel/sdk v1.43.0
+ go.opentelemetry.io/otel/trace v1.44.0
+)
+
+require (
+ github.com/99designs/gqlgen v0.17.90 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.17.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.17.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.41.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.43.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.41.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.41.0 // indirect
+ go.opentelemetry.io/otel/log v0.17.0 // indirect
+ go.opentelemetry.io/otel/metric v1.44.0 // indirect
+ go.opentelemetry.io/otel/sdk/log v0.17.0 // indirect
+ go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
+ go.opentelemetry.io/proto/otlp v1.10.0 // indirect
+ golang.org/x/sync v0.20.0 // indirect
+ google.golang.org/grpc v1.80.0 // indirect
+)
+
+require (
+ github.com/cenkalti/backoff/v5 v5.0.3 // indirect
+ github.com/cespare/xxhash/v2 v2.3.0 // indirect
+ github.com/dagger/querybuilder v0.0.0-20260402040506-574a5e81cb59
+ github.com/go-logr/logr v1.4.3 // indirect
+ github.com/go-logr/stdr v1.2.2 // indirect
+ github.com/google/uuid v1.6.0 // indirect
+ github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
+ github.com/sosodev/duration v1.4.0 // indirect
+ go.opentelemetry.io/auto/sdk v1.2.1 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.41.0 // indirect
+ golang.org/x/net v0.52.0 // indirect
+ golang.org/x/sys v0.45.0 // indirect
+ golang.org/x/text v0.35.0 // indirect
+ google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
+ google.golang.org/protobuf v1.36.11 // indirect
+)
+
+replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.16.0
+
+replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.16.0
+
+replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.16.0
+
+replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.16.0
diff --git a/runtime/go.sum b/runtime/go.sum
new file mode 100644
index 0000000..f768a57
--- /dev/null
+++ b/runtime/go.sum
@@ -0,0 +1,97 @@
+github.com/99designs/gqlgen v0.17.90 h1:wSv6blm/PoplU6QoNw83EcQpNtC0HX3/+44vITJOzpk=
+github.com/99designs/gqlgen v0.17.90/go.mod h1:GqYrEwYsqCG8VaOsq2kJUCUKwAE1T+u2i+Nj7NtXiVI=
+github.com/Khan/genqlient v0.8.1 h1:wtOCc8N9rNynRLXN3k3CnfzheCUNKBcvXmVv5zt6WCs=
+github.com/Khan/genqlient v0.8.1/go.mod h1:R2G6DzjBvCbhjsEajfRjbWdVglSH/73kSivC9TLWVjU=
+github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM=
+github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
+github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
+github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
+github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
+github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
+github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
+github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/dagger/otel-go v1.41.0 h1:GQAJtTM1Ja9Dt/JSSqqjCFVlCye09Ymx4dWUDRqcgKw=
+github.com/dagger/otel-go v1.41.0/go.mod h1:RP74B3xmOq2MWL1lBsAWD9uvTryDhZ+m1dDzJj9QJEI=
+github.com/dagger/querybuilder v0.0.0-20260402040506-574a5e81cb59 h1:g6vfdGRyz6fAjfHz5FyYPZgHy8qcQ31fHrBl1iCOzxw=
+github.com/dagger/querybuilder v0.0.0-20260402040506-574a5e81cb59/go.mod h1:jsdUJeYzcbyK1j/EqMGPrQgNYxl/Zfg06vvM9C/xXxs=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
+github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
+github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
+github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
+github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
+github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs=
+github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
+github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
+github.com/sosodev/duration v1.4.0 h1:35ed0KiVFriGHHzZZJaZLgmTEEICIyt8Sx0RQfj9IjE=
+github.com/sosodev/duration v1.4.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
+github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
+github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+github.com/vektah/gqlparser/v2 v2.5.33 h1:lRp8aIeNUNbimf/axZd7ETg24q06hBtPaas+TcvI/7E=
+github.com/vektah/gqlparser/v2 v2.5.33/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts=
+go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
+go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
+go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
+go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
+go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.16.0 h1:ZVg+kCXxd9LtAaQNKBxAvJ5NpMf7LpvEr4MIZqb0TMQ=
+go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.16.0/go.mod h1:hh0tMeZ75CCXrHd9OXRYxTlCAdxcXioWHFIpYw2rZu8=
+go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.16.0 h1:djrxvDxAe44mJUrKataUbOhCKhR3F8QCyWucO16hTQs=
+go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.16.0/go.mod h1:dt3nxpQEiSoKvfTVxp3TUg5fHPLhKtbcnN3Z1I1ePD0=
+go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.41.0 h1:VO3BL6OZXRQ1yQc8W6EVfJzINeJ35BkiHx4MYfoQf44=
+go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.41.0/go.mod h1:qRDnJ2nv3CQXMK2HUd9K9VtvedsPAce3S+/4LZHjX/s=
+go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.43.0 h1:w1K+pCJoPpQifuVpsKamUdn9U0zM3xUziVOqsGksUrY=
+go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.43.0/go.mod h1:HBy4BjzgVE8139ieRI75oXm3EcDN+6GhD88JT1Kjvxg=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.41.0 h1:ao6Oe+wSebTlQ1OEht7jlYTzQKE+pnx/iNywFvTbuuI=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.41.0/go.mod h1:u3T6vz0gh/NVzgDgiwkgLxpsSF6PaPmo2il0apGJbls=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.41.0 h1:mq/Qcf28TWz719lE3/hMB4KkyDuLJIvgJnFGcd0kEUI=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.41.0/go.mod h1:yk5LXEYhsL2htyDNJbEq7fWzNEigeEdV5xBF/Y+kAv0=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.41.0 h1:inYW9ZhgqiDqh6BioM7DVHHzEGVq76Db5897WLGZ5Go=
+go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.41.0/go.mod h1:Izur+Wt8gClgMJqO/cZ8wdeeMryJ/xxiOVgFSSfpDTY=
+go.opentelemetry.io/otel/log v0.16.0 h1:DeuBPqCi6pQwtCK0pO4fvMB5eBq6sNxEnuTs88pjsN4=
+go.opentelemetry.io/otel/log v0.16.0/go.mod h1:rWsmqNVTLIA8UnwYVOItjyEZDbKIkMxdQunsIhpUMes=
+go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
+go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
+go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
+go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
+go.opentelemetry.io/otel/sdk/log v0.16.0 h1:e/b4bdlQwC5fnGtG3dlXUrNOnP7c8YLVSpSfEBIkTnI=
+go.opentelemetry.io/otel/sdk/log v0.16.0/go.mod h1:JKfP3T6ycy7QEuv3Hj8oKDy7KItrEkus8XJE6EoSzw4=
+go.opentelemetry.io/otel/sdk/log/logtest v0.16.0 h1:/XVkpZ41rVRTP4DfMgYv1nEtNmf65XPPyAdqV90TMy4=
+go.opentelemetry.io/otel/sdk/log/logtest v0.16.0/go.mod h1:iOOPgQr5MY9oac/F5W86mXdeyWZGleIx3uXO98X2R6Y=
+go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
+go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
+go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
+go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
+go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
+go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
+go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
+go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
+golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
+golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
+golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
+golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
+golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
+golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
+golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
+gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
+gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
+google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
+google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
+google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
+google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
+google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
+google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/runtime/images/java/Dockerfile b/runtime/images/java/Dockerfile
new file mode 100644
index 0000000..423d64a
--- /dev/null
+++ b/runtime/images/java/Dockerfile
@@ -0,0 +1 @@
+FROM eclipse-temurin:21-jre-alpine-3.21@sha256:4e9ab608d97796571b1d5bbcd1c9f430a89a5f03fe5aa6c093888ceb6756c502
diff --git a/runtime/images/maven/Dockerfile b/runtime/images/maven/Dockerfile
new file mode 100644
index 0000000..ade94fd
--- /dev/null
+++ b/runtime/images/maven/Dockerfile
@@ -0,0 +1 @@
+FROM maven:3.9.9-eclipse-temurin-21-alpine@sha256:4cbb8bf76c46b97e028998f2486ed014759a8e932480431039bdb93dffe6813e
diff --git a/runtime/internal/dagger/dagger.gen.go b/runtime/internal/dagger/dagger.gen.go
new file mode 100644
index 0000000..b9e60a7
--- /dev/null
+++ b/runtime/internal/dagger/dagger.gen.go
@@ -0,0 +1,18470 @@
+// Code generated by dagger. DO NOT EDIT.
+
+package dagger
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "net"
+ "net/http"
+ "os"
+ "reflect"
+ "strconv"
+
+ "github.com/Khan/genqlient/graphql"
+ "github.com/vektah/gqlparser/v2/gqlerror"
+ "go.opentelemetry.io/otel"
+ "go.opentelemetry.io/otel/propagation"
+ "go.opentelemetry.io/otel/trace"
+
+ "github.com/dagger/querybuilder"
+
+ telemetry "github.com/dagger/otel-go"
+)
+
+func Tracer() trace.Tracer {
+ return otel.Tracer("dagger.io/sdk.go")
+}
+
+// reassigned at runtime after the span is initialized
+var marshalCtx = context.Background()
+
+// SetMarshalContext is a hack that lets us set the ctx to use for
+// MarshalJSON implementations that get an object's ID.
+func SetMarshalContext(ctx context.Context) {
+ marshalCtx = ctx
+}
+
+// assertNotNil panic if the given value is nil.
+// This function is used to validate that input with pointer type are not nil.
+// See https://github.com/dagger/dagger/issues/5696 for more context.
+func assertNotNil(argName string, value any) {
+ // We use reflect because just comparing value to nil is not working since
+ // the value is wrapped into a type when passed as parameter.
+ // E.g., nil become (*dagger.File)(nil).
+ if reflect.ValueOf(value).IsNil() {
+ panic(fmt.Sprintf("unexpected nil pointer for argument %q", argName))
+ }
+}
+
+type DaggerObject interface {
+ querybuilder.GraphQLMarshaller
+ ID(ctx context.Context) (ID, error)
+}
+
+type gqlExtendedError struct {
+ inner *gqlerror.Error
+}
+
+// Same as telemetry.ExtendedError, but without the dependency, to simplify
+// client generation.
+type extendedError interface {
+ error
+ Extensions() map[string]any
+}
+
+func (e gqlExtendedError) Unwrap() error {
+ return e.inner
+}
+
+var _ extendedError = gqlExtendedError{}
+
+func (e gqlExtendedError) Error() string {
+ return e.inner.Message
+}
+
+func (e gqlExtendedError) Extensions() map[string]any {
+ return e.inner.Extensions
+}
+
+// getCustomError parses a GraphQL error into a more specific error type.
+func getCustomError(err error) error {
+ var gqlErr *gqlerror.Error
+ if !errors.As(err, &gqlErr) {
+ return nil
+ }
+
+ ext := gqlErr.Extensions
+
+ lessNoisyErr := gqlExtendedError{gqlErr}
+
+ typ, ok := ext["_type"].(string)
+ if !ok {
+ return lessNoisyErr
+ }
+
+ if typ == "EXEC_ERROR" {
+ e := &ExecError{
+ original: lessNoisyErr,
+ }
+ if code, ok := ext["exitCode"].(float64); ok {
+ e.ExitCode = int(code)
+ }
+ if args, ok := ext["cmd"].([]interface{}); ok {
+ cmd := make([]string, len(args))
+ for i, v := range args {
+ cmd[i] = v.(string)
+ }
+ e.Cmd = cmd
+ }
+ if stdout, ok := ext["stdout"].(string); ok {
+ e.Stdout = stdout
+ }
+ if stderr, ok := ext["stderr"].(string); ok {
+ e.Stderr = stderr
+ }
+ return e
+ }
+
+ return lessNoisyErr
+}
+
+// ExecError is an API error from an exec operation.
+type ExecError struct {
+ original extendedError
+ Cmd []string
+ ExitCode int
+ Stdout string
+ Stderr string
+}
+
+var _ extendedError = (*ExecError)(nil)
+
+func (e *ExecError) Error() string {
+ return e.Message()
+}
+
+func (e *ExecError) Extensions() map[string]any {
+ return e.original.Extensions()
+}
+
+func (e *ExecError) Message() string {
+ return e.original.Error()
+}
+
+func (e *ExecError) Unwrap() error {
+ return e.original
+}
+
+// A unique identifier for an object.
+type ID string
+
+// An arbitrary JSON-encoded value.
+type JSON string
+
+// The platform config OS and architecture in a Container.
+//
+// The format is [os]/[platform]/[version] (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
+type Platform string
+
+// The absence of a value.
+//
+// A Null Void is used as a placeholder for resolvers that do not return anything.
+type Void string
+
+// Key value object that represents a build argument.
+type BuildArg struct {
+ // The build argument name.
+ Name string `json:"name"`
+
+ // The build argument value.
+ Value string `json:"value"`
+}
+
+// Key value object that represents a pipeline label.
+type PipelineLabel struct {
+ // Label name.
+ Name string `json:"name"`
+
+ // Label value.
+ Value string `json:"value"`
+}
+
+// Port forwarding rules for tunneling network traffic.
+type PortForward struct {
+ // Destination port for traffic.
+ Backend int `json:"backend"`
+
+ // Port to expose to clients. If unspecified, a default will be chosen.
+ Frontend int `json:"frontend"`
+
+ // Transport layer protocol to use for traffic.
+ Protocol NetworkProtocol `json:"protocol,omitempty"`
+}
+
+// A standardized address to load containers, directories, secrets, and other object types. Address format depends on the type, and is validated at type selection.
+type Address struct {
+ query *querybuilder.Selection
+
+ id *ID
+ value *string
+}
+
+func (r *Address) WithGraphQLQuery(q *querybuilder.Selection) *Address {
+ return &Address{
+ query: q,
+ }
+}
+
+// Load a container from the address.
+func (r *Address) Container() *Container {
+ q := r.query.Select("container")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// AddressDirectoryOpts contains options for Address.Directory
+type AddressDirectoryOpts struct {
+ Exclude []string
+
+ Include []string
+
+ Gitignore bool
+
+ NoCache bool
+}
+
+// Load a directory from the address.
+func (r *Address) Directory(opts ...AddressDirectoryOpts) *Directory {
+ q := r.query.Select("directory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ // `noCache` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoCache) {
+ q = q.Arg("noCache", opts[i].NoCache)
+ }
+ }
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// AddressFileOpts contains options for Address.File
+type AddressFileOpts struct {
+ Exclude []string
+
+ Include []string
+
+ Gitignore bool
+
+ NoCache bool
+}
+
+// Load a file from the address.
+func (r *Address) File(opts ...AddressFileOpts) *File {
+ q := r.query.Select("file")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ // `noCache` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoCache) {
+ q = q.Arg("noCache", opts[i].NoCache)
+ }
+ }
+
+ return &File{
+ query: q,
+ }
+}
+
+// Load a git ref (branch, tag or commit) from the address.
+func (r *Address) GitRef() *GitRef {
+ q := r.query.Select("gitRef")
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// Load a git repository from the address.
+func (r *Address) GitRepository() *GitRepository {
+ q := r.query.Select("gitRepository")
+
+ return &GitRepository{
+ query: q,
+ }
+}
+
+// A unique identifier for this Address.
+func (r *Address) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Address) XXX_GraphQLType() string {
+ return "Address"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Address) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Address) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Address) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Address) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Address{query: selectNode(dag.query, id, "Address")}
+ return nil
+}
+
+// Load a secret from the address.
+func (r *Address) Secret() *Secret {
+ q := r.query.Select("secret")
+
+ return &Secret{
+ query: q,
+ }
+}
+
+// Load a service from the address.
+func (r *Address) Service() *Service {
+ q := r.query.Select("service")
+
+ return &Service{
+ query: q,
+ }
+}
+
+// Load a local socket from the address.
+func (r *Address) Socket() *Socket {
+ q := r.query.Select("socket")
+
+ return &Socket{
+ query: q,
+ }
+}
+
+// The address value
+func (r *Address) Value(ctx context.Context) (string, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Address as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Address) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type Binding struct {
+ query *querybuilder.Selection
+
+ asString *string
+ digest *string
+ id *ID
+ isNull *bool
+ name *string
+ typeName *string
+}
+
+func (r *Binding) WithGraphQLQuery(q *querybuilder.Selection) *Binding {
+ return &Binding{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Address
+func (r *Binding) AsAddress() *Address {
+ q := r.query.Select("asAddress")
+
+ return &Address{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type CacheVolume
+func (r *Binding) AsCacheVolume() *CacheVolume {
+ q := r.query.Select("asCacheVolume")
+
+ return &CacheVolume{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Changeset
+func (r *Binding) AsChangeset() *Changeset {
+ q := r.query.Select("asChangeset")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Check
+func (r *Binding) AsCheck() *Check {
+ q := r.query.Select("asCheck")
+
+ return &Check{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type CheckGroup
+func (r *Binding) AsCheckGroup() *CheckGroup {
+ q := r.query.Select("asCheckGroup")
+
+ return &CheckGroup{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Cloud
+func (r *Binding) AsCloud() *Cloud {
+ q := r.query.Select("asCloud")
+
+ return &Cloud{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Container
+func (r *Binding) AsContainer() *Container {
+ q := r.query.Select("asContainer")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type CurrentModuleAsSDK
+func (r *Binding) AsCurrentModuleAsSDK() *CurrentModuleAsSDK {
+ q := r.query.Select("asCurrentModuleAsSDK")
+
+ return &CurrentModuleAsSDK{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type CurrentModuleAsSDKClient
+func (r *Binding) AsCurrentModuleAsSDKClient() *CurrentModuleAsSDKClient {
+ q := r.query.Select("asCurrentModuleAsSDKClient")
+
+ return &CurrentModuleAsSDKClient{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type CurrentModuleAsSDKModule
+func (r *Binding) AsCurrentModuleAsSDKModule() *CurrentModuleAsSDKModule {
+ q := r.query.Select("asCurrentModuleAsSDKModule")
+
+ return &CurrentModuleAsSDKModule{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type DiffStat
+func (r *Binding) AsDiffStat() *DiffStat {
+ q := r.query.Select("asDiffStat")
+
+ return &DiffStat{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Directory
+func (r *Binding) AsDirectory() *Directory {
+ q := r.query.Select("asDirectory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Env
+func (r *Binding) AsEnv() *Env {
+ q := r.query.Select("asEnv")
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type EnvFile
+func (r *Binding) AsEnvFile() *EnvFile {
+ q := r.query.Select("asEnvFile")
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type File
+func (r *Binding) AsFile() *File {
+ q := r.query.Select("asFile")
+
+ return &File{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Generator
+func (r *Binding) AsGenerator() *Generator {
+ q := r.query.Select("asGenerator")
+
+ return &Generator{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type GeneratorGroup
+func (r *Binding) AsGeneratorGroup() *GeneratorGroup {
+ q := r.query.Select("asGeneratorGroup")
+
+ return &GeneratorGroup{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type GitRef
+func (r *Binding) AsGitRef() *GitRef {
+ q := r.query.Select("asGitRef")
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type GitRepository
+func (r *Binding) AsGitRepository() *GitRepository {
+ q := r.query.Select("asGitRepository")
+
+ return &GitRepository{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type HTTPState
+func (r *Binding) AsHTTPState() *HTTPState {
+ q := r.query.Select("asHTTPState")
+
+ return &HTTPState{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type JSONValue
+func (r *Binding) AsJSONValue() *JSONValue {
+ q := r.query.Select("asJSONValue")
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Module
+func (r *Binding) AsModule() *Module {
+ q := r.query.Select("asModule")
+
+ return &Module{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type ModuleConfigClient
+func (r *Binding) AsModuleConfigClient() *ModuleConfigClient {
+ q := r.query.Select("asModuleConfigClient")
+
+ return &ModuleConfigClient{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type ModuleSource
+func (r *Binding) AsModuleSource() *ModuleSource {
+ q := r.query.Select("asModuleSource")
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type SearchResult
+func (r *Binding) AsSearchResult() *SearchResult {
+ q := r.query.Select("asSearchResult")
+
+ return &SearchResult{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type SearchSubmatch
+func (r *Binding) AsSearchSubmatch() *SearchSubmatch {
+ q := r.query.Select("asSearchSubmatch")
+
+ return &SearchSubmatch{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Secret
+func (r *Binding) AsSecret() *Secret {
+ q := r.query.Select("asSecret")
+
+ return &Secret{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Service
+func (r *Binding) AsService() *Service {
+ q := r.query.Select("asService")
+
+ return &Service{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Socket
+func (r *Binding) AsSocket() *Socket {
+ q := r.query.Select("asSocket")
+
+ return &Socket{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Stat
+func (r *Binding) AsStat() *Stat {
+ q := r.query.Select("asStat")
+
+ return &Stat{
+ query: q,
+ }
+}
+
+// Returns the binding's string value
+func (r *Binding) AsString(ctx context.Context) (string, error) {
+ if r.asString != nil {
+ return *r.asString, nil
+ }
+ q := r.query.Select("asString")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieve the binding value, as type Up
+func (r *Binding) AsUp() *Up {
+ q := r.query.Select("asUp")
+
+ return &Up{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type UpGroup
+func (r *Binding) AsUpGroup() *UpGroup {
+ q := r.query.Select("asUpGroup")
+
+ return &UpGroup{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type Workspace
+func (r *Binding) AsWorkspace() *Workspace {
+ q := r.query.Select("asWorkspace")
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type WorkspaceGit
+func (r *Binding) AsWorkspaceGit() *WorkspaceGit {
+ q := r.query.Select("asWorkspaceGit")
+
+ return &WorkspaceGit{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type WorkspaceMigration
+func (r *Binding) AsWorkspaceMigration() *WorkspaceMigration {
+ q := r.query.Select("asWorkspaceMigration")
+
+ return &WorkspaceMigration{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type WorkspaceMigrationStep
+func (r *Binding) AsWorkspaceMigrationStep() *WorkspaceMigrationStep {
+ q := r.query.Select("asWorkspaceMigrationStep")
+
+ return &WorkspaceMigrationStep{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type WorkspaceModule
+func (r *Binding) AsWorkspaceModule() *WorkspaceModule {
+ q := r.query.Select("asWorkspaceModule")
+
+ return &WorkspaceModule{
+ query: q,
+ }
+}
+
+// Retrieve the binding value, as type WorkspaceModuleSetting
+func (r *Binding) AsWorkspaceModuleSetting() *WorkspaceModuleSetting {
+ q := r.query.Select("asWorkspaceModuleSetting")
+
+ return &WorkspaceModuleSetting{
+ query: q,
+ }
+}
+
+// Returns the digest of the binding value
+func (r *Binding) Digest(ctx context.Context) (string, error) {
+ if r.digest != nil {
+ return *r.digest, nil
+ }
+ q := r.query.Select("digest")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Binding.
+func (r *Binding) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Binding) XXX_GraphQLType() string {
+ return "Binding"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Binding) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Binding) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Binding) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Binding) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Binding{query: selectNode(dag.query, id, "Binding")}
+ return nil
+}
+
+// Returns true if the binding is null
+func (r *Binding) IsNull(ctx context.Context) (bool, error) {
+ if r.isNull != nil {
+ return *r.isNull, nil
+ }
+ q := r.query.Select("isNull")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Returns the binding name
+func (r *Binding) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Returns the binding type
+func (r *Binding) TypeName(ctx context.Context) (string, error) {
+ if r.typeName != nil {
+ return *r.typeName, nil
+ }
+ q := r.query.Select("typeName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Binding as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Binding) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A directory whose contents persist across runs.
+type CacheVolume struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *CacheVolume) WithGraphQLQuery(q *querybuilder.Selection) *CacheVolume {
+ return &CacheVolume{
+ query: q,
+ }
+}
+
+// A unique identifier for this CacheVolume.
+func (r *CacheVolume) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *CacheVolume) XXX_GraphQLType() string {
+ return "CacheVolume"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *CacheVolume) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *CacheVolume) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *CacheVolume) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *CacheVolume) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = CacheVolume{query: selectNode(dag.query, id, "CacheVolume")}
+ return nil
+}
+
+// AsNode returns this CacheVolume as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *CacheVolume) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A comparison between two directories representing changes that can be applied.
+type Changeset struct {
+ query *querybuilder.Selection
+
+ export *string
+ id *ID
+ isEmpty *bool
+ sync *ID
+}
+type WithChangesetFunc func(r *Changeset) *Changeset
+
+// With calls the provided function with current Changeset.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Changeset) With(f WithChangesetFunc) *Changeset {
+ return f(r)
+}
+
+func (r *Changeset) WithGraphQLQuery(q *querybuilder.Selection) *Changeset {
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Files and directories that were added in the newer directory.
+func (r *Changeset) AddedPaths(ctx context.Context) ([]string, error) {
+ q := r.query.Select("addedPaths")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The newer/upper snapshot.
+func (r *Changeset) After() *Directory {
+ q := r.query.Select("after")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return a Git-compatible patch of the changes
+func (r *Changeset) AsPatch() *File {
+ q := r.query.Select("asPatch")
+
+ return &File{
+ query: q,
+ }
+}
+
+// The older/lower snapshot to compare against.
+func (r *Changeset) Before() *Directory {
+ q := r.query.Select("before")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Structured per-path diff statistics (kind and line counts) for this changeset.
+func (r *Changeset) DiffStats(ctx context.Context) ([]DiffStat, error) {
+ q := r.query.Select("diffStats")
+
+ q = q.Select("id")
+
+ type diffStats struct {
+ Id ID
+ }
+
+ convert := func(fields []diffStats) []DiffStat {
+ out := []DiffStat{}
+
+ for i := range fields {
+ val := DiffStat{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "DiffStat")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []diffStats
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Applies the diff represented by this changeset to a path on the host.
+func (r *Changeset) Export(ctx context.Context, path string) (string, error) {
+ if r.export != nil {
+ return *r.export, nil
+ }
+ q := r.query.Select("export")
+ q = q.Arg("path", path)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Changeset.
+func (r *Changeset) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Changeset) XXX_GraphQLType() string {
+ return "Changeset"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Changeset) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Changeset) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Changeset) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Changeset) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Changeset{query: selectNode(dag.query, id, "Changeset")}
+ return nil
+}
+
+// Returns true if the changeset is empty (i.e. there are no changes).
+func (r *Changeset) IsEmpty(ctx context.Context) (bool, error) {
+ if r.isEmpty != nil {
+ return *r.isEmpty, nil
+ }
+ q := r.query.Select("isEmpty")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return a snapshot containing only the created and modified files
+func (r *Changeset) Layer() *Directory {
+ q := r.query.Select("layer")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Files and directories that existed before and were updated in the newer directory.
+func (r *Changeset) ModifiedPaths(ctx context.Context) ([]string, error) {
+ q := r.query.Select("modifiedPaths")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Files and directories that were removed. Directories are indicated by a trailing slash, and their child paths are not included.
+func (r *Changeset) RemovedPaths(ctx context.Context) ([]string, error) {
+ q := r.query.Select("removedPaths")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Force evaluation in the engine.
+func (r *Changeset) Sync(ctx context.Context) (*Changeset, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Changeset{
+ query: selectNode(q.Root(), id, "Changeset"),
+ }, nil
+}
+
+// ChangesetWithChangesetOpts contains options for Changeset.WithChangeset
+type ChangesetWithChangesetOpts struct {
+ // What to do on a merge conflict
+ //
+ // Default: FAIL
+ OnConflict ChangesetMergeConflict
+}
+
+// Add changes to an existing changeset
+//
+// By default the operation will fail in case of conflicts, for instance a file modified in both changesets. The behavior can be adjusted using onConflict argument
+func (r *Changeset) WithChangeset(changes *Changeset, opts ...ChangesetWithChangesetOpts) *Changeset {
+ assertNotNil("changes", changes)
+ q := r.query.Select("withChangeset")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `onConflict` optional argument
+ if !querybuilder.IsZeroValue(opts[i].OnConflict) {
+ q = q.Arg("onConflict", opts[i].OnConflict)
+ }
+ }
+ q = q.Arg("changes", changes)
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// ChangesetWithChangesetsOpts contains options for Changeset.WithChangesets
+type ChangesetWithChangesetsOpts struct {
+ // What to do on a merge conflict
+ //
+ // Default: FAIL
+ OnConflict ChangesetsMergeConflict
+}
+
+// Add changes from multiple changesets using git octopus merge strategy
+//
+// This is more efficient than chaining multiple withChangeset calls when merging many changesets.
+//
+// Only FAIL and FAIL_EARLY conflict strategies are supported (octopus merge cannot use -X ours/theirs).
+func (r *Changeset) WithChangesets(changes []*Changeset, opts ...ChangesetWithChangesetsOpts) *Changeset {
+ q := r.query.Select("withChangesets")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `onConflict` optional argument
+ if !querybuilder.IsZeroValue(opts[i].OnConflict) {
+ q = q.Arg("onConflict", opts[i].OnConflict)
+ }
+ }
+ q = q.Arg("changes", changes)
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// AsExportable returns this Changeset as a Exportable.
+// This is a local type conversion — no GraphQL call.
+func (r *Changeset) AsExportable() Exportable {
+ return &ExportableClient{
+ query: r.query,
+ }
+}
+
+// AsNode returns this Changeset as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Changeset) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this Changeset as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *Changeset) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+type Check struct {
+ query *querybuilder.Selection
+
+ checkType *string
+ completed *bool
+ description *string
+ id *ID
+ name *string
+ passed *bool
+ resultEmoji *string
+}
+type WithCheckFunc func(r *Check) *Check
+
+// With calls the provided function with current Check.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Check) With(f WithCheckFunc) *Check {
+ return f(r)
+}
+
+func (r *Check) WithGraphQLQuery(q *querybuilder.Selection) *Check {
+ return &Check{
+ query: q,
+ }
+}
+
+// The type of check: 'check' for annotated checks, 'generate' for generate-as-checks
+func (r *Check) CheckType(ctx context.Context) (string, error) {
+ if r.checkType != nil {
+ return *r.checkType, nil
+ }
+ q := r.query.Select("checkType")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Whether the check completed
+func (r *Check) Completed(ctx context.Context) (bool, error) {
+ if r.completed != nil {
+ return *r.completed, nil
+ }
+ q := r.query.Select("completed")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The description of the check
+func (r *Check) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// If the check failed, this is the error
+func (r *Check) Error() *Error {
+ q := r.query.Select("error")
+
+ return &Error{
+ query: q,
+ }
+}
+
+// A unique identifier for this Check.
+func (r *Check) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Check) XXX_GraphQLType() string {
+ return "Check"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Check) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Check) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Check) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Check) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Check{query: selectNode(dag.query, id, "Check")}
+ return nil
+}
+
+// Return the fully qualified name of the check
+func (r *Check) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The original module in which the check has been defined
+func (r *Check) OriginalModule() *Module {
+ q := r.query.Select("originalModule")
+
+ return &Module{
+ query: q,
+ }
+}
+
+// Whether the check passed
+func (r *Check) Passed(ctx context.Context) (bool, error) {
+ if r.passed != nil {
+ return *r.passed, nil
+ }
+ q := r.query.Select("passed")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The path of the check within its module
+func (r *Check) Path(ctx context.Context) ([]string, error) {
+ q := r.query.Select("path")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// An emoji representing the result of the check
+func (r *Check) ResultEmoji(ctx context.Context) (string, error) {
+ if r.resultEmoji != nil {
+ return *r.resultEmoji, nil
+ }
+ q := r.query.Select("resultEmoji")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Execute the check
+func (r *Check) Run() *Check {
+ q := r.query.Select("run")
+
+ return &Check{
+ query: q,
+ }
+}
+
+// AsNode returns this Check as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Check) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type CheckGroup struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+type WithCheckGroupFunc func(r *CheckGroup) *CheckGroup
+
+// With calls the provided function with current CheckGroup.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *CheckGroup) With(f WithCheckGroupFunc) *CheckGroup {
+ return f(r)
+}
+
+func (r *CheckGroup) WithGraphQLQuery(q *querybuilder.Selection) *CheckGroup {
+ return &CheckGroup{
+ query: q,
+ }
+}
+
+// A unique identifier for this CheckGroup.
+func (r *CheckGroup) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *CheckGroup) XXX_GraphQLType() string {
+ return "CheckGroup"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *CheckGroup) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *CheckGroup) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *CheckGroup) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *CheckGroup) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = CheckGroup{query: selectNode(dag.query, id, "CheckGroup")}
+ return nil
+}
+
+// Return a list of individual checks and their details
+func (r *CheckGroup) List(ctx context.Context) ([]Check, error) {
+ q := r.query.Select("list")
+
+ q = q.Select("id")
+
+ type list struct {
+ Id ID
+ }
+
+ convert := func(fields []list) []Check {
+ out := []Check{}
+
+ for i := range fields {
+ val := Check{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Check")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []list
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Generate a markdown report
+func (r *CheckGroup) Report() *File {
+ q := r.query.Select("report")
+
+ return &File{
+ query: q,
+ }
+}
+
+// CheckGroupRunOpts contains options for CheckGroup.Run
+type CheckGroupRunOpts struct {
+ // If true, stop running checks as soon as any check fails.
+ FailFast bool
+}
+
+// Execute all selected checks
+func (r *CheckGroup) Run(opts ...CheckGroupRunOpts) *CheckGroup {
+ q := r.query.Select("run")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `failFast` optional argument
+ if !querybuilder.IsZeroValue(opts[i].FailFast) {
+ q = q.Arg("failFast", opts[i].FailFast)
+ }
+ }
+
+ return &CheckGroup{
+ query: q,
+ }
+}
+
+// AsNode returns this CheckGroup as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *CheckGroup) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An internal persistent filesync mirror.
+type ClientFilesyncMirror struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *ClientFilesyncMirror) WithGraphQLQuery(q *querybuilder.Selection) *ClientFilesyncMirror {
+ return &ClientFilesyncMirror{
+ query: q,
+ }
+}
+
+// A unique identifier for this ClientFilesyncMirror.
+func (r *ClientFilesyncMirror) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ClientFilesyncMirror) XXX_GraphQLType() string {
+ return "ClientFilesyncMirror"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ClientFilesyncMirror) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ClientFilesyncMirror) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ClientFilesyncMirror) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ClientFilesyncMirror) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ClientFilesyncMirror{query: selectNode(dag.query, id, "ClientFilesyncMirror")}
+ return nil
+}
+
+// AsNode returns this ClientFilesyncMirror as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ClientFilesyncMirror) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// Dagger Cloud configuration and state
+type Cloud struct {
+ query *querybuilder.Selection
+
+ id *ID
+ traceURL *string
+}
+
+func (r *Cloud) WithGraphQLQuery(q *querybuilder.Selection) *Cloud {
+ return &Cloud{
+ query: q,
+ }
+}
+
+// A unique identifier for this Cloud.
+func (r *Cloud) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Cloud) XXX_GraphQLType() string {
+ return "Cloud"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Cloud) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Cloud) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Cloud) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Cloud) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Cloud{query: selectNode(dag.query, id, "Cloud")}
+ return nil
+}
+
+// The trace URL for the current session
+func (r *Cloud) TraceURL(ctx context.Context) (string, error) {
+ if r.traceURL != nil {
+ return *r.traceURL, nil
+ }
+ q := r.query.Select("traceURL")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Cloud as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Cloud) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An OCI-compatible container, also known as a Docker container.
+type Container struct {
+ query *querybuilder.Selection
+
+ combinedOutput *string
+ envVariable *string
+ exists *bool
+ exitCode *int
+ export *string
+ exportImage *Void
+ id *ID
+ imageRef *string
+ label *string
+ platform *Platform
+ publish *string
+ stderr *string
+ stdout *string
+ sync *ID
+ up *Void
+ user *string
+ workdir *string
+}
+type WithContainerFunc func(r *Container) *Container
+
+// With calls the provided function with current Container.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Container) With(f WithContainerFunc) *Container {
+ return f(r)
+}
+
+func (r *Container) WithGraphQLQuery(q *querybuilder.Selection) *Container {
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerAsServiceOpts contains options for Container.AsService
+type ContainerAsServiceOpts struct {
+ // Command to run instead of the container's default command (e.g., ["go", "run", "main.go"]).
+ //
+ // If empty, the container's default command is used.
+ Args []string
+ // If the container has an entrypoint, prepend it to the args.
+ UseEntrypoint bool
+ // Provides Dagger access to the executed command.
+ ExperimentalPrivilegedNesting bool
+ // Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
+ InsecureRootCapabilities bool
+ // Replace "${VAR}" or "$VAR" in the args according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+ // If set, skip the automatic init process injected into containers by default.
+ //
+ // This should only be used if the user requires that their exec process be the pid 1 process in the container. Otherwise it may result in unexpected behavior.
+ NoInit bool
+}
+
+// Turn the container into a Service.
+//
+// Be sure to set any exposed ports before this conversion.
+func (r *Container) AsService(opts ...ContainerAsServiceOpts) *Service {
+ q := r.query.Select("asService")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `args` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Args) {
+ q = q.Arg("args", opts[i].Args)
+ }
+ // `useEntrypoint` optional argument
+ if !querybuilder.IsZeroValue(opts[i].UseEntrypoint) {
+ q = q.Arg("useEntrypoint", opts[i].UseEntrypoint)
+ }
+ // `experimentalPrivilegedNesting` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) {
+ q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting)
+ }
+ // `insecureRootCapabilities` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) {
+ q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ // `noInit` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoInit) {
+ q = q.Arg("noInit", opts[i].NoInit)
+ }
+ }
+
+ return &Service{
+ query: q,
+ }
+}
+
+// ContainerAsTarballOpts contains options for Container.AsTarball
+type ContainerAsTarballOpts struct {
+ // Identifiers for other platform specific containers.
+ //
+ // Used for multi-platform images.
+ PlatformVariants []*Container
+ // Force each layer of the image to use the specified compression algorithm.
+ //
+ // If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
+ ForcedCompression ImageLayerCompression
+ // Use the specified media types for the image's layers.
+ //
+ // Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
+ //
+ // Default: OCIMediaTypes
+ MediaTypes ImageMediaTypes
+}
+
+// Package the container state as an OCI image, and return it as a tar archive
+func (r *Container) AsTarball(opts ...ContainerAsTarballOpts) *File {
+ q := r.query.Select("asTarball")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `platformVariants` optional argument
+ if !querybuilder.IsZeroValue(opts[i].PlatformVariants) {
+ q = q.Arg("platformVariants", opts[i].PlatformVariants)
+ }
+ // `forcedCompression` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ForcedCompression) {
+ q = q.Arg("forcedCompression", opts[i].ForcedCompression)
+ }
+ // `mediaTypes` optional argument
+ if !querybuilder.IsZeroValue(opts[i].MediaTypes) {
+ q = q.Arg("mediaTypes", opts[i].MediaTypes)
+ }
+ }
+
+ return &File{
+ query: q,
+ }
+}
+
+// The combined buffered standard output and standard error stream of the last executed command
+//
+// Returns an error if no command was executed
+func (r *Container) CombinedOutput(ctx context.Context) (string, error) {
+ if r.combinedOutput != nil {
+ return *r.combinedOutput, nil
+ }
+ q := r.query.Select("combinedOutput")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return the container's default arguments.
+func (r *Container) DefaultArgs(ctx context.Context) ([]string, error) {
+ q := r.query.Select("defaultArgs")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// ContainerDirectoryOpts contains options for Container.Directory
+type ContainerDirectoryOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieve a directory from the container's root filesystem
+//
+// Mounts are included.
+func (r *Container) Directory(path string, opts ...ContainerDirectoryOpts) *Directory {
+ q := r.query.Select("directory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Retrieves this container's configured docker healthcheck.
+func (r *Container) DockerHealthcheck() *HealthcheckConfig {
+ q := r.query.Select("dockerHealthcheck")
+
+ return &HealthcheckConfig{
+ query: q,
+ }
+}
+
+// Return the container's OCI entrypoint.
+func (r *Container) Entrypoint(ctx context.Context) ([]string, error) {
+ q := r.query.Select("entrypoint")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieves the value of the specified persistent environment variable.
+func (r *Container) EnvVariable(ctx context.Context, name string) (string, error) {
+ if r.envVariable != nil {
+ return *r.envVariable, nil
+ }
+ q := r.query.Select("envVariable")
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieves the list of persistent environment variables configured on the container.
+func (r *Container) EnvVariables(ctx context.Context) ([]EnvVariable, error) {
+ q := r.query.Select("envVariables")
+
+ q = q.Select("id")
+
+ type envVariables struct {
+ Id ID
+ }
+
+ convert := func(fields []envVariables) []EnvVariable {
+ out := []EnvVariable{}
+
+ for i := range fields {
+ val := EnvVariable{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "EnvVariable")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []envVariables
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// ContainerExistsOpts contains options for Container.Exists
+type ContainerExistsOpts struct {
+ // If specified, also validate the type of file (e.g. "REGULAR_TYPE", "DIRECTORY_TYPE", or "SYMLINK_TYPE").
+ ExpectedType ExistsType
+ // If specified, do not follow symlinks.
+ DoNotFollowSymlinks bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// check if a file or directory exists
+func (r *Container) Exists(ctx context.Context, path string, opts ...ContainerExistsOpts) (bool, error) {
+ if r.exists != nil {
+ return *r.exists, nil
+ }
+ q := r.query.Select("exists")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expectedType` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExpectedType) {
+ q = q.Arg("expectedType", opts[i].ExpectedType)
+ }
+ // `doNotFollowSymlinks` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DoNotFollowSymlinks) {
+ q = q.Arg("doNotFollowSymlinks", opts[i].DoNotFollowSymlinks)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The exit code of the last executed command
+//
+// Returns an error if no command was executed
+func (r *Container) ExitCode(ctx context.Context) (int, error) {
+ if r.exitCode != nil {
+ return *r.exitCode, nil
+ }
+ q := r.query.Select("exitCode")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// EXPERIMENTAL API! Subject to change/removal at any time.
+//
+// Configures all available GPUs on the host to be accessible to this container.
+//
+// This currently works for Nvidia devices only.
+func (r *Container) ExperimentalWithAllGPUs() *Container {
+ q := r.query.Select("experimentalWithAllGPUs")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// EXPERIMENTAL API! Subject to change/removal at any time.
+//
+// Configures the provided list of devices to be accessible to this container.
+//
+// This currently works for Nvidia devices only.
+func (r *Container) ExperimentalWithGPU(devices []string) *Container {
+ q := r.query.Select("experimentalWithGPU")
+ q = q.Arg("devices", devices)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerExportOpts contains options for Container.Export
+type ContainerExportOpts struct {
+ // Identifiers for other platform specific containers.
+ //
+ // Used for multi-platform image.
+ PlatformVariants []*Container
+ // Force each layer of the exported image to use the specified compression algorithm.
+ //
+ // If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
+ ForcedCompression ImageLayerCompression
+ // Use the specified media types for the exported image's layers.
+ //
+ // Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
+ //
+ // Default: OCIMediaTypes
+ MediaTypes ImageMediaTypes
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Writes the container as an OCI tarball to the destination file path on the host.
+//
+// It can also export platform variants.
+func (r *Container) Export(ctx context.Context, path string, opts ...ContainerExportOpts) (string, error) {
+ if r.export != nil {
+ return *r.export, nil
+ }
+ q := r.query.Select("export")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `platformVariants` optional argument
+ if !querybuilder.IsZeroValue(opts[i].PlatformVariants) {
+ q = q.Arg("platformVariants", opts[i].PlatformVariants)
+ }
+ // `forcedCompression` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ForcedCompression) {
+ q = q.Arg("forcedCompression", opts[i].ForcedCompression)
+ }
+ // `mediaTypes` optional argument
+ if !querybuilder.IsZeroValue(opts[i].MediaTypes) {
+ q = q.Arg("mediaTypes", opts[i].MediaTypes)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// ContainerExportImageOpts contains options for Container.ExportImage
+type ContainerExportImageOpts struct {
+ // Identifiers for other platform specific containers.
+ //
+ // Used for multi-platform image.
+ PlatformVariants []*Container
+ // Force each layer of the exported image to use the specified compression algorithm.
+ //
+ // If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
+ ForcedCompression ImageLayerCompression
+ // Use the specified media types for the exported image's layers.
+ //
+ // Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
+ //
+ // Default: OCIMediaTypes
+ MediaTypes ImageMediaTypes
+}
+
+// Exports the container as an image to the host's container image store.
+func (r *Container) ExportImage(ctx context.Context, name string, opts ...ContainerExportImageOpts) error {
+ if r.exportImage != nil {
+ return nil
+ }
+ q := r.query.Select("exportImage")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `platformVariants` optional argument
+ if !querybuilder.IsZeroValue(opts[i].PlatformVariants) {
+ q = q.Arg("platformVariants", opts[i].PlatformVariants)
+ }
+ // `forcedCompression` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ForcedCompression) {
+ q = q.Arg("forcedCompression", opts[i].ForcedCompression)
+ }
+ // `mediaTypes` optional argument
+ if !querybuilder.IsZeroValue(opts[i].MediaTypes) {
+ q = q.Arg("mediaTypes", opts[i].MediaTypes)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return q.Execute(ctx)
+}
+
+// Retrieves the list of exposed ports.
+//
+// This includes ports already exposed by the image, even if not explicitly added with dagger.
+func (r *Container) ExposedPorts(ctx context.Context) ([]Port, error) {
+ q := r.query.Select("exposedPorts")
+
+ q = q.Select("id")
+
+ type exposedPorts struct {
+ Id ID
+ }
+
+ convert := func(fields []exposedPorts) []Port {
+ out := []Port{}
+
+ for i := range fields {
+ val := Port{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Port")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []exposedPorts
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// ContainerFileOpts contains options for Container.File
+type ContainerFileOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Retrieves a file at the given path.
+//
+// Mounts are included.
+func (r *Container) File(path string, opts ...ContainerFileOpts) *File {
+ q := r.query.Select("file")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &File{
+ query: q,
+ }
+}
+
+// ContainerFromOpts contains options for Container.From
+type ContainerFromOpts struct {
+ // Service to use as the registry endpoint for the image address.
+ //
+ // The service will be started only for this pull.
+ RegistryService *Service
+ // Protocol to use for registry communication.
+ //
+ // Defaults to "HTTPS". Use "HTTP" only for plain HTTP registries.
+ Protocol RegistryProtocol
+ // Allow HTTPS registry communication without verifying the server certificate.
+ InsecureSkipTLSVerify bool
+}
+
+// Download a container image, and apply it to the container state. All previous state will be lost.
+func (r *Container) From(address string, opts ...ContainerFromOpts) *Container {
+ q := r.query.Select("from")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `registryService` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RegistryService) {
+ q = q.Arg("registryService", opts[i].RegistryService)
+ }
+ // `protocol` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Protocol) {
+ q = q.Arg("protocol", opts[i].Protocol)
+ }
+ // `insecureSkipTLSVerify` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureSkipTLSVerify) {
+ q = q.Arg("insecureSkipTLSVerify", opts[i].InsecureSkipTLSVerify)
+ }
+ }
+ q = q.Arg("address", address)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// A unique identifier for this Container.
+func (r *Container) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Container) XXX_GraphQLType() string {
+ return "Container"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Container) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Container) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Container) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Container) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Container{query: selectNode(dag.query, id, "Container")}
+ return nil
+}
+
+// The unique image reference which can only be retrieved immediately after the 'Container.From' call.
+func (r *Container) ImageRef(ctx context.Context) (string, error) {
+ if r.imageRef != nil {
+ return *r.imageRef, nil
+ }
+ q := r.query.Select("imageRef")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// ContainerImportOpts contains options for Container.Import
+type ContainerImportOpts struct {
+ // Identifies the tag to import from the archive, if the archive bundles multiple tags.
+ Tag string
+}
+
+// Reads the container from an OCI tarball.
+func (r *Container) Import(source *File, opts ...ContainerImportOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("import")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `tag` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Tag) {
+ q = q.Arg("tag", opts[i].Tag)
+ }
+ }
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves the value of the specified label.
+func (r *Container) Label(ctx context.Context, name string) (string, error) {
+ if r.label != nil {
+ return *r.label, nil
+ }
+ q := r.query.Select("label")
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieves the list of labels passed to container.
+func (r *Container) Labels(ctx context.Context) ([]Label, error) {
+ q := r.query.Select("labels")
+
+ q = q.Select("id")
+
+ type labels struct {
+ Id ID
+ }
+
+ convert := func(fields []labels) []Label {
+ out := []Label{}
+
+ for i := range fields {
+ val := Label{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Label")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []labels
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Retrieves the list of paths where a directory is mounted.
+func (r *Container) Mounts(ctx context.Context) ([]string, error) {
+ q := r.query.Select("mounts")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The platform this container executes and publishes as.
+func (r *Container) Platform(ctx context.Context) (Platform, error) {
+ if r.platform != nil {
+ return *r.platform, nil
+ }
+ q := r.query.Select("platform")
+
+ var response Platform
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// ContainerPublishOpts contains options for Container.Publish
+type ContainerPublishOpts struct {
+ // Identifiers for other platform specific containers.
+ //
+ // Used for multi-platform image.
+ PlatformVariants []*Container
+ // Force each layer of the published image to use the specified compression algorithm.
+ //
+ // If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.
+ ForcedCompression ImageLayerCompression
+ // Use the specified media types for the published image's layers.
+ //
+ // Defaults to "OCI", which is compatible with most recent registries, but "Docker" may be needed for older registries without OCI support.
+ //
+ // Default: OCIMediaTypes
+ MediaTypes ImageMediaTypes
+ // Service to use as the registry endpoint for the image address.
+ //
+ // The service will be started only for this push.
+ RegistryService *Service
+ // Protocol to use for registry communication.
+ //
+ // Defaults to "HTTPS". Use "HTTP" only for plain HTTP registries.
+ Protocol RegistryProtocol
+ // Allow HTTPS registry communication without verifying the server certificate.
+ InsecureSkipTLSVerify bool
+}
+
+// Package the container state as an OCI image, and publish it to a registry
+//
+// Returns the fully qualified address of the published image, with digest
+func (r *Container) Publish(ctx context.Context, address string, opts ...ContainerPublishOpts) (string, error) {
+ if r.publish != nil {
+ return *r.publish, nil
+ }
+ q := r.query.Select("publish")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `platformVariants` optional argument
+ if !querybuilder.IsZeroValue(opts[i].PlatformVariants) {
+ q = q.Arg("platformVariants", opts[i].PlatformVariants)
+ }
+ // `forcedCompression` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ForcedCompression) {
+ q = q.Arg("forcedCompression", opts[i].ForcedCompression)
+ }
+ // `mediaTypes` optional argument
+ if !querybuilder.IsZeroValue(opts[i].MediaTypes) {
+ q = q.Arg("mediaTypes", opts[i].MediaTypes)
+ }
+ // `registryService` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RegistryService) {
+ q = q.Arg("registryService", opts[i].RegistryService)
+ }
+ // `protocol` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Protocol) {
+ q = q.Arg("protocol", opts[i].Protocol)
+ }
+ // `insecureSkipTLSVerify` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureSkipTLSVerify) {
+ q = q.Arg("insecureSkipTLSVerify", opts[i].InsecureSkipTLSVerify)
+ }
+ }
+ q = q.Arg("address", address)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return a snapshot of the container's root filesystem. The snapshot can be modified then written back using withRootfs. Use that method for filesystem modifications.
+func (r *Container) Rootfs() *Directory {
+ q := r.query.Select("rootfs")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// ContainerStatOpts contains options for Container.Stat
+type ContainerStatOpts struct {
+ // If specified, do not follow symlinks.
+ DoNotFollowSymlinks bool
+}
+
+// Return file status
+func (r *Container) Stat(path string, opts ...ContainerStatOpts) *Stat {
+ q := r.query.Select("stat")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `doNotFollowSymlinks` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DoNotFollowSymlinks) {
+ q = q.Arg("doNotFollowSymlinks", opts[i].DoNotFollowSymlinks)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Stat{
+ query: q,
+ }
+}
+
+// The buffered standard error stream of the last executed command
+//
+// Returns an error if no command was executed
+func (r *Container) Stderr(ctx context.Context) (string, error) {
+ if r.stderr != nil {
+ return *r.stderr, nil
+ }
+ q := r.query.Select("stderr")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The buffered standard output stream of the last executed command
+//
+// Returns an error if no command was executed
+func (r *Container) Stdout(ctx context.Context) (string, error) {
+ if r.stdout != nil {
+ return *r.stdout, nil
+ }
+ q := r.query.Select("stdout")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Forces evaluation of the pipeline in the engine.
+//
+// It doesn't run the default command if no exec has been set.
+func (r *Container) Sync(ctx context.Context) (*Container, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Container{
+ query: selectNode(q.Root(), id, "Container"),
+ }, nil
+}
+
+// ContainerTerminalOpts contains options for Container.Terminal
+type ContainerTerminalOpts struct {
+ // If set, override the container's default terminal command and invoke these command arguments instead.
+ Cmd []string
+ // Provides Dagger access to the executed command.
+ ExperimentalPrivilegedNesting bool
+ // Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
+ InsecureRootCapabilities bool
+}
+
+// Opens an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default).
+func (r *Container) Terminal(opts ...ContainerTerminalOpts) *Container {
+ q := r.query.Select("terminal")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `cmd` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Cmd) {
+ q = q.Arg("cmd", opts[i].Cmd)
+ }
+ // `experimentalPrivilegedNesting` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) {
+ q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting)
+ }
+ // `insecureRootCapabilities` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) {
+ q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities)
+ }
+ }
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerUpOpts contains options for Container.Up
+type ContainerUpOpts struct {
+ // Bind each tunnel port to a random port on the host.
+ Random bool
+ // List of frontend/backend port mappings to forward.
+ //
+ // Frontend is the port accepting traffic on the host, backend is the service port.
+ Ports []PortForward
+ // Command to run instead of the container's default command (e.g., ["go", "run", "main.go"]).
+ //
+ // If empty, the container's default command is used.
+ Args []string
+ // If the container has an entrypoint, prepend it to the args.
+ UseEntrypoint bool
+ // Provides Dagger access to the executed command.
+ ExperimentalPrivilegedNesting bool
+ // Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
+ InsecureRootCapabilities bool
+ // Replace "${VAR}" or "$VAR" in the args according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+ // If set, skip the automatic init process injected into containers by default.
+ //
+ // This should only be used if the user requires that their exec process be the pid 1 process in the container. Otherwise it may result in unexpected behavior.
+ NoInit bool
+}
+
+// Starts a Service and creates a tunnel that forwards traffic from the caller's network to that service.
+//
+// Be sure to set any exposed ports before calling this api.
+func (r *Container) Up(ctx context.Context, opts ...ContainerUpOpts) error {
+ if r.up != nil {
+ return nil
+ }
+ q := r.query.Select("up")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `random` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Random) {
+ q = q.Arg("random", opts[i].Random)
+ }
+ // `ports` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Ports) {
+ q = q.Arg("ports", opts[i].Ports)
+ }
+ // `args` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Args) {
+ q = q.Arg("args", opts[i].Args)
+ }
+ // `useEntrypoint` optional argument
+ if !querybuilder.IsZeroValue(opts[i].UseEntrypoint) {
+ q = q.Arg("useEntrypoint", opts[i].UseEntrypoint)
+ }
+ // `experimentalPrivilegedNesting` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) {
+ q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting)
+ }
+ // `insecureRootCapabilities` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) {
+ q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ // `noInit` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoInit) {
+ q = q.Arg("noInit", opts[i].NoInit)
+ }
+ }
+
+ return q.Execute(ctx)
+}
+
+// Retrieves the user to be set for all commands.
+func (r *Container) User(ctx context.Context) (string, error) {
+ if r.user != nil {
+ return *r.user, nil
+ }
+ q := r.query.Select("user")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieves this container plus the given OCI annotation.
+func (r *Container) WithAnnotation(name string, value string) *Container {
+ q := r.query.Select("withAnnotation")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Configures default arguments for future commands. Like CMD in Dockerfile.
+func (r *Container) WithDefaultArgs(args []string) *Container {
+ q := r.query.Select("withDefaultArgs")
+ q = q.Arg("args", args)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithDefaultTerminalCmdOpts contains options for Container.WithDefaultTerminalCmd
+type ContainerWithDefaultTerminalCmdOpts struct {
+ // Provides Dagger access to the executed command.
+ ExperimentalPrivilegedNesting bool
+ // Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
+ InsecureRootCapabilities bool
+}
+
+// Set the default command to invoke for the container's terminal API.
+func (r *Container) WithDefaultTerminalCmd(args []string, opts ...ContainerWithDefaultTerminalCmdOpts) *Container {
+ q := r.query.Select("withDefaultTerminalCmd")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `experimentalPrivilegedNesting` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) {
+ q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting)
+ }
+ // `insecureRootCapabilities` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) {
+ q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities)
+ }
+ }
+ q = q.Arg("args", args)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithDirectoryOpts contains options for Container.WithDirectory
+type ContainerWithDirectoryOpts struct {
+ // Patterns to exclude in the written directory (e.g. ["node_modules/**", ".gitignore", ".git/"]).
+ Exclude []string
+ // Patterns to include in the written directory (e.g. ["*.go", "go.mod", "go.sum"]).
+ Include []string
+ // Apply .gitignore rules when writing the directory.
+ Gitignore bool
+ // A user:group to set for the directory and its contents.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+
+ Permissions int
+}
+
+// Return a new container snapshot, with a directory added to its filesystem
+func (r *Container) WithDirectory(path string, source *Directory, opts ...ContainerWithDirectoryOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withDirectory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithDockerHealthcheckOpts contains options for Container.WithDockerHealthcheck
+type ContainerWithDockerHealthcheckOpts struct {
+ // When true, command must be a single element, which is run using the container's shell
+ Shell bool
+ // Interval between running healthcheck. Example: "30s"
+ Interval string
+ // Healthcheck timeout. Example: "3s"
+ Timeout string
+ // StartPeriod allows for failures during this initial startup period which do not count towards maximum number of retries. Example: "0s"
+ StartPeriod string
+ // StartInterval configures the duration between checks during the startup phase. Example: "5s"
+ StartInterval string
+ // The maximum number of consecutive failures before the container is marked as unhealthy. Example: "3"
+ Retries int
+}
+
+// Retrieves this container with the specificed docker healtcheck command set.
+func (r *Container) WithDockerHealthcheck(args []string, opts ...ContainerWithDockerHealthcheckOpts) *Container {
+ q := r.query.Select("withDockerHealthcheck")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `shell` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Shell) {
+ q = q.Arg("shell", opts[i].Shell)
+ }
+ // `interval` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Interval) {
+ q = q.Arg("interval", opts[i].Interval)
+ }
+ // `timeout` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Timeout) {
+ q = q.Arg("timeout", opts[i].Timeout)
+ }
+ // `startPeriod` optional argument
+ if !querybuilder.IsZeroValue(opts[i].StartPeriod) {
+ q = q.Arg("startPeriod", opts[i].StartPeriod)
+ }
+ // `startInterval` optional argument
+ if !querybuilder.IsZeroValue(opts[i].StartInterval) {
+ q = q.Arg("startInterval", opts[i].StartInterval)
+ }
+ // `retries` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Retries) {
+ q = q.Arg("retries", opts[i].Retries)
+ }
+ }
+ q = q.Arg("args", args)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithEntrypointOpts contains options for Container.WithEntrypoint
+type ContainerWithEntrypointOpts struct {
+ // Don't reset the default arguments when setting the entrypoint. By default it is reset, since entrypoint and default args are often tightly coupled.
+ KeepDefaultArgs bool
+}
+
+// Set an OCI-style entrypoint. It will be included in the container's OCI configuration. Note, withExec ignores the entrypoint by default.
+func (r *Container) WithEntrypoint(args []string, opts ...ContainerWithEntrypointOpts) *Container {
+ q := r.query.Select("withEntrypoint")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `keepDefaultArgs` optional argument
+ if !querybuilder.IsZeroValue(opts[i].KeepDefaultArgs) {
+ q = q.Arg("keepDefaultArgs", opts[i].KeepDefaultArgs)
+ }
+ }
+ q = q.Arg("args", args)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Export environment variables from an env-file to the container.
+func (r *Container) WithEnvFileVariables(source *EnvFile) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withEnvFileVariables")
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithEnvVariableOpts contains options for Container.WithEnvVariable
+type ContainerWithEnvVariableOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value according to the current environment variables defined in the container (e.g. "/opt/bin:$PATH").
+ Expand bool
+}
+
+// Set a new environment variable in the container.
+func (r *Container) WithEnvVariable(name string, value string, opts ...ContainerWithEnvVariableOpts) *Container {
+ q := r.query.Select("withEnvVariable")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Raise an error.
+func (r *Container) WithError(err string) *Container {
+ q := r.query.Select("withError")
+ q = q.Arg("err", err)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithExecOpts contains options for Container.WithExec
+type ContainerWithExecOpts struct {
+ // Apply the OCI entrypoint, if present, by prepending it to the args. Ignored by default.
+ UseEntrypoint bool
+ // Content to write to the command's standard input. Example: "Hello world")
+ Stdin string
+ // Redirect the command's standard input from a file in the container. Example: "./stdin.txt"
+ RedirectStdin string
+ // Redirect the command's standard output to a file in the container. Example: "./stdout.txt"
+ RedirectStdout string
+ // Redirect the command's standard error to a file in the container. Example: "./stderr.txt"
+ RedirectStderr string
+ // Exit codes this command is allowed to exit with without error
+ //
+ // Default: SUCCESS
+ Expect ReturnType
+ // Provides Dagger access to the executed command.
+ ExperimentalPrivilegedNesting bool
+ // Execute the command with all root capabilities. Like --privileged in Docker
+ //
+ // DANGER: this grants the command full access to the host system. Only use when 1) you trust the command being executed and 2) you specifically need this level of access.
+ InsecureRootCapabilities bool
+ // Replace "${VAR}" or "$VAR" in the args according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+ // Skip the automatic init process injected into containers by default.
+ //
+ // Only use this if you specifically need the command to be pid 1 in the container. Otherwise it may result in unexpected behavior. If you're not sure, you don't need this.
+ NoInit bool
+}
+
+// Execute a command in the container, and return a new snapshot of the container state after execution.
+func (r *Container) WithExec(args []string, opts ...ContainerWithExecOpts) *Container {
+ q := r.query.Select("withExec")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `useEntrypoint` optional argument
+ if !querybuilder.IsZeroValue(opts[i].UseEntrypoint) {
+ q = q.Arg("useEntrypoint", opts[i].UseEntrypoint)
+ }
+ // `stdin` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Stdin) {
+ q = q.Arg("stdin", opts[i].Stdin)
+ }
+ // `redirectStdin` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RedirectStdin) {
+ q = q.Arg("redirectStdin", opts[i].RedirectStdin)
+ }
+ // `redirectStdout` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RedirectStdout) {
+ q = q.Arg("redirectStdout", opts[i].RedirectStdout)
+ }
+ // `redirectStderr` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RedirectStderr) {
+ q = q.Arg("redirectStderr", opts[i].RedirectStderr)
+ }
+ // `expect` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expect) {
+ q = q.Arg("expect", opts[i].Expect)
+ }
+ // `experimentalPrivilegedNesting` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) {
+ q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting)
+ }
+ // `insecureRootCapabilities` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) {
+ q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ // `noInit` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoInit) {
+ q = q.Arg("noInit", opts[i].NoInit)
+ }
+ }
+ q = q.Arg("args", args)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithExposedPortOpts contains options for Container.WithExposedPort
+type ContainerWithExposedPortOpts struct {
+ // Network protocol. Example: "tcp"
+ //
+ // Default: TCP
+ Protocol NetworkProtocol
+ // Port description. Example: "payment API endpoint"
+ Description string
+ // Skip the health check when run as a service.
+ ExperimentalSkipHealthcheck bool
+}
+
+// Expose a network port. Like EXPOSE in Dockerfile (but with healthcheck support)
+//
+// Exposed ports serve two purposes:
+//
+// - For health checks and introspection, when running services
+//
+// - For setting the EXPOSE OCI field when publishing the container
+func (r *Container) WithExposedPort(port int, opts ...ContainerWithExposedPortOpts) *Container {
+ q := r.query.Select("withExposedPort")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `protocol` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Protocol) {
+ q = q.Arg("protocol", opts[i].Protocol)
+ }
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `experimentalSkipHealthcheck` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalSkipHealthcheck) {
+ q = q.Arg("experimentalSkipHealthcheck", opts[i].ExperimentalSkipHealthcheck)
+ }
+ }
+ q = q.Arg("port", port)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithFileOpts contains options for Container.WithFile
+type ContainerWithFileOpts struct {
+ // Permissions of the new file. Example: 0600
+ Permissions int
+ // A user:group to set for the file.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Return a container snapshot with a file added
+func (r *Container) WithFile(path string, source *File, opts ...ContainerWithFileOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithFilesOpts contains options for Container.WithFiles
+type ContainerWithFilesOpts struct {
+ // Permission given to the copied files (e.g., 0600).
+ Permissions int
+ // A user:group to set for the files.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Retrieves this container plus the contents of the given files copied to the given path.
+func (r *Container) WithFiles(path string, sources []*File, opts ...ContainerWithFilesOpts) *Container {
+ q := r.query.Select("withFiles")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("sources", sources)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container plus the given label.
+func (r *Container) WithLabel(name string, value string) *Container {
+ q := r.query.Select("withLabel")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithMountedCacheOpts contains options for Container.WithMountedCache
+type ContainerWithMountedCacheOpts struct {
+ // Identifier of the directory to use as the cache volume's root.
+ Source *Directory
+ // Sharing mode of the cache volume.
+ //
+ // Default: SHARED
+ Sharing CacheSharingMode
+ // A user:group to set for the mounted cache directory.
+ //
+ // Note that this changes the ownership of the specified mount along with the initial filesystem provided by source (if any). It does not have any effect if/when the cache has already been created.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container plus a cache volume mounted at the given path.
+func (r *Container) WithMountedCache(path string, cache *CacheVolume, opts ...ContainerWithMountedCacheOpts) *Container {
+ assertNotNil("cache", cache)
+ q := r.query.Select("withMountedCache")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `source` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Source) {
+ q = q.Arg("source", opts[i].Source)
+ }
+ // `sharing` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Sharing) {
+ q = q.Arg("sharing", opts[i].Sharing)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("cache", cache)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithMountedDirectoryOpts contains options for Container.WithMountedDirectory
+type ContainerWithMountedDirectoryOpts struct {
+ // A user:group to set for the mounted directory and its contents.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Mount the directory read-only.
+ ReadOnly bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container plus a directory mounted at the given path.
+func (r *Container) WithMountedDirectory(path string, source *Directory, opts ...ContainerWithMountedDirectoryOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withMountedDirectory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `readOnly` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ReadOnly) {
+ q = q.Arg("readOnly", opts[i].ReadOnly)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithMountedFileOpts contains options for Container.WithMountedFile
+type ContainerWithMountedFileOpts struct {
+ // A user or user:group to set for the mounted file.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Retrieves this container plus a file mounted at the given path.
+func (r *Container) WithMountedFile(path string, source *File, opts ...ContainerWithMountedFileOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withMountedFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithMountedSecretOpts contains options for Container.WithMountedSecret
+type ContainerWithMountedSecretOpts struct {
+ // A user:group to set for the mounted secret.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Permission given to the mounted secret (e.g., 0600).
+ //
+ // This option requires an owner to be set to be active.
+ //
+ // Default: 256
+ Mode int
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container plus a secret mounted into a file at the given path.
+func (r *Container) WithMountedSecret(path string, source *Secret, opts ...ContainerWithMountedSecretOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withMountedSecret")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `mode` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Mode) {
+ q = q.Arg("mode", opts[i].Mode)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithMountedTempOpts contains options for Container.WithMountedTemp
+type ContainerWithMountedTempOpts struct {
+ // Size of the temporary directory in bytes.
+ Size int
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container plus a temporary directory mounted at the given path. Any writes will be ephemeral to a single withExec call; they will not be persisted to subsequent withExecs.
+func (r *Container) WithMountedTemp(path string, opts ...ContainerWithMountedTempOpts) *Container {
+ q := r.query.Select("withMountedTemp")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `size` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Size) {
+ q = q.Arg("size", opts[i].Size)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithNewFileOpts contains options for Container.WithNewFile
+type ContainerWithNewFileOpts struct {
+ // Permissions of the new file. Example: 0600
+ //
+ // Default: 420
+ Permissions int
+ // A user:group to set for the file.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Return a new container snapshot, with a file added to its filesystem with text content
+func (r *Container) WithNewFile(path string, contents string, opts ...ContainerWithNewFileOpts) *Container {
+ q := r.query.Select("withNewFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("contents", contents)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Attach credentials for future publishing to a registry. Use in combination with publish
+func (r *Container) WithRegistryAuth(address string, username string, secret *Secret) *Container {
+ assertNotNil("secret", secret)
+ q := r.query.Select("withRegistryAuth")
+ q = q.Arg("address", address)
+ q = q.Arg("username", username)
+ q = q.Arg("secret", secret)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Change the container's root filesystem. The previous root filesystem will be lost.
+func (r *Container) WithRootfs(directory *Directory) *Container {
+ assertNotNil("directory", directory)
+ q := r.query.Select("withRootfs")
+ q = q.Arg("directory", directory)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Set a new environment variable, using a secret value
+func (r *Container) WithSecretVariable(name string, secret *Secret) *Container {
+ assertNotNil("secret", secret)
+ q := r.query.Select("withSecretVariable")
+ q = q.Arg("name", name)
+ q = q.Arg("secret", secret)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Establish a runtime dependency from a container to a network service.
+//
+// The service will be started automatically when needed and detached when it is no longer needed, executing the default command if none is set.
+//
+// The service will be reachable from the container via the provided hostname alias.
+//
+// The service dependency will also convey to any files or directories produced by the container.
+func (r *Container) WithServiceBinding(alias string, service *Service) *Container {
+ assertNotNil("service", service)
+ q := r.query.Select("withServiceBinding")
+ q = q.Arg("alias", alias)
+ q = q.Arg("service", service)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithSymlinkOpts contains options for Container.WithSymlink
+type ContainerWithSymlinkOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Return a snapshot with a symlink
+func (r *Container) WithSymlink(target string, linkName string, opts ...ContainerWithSymlinkOpts) *Container {
+ q := r.query.Select("withSymlink")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("target", target)
+ q = q.Arg("linkName", linkName)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithUnixSocketOpts contains options for Container.WithUnixSocket
+type ContainerWithUnixSocketOpts struct {
+ // A user:group to set for the mounted socket.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Set the owner to the container's current user.
+ InheritOwner bool
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container plus a socket forwarded to the given Unix socket path.
+func (r *Container) WithUnixSocket(path string, source *Socket, opts ...ContainerWithUnixSocketOpts) *Container {
+ assertNotNil("source", source)
+ q := r.query.Select("withUnixSocket")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `inheritOwner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InheritOwner) {
+ q = q.Arg("inheritOwner", opts[i].InheritOwner)
+ }
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container with a different command user.
+func (r *Container) WithUser(name string) *Container {
+ q := r.query.Select("withUser")
+ q = q.Arg("name", name)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Set a new non-secret environment variable for future execs without invalidating exec cache when only its value changes.
+//
+// This is an expert-only escape hatch. If a volatile value affects observable exec results, stale cached results may be reused.
+func (r *Container) WithVolatileVariable(name string, value string) *Container {
+ q := r.query.Select("withVolatileVariable")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithWorkdirOpts contains options for Container.WithWorkdir
+type ContainerWithWorkdirOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Change the container's working directory. Like WORKDIR in Dockerfile.
+func (r *Container) WithWorkdir(path string, opts ...ContainerWithWorkdirOpts) *Container {
+ q := r.query.Select("withWorkdir")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container minus the given OCI annotation.
+func (r *Container) WithoutAnnotation(name string) *Container {
+ q := r.query.Select("withoutAnnotation")
+ q = q.Arg("name", name)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Remove the container's default arguments.
+func (r *Container) WithoutDefaultArgs() *Container {
+ q := r.query.Select("withoutDefaultArgs")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutDirectoryOpts contains options for Container.WithoutDirectory
+type ContainerWithoutDirectoryOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Return a new container snapshot, with a directory removed from its filesystem
+func (r *Container) WithoutDirectory(path string, opts ...ContainerWithoutDirectoryOpts) *Container {
+ q := r.query.Select("withoutDirectory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container without a configured docker healtcheck command.
+func (r *Container) WithoutDockerHealthcheck() *Container {
+ q := r.query.Select("withoutDockerHealthcheck")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutEntrypointOpts contains options for Container.WithoutEntrypoint
+type ContainerWithoutEntrypointOpts struct {
+ // Don't remove the default arguments when unsetting the entrypoint.
+ KeepDefaultArgs bool
+}
+
+// Reset the container's OCI entrypoint.
+func (r *Container) WithoutEntrypoint(opts ...ContainerWithoutEntrypointOpts) *Container {
+ q := r.query.Select("withoutEntrypoint")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `keepDefaultArgs` optional argument
+ if !querybuilder.IsZeroValue(opts[i].KeepDefaultArgs) {
+ q = q.Arg("keepDefaultArgs", opts[i].KeepDefaultArgs)
+ }
+ }
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container minus the given environment variable.
+func (r *Container) WithoutEnvVariable(name string) *Container {
+ q := r.query.Select("withoutEnvVariable")
+ q = q.Arg("name", name)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutExposedPortOpts contains options for Container.WithoutExposedPort
+type ContainerWithoutExposedPortOpts struct {
+ // Port protocol to unexpose
+ //
+ // Default: TCP
+ Protocol NetworkProtocol
+}
+
+// Unexpose a previously exposed port.
+func (r *Container) WithoutExposedPort(port int, opts ...ContainerWithoutExposedPortOpts) *Container {
+ q := r.query.Select("withoutExposedPort")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `protocol` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Protocol) {
+ q = q.Arg("protocol", opts[i].Protocol)
+ }
+ }
+ q = q.Arg("port", port)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutFileOpts contains options for Container.WithoutFile
+type ContainerWithoutFileOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Retrieves this container with the file at the given path removed.
+func (r *Container) WithoutFile(path string, opts ...ContainerWithoutFileOpts) *Container {
+ q := r.query.Select("withoutFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutFilesOpts contains options for Container.WithoutFiles
+type ContainerWithoutFilesOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of paths according to the current environment variables defined in the container (e.g. "/$VAR/foo.txt").
+ Expand bool
+}
+
+// Return a new container spanshot with specified files removed
+func (r *Container) WithoutFiles(paths []string, opts ...ContainerWithoutFilesOpts) *Container {
+ q := r.query.Select("withoutFiles")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("paths", paths)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container minus the given environment label.
+func (r *Container) WithoutLabel(name string) *Container {
+ q := r.query.Select("withoutLabel")
+ q = q.Arg("name", name)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutMountOpts contains options for Container.WithoutMount
+type ContainerWithoutMountOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container after unmounting everything at the given path.
+func (r *Container) WithoutMount(path string, opts ...ContainerWithoutMountOpts) *Container {
+ q := r.query.Select("withoutMount")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container without the registry authentication of a given address.
+func (r *Container) WithoutRegistryAuth(address string) *Container {
+ q := r.query.Select("withoutRegistryAuth")
+ q = q.Arg("address", address)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container minus the given environment variable containing the secret.
+func (r *Container) WithoutSecretVariable(name string) *Container {
+ q := r.query.Select("withoutSecretVariable")
+ q = q.Arg("name", name)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// ContainerWithoutUnixSocketOpts contains options for Container.WithoutUnixSocket
+type ContainerWithoutUnixSocketOpts struct {
+ // Replace "${VAR}" or "$VAR" in the value of path according to the current environment variables defined in the container (e.g. "/$VAR/foo").
+ Expand bool
+}
+
+// Retrieves this container with a previously added Unix socket removed.
+func (r *Container) WithoutUnixSocket(path string, opts ...ContainerWithoutUnixSocketOpts) *Container {
+ q := r.query.Select("withoutUnixSocket")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container with an unset command user.
+//
+// Should default to root.
+func (r *Container) WithoutUser() *Container {
+ q := r.query.Select("withoutUser")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves this container minus the given volatile environment variable.
+func (r *Container) WithoutVolatileVariable(name string) *Container {
+ q := r.query.Select("withoutVolatileVariable")
+ q = q.Arg("name", name)
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Unset the container's working directory.
+//
+// Should default to "/".
+func (r *Container) WithoutWorkdir() *Container {
+ q := r.query.Select("withoutWorkdir")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Retrieves the working directory for all commands.
+func (r *Container) Workdir(ctx context.Context) (string, error) {
+ if r.workdir != nil {
+ return *r.workdir, nil
+ }
+ q := r.query.Select("workdir")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsExportable returns this Container as a Exportable.
+// This is a local type conversion — no GraphQL call.
+func (r *Container) AsExportable() Exportable {
+ return &ExportableClient{
+ query: r.query,
+ }
+}
+
+// AsNode returns this Container as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Container) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this Container as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *Container) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// Reflective module API provided to functions at runtime.
+type CurrentModule struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+}
+
+func (r *CurrentModule) WithGraphQLQuery(q *querybuilder.Selection) *CurrentModule {
+ return &CurrentModule{
+ query: q,
+ }
+}
+
+// Treat the currently executing module as an SDK installed in the active workspace, exposing the modules and clients it manages.
+//
+// Errors if the current module is not installed as an SDK in this workspace.
+func (r *CurrentModule) AsSDK() *CurrentModuleAsSDK {
+ q := r.query.Select("asSDK")
+
+ return &CurrentModuleAsSDK{
+ query: q,
+ }
+}
+
+// The dependencies of the module.
+func (r *CurrentModule) Dependencies(ctx context.Context) ([]Module, error) {
+ q := r.query.Select("dependencies")
+
+ q = q.Select("id")
+
+ type dependencies struct {
+ Id ID
+ }
+
+ convert := func(fields []dependencies) []Module {
+ out := []Module{}
+
+ for i := range fields {
+ val := Module{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Module")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []dependencies
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The generated files and directories made on top of the module source's context directory.
+func (r *CurrentModule) GeneratedContextDirectory() *Directory {
+ q := r.query.Select("generatedContextDirectory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// CurrentModuleGeneratorsOpts contains options for CurrentModule.Generators
+type CurrentModuleGeneratorsOpts struct {
+ // Only include generators matching the specified patterns
+ Include []string
+}
+
+// Return all generators defined by the module
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *CurrentModule) Generators(opts ...CurrentModuleGeneratorsOpts) *GeneratorGroup {
+ q := r.query.Select("generators")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ }
+
+ return &GeneratorGroup{
+ query: q,
+ }
+}
+
+// A unique identifier for this CurrentModule.
+func (r *CurrentModule) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *CurrentModule) XXX_GraphQLType() string {
+ return "CurrentModule"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *CurrentModule) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *CurrentModule) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *CurrentModule) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *CurrentModule) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = CurrentModule{query: selectNode(dag.query, id, "CurrentModule")}
+ return nil
+}
+
+// The name of the module being executed in
+func (r *CurrentModule) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The directory containing the module's source code loaded into the engine (plus any generated code that may have been created).
+func (r *CurrentModule) Source() *Directory {
+ q := r.query.Select("source")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// CurrentModuleWorkdirOpts contains options for CurrentModule.Workdir
+type CurrentModuleWorkdirOpts struct {
+ // Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
+ Exclude []string
+ // Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
+ Include []string
+ // Apply .gitignore filter rules inside the directory
+ Gitignore bool
+}
+
+// Load a directory from the module's scratch working directory, including any changes that may have been made to it during module function execution.
+func (r *CurrentModule) Workdir(path string, opts ...CurrentModuleWorkdirOpts) *Directory {
+ q := r.query.Select("workdir")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.
+func (r *CurrentModule) WorkdirFile(path string) *File {
+ q := r.query.Select("workdirFile")
+ q = q.Arg("path", path)
+
+ return &File{
+ query: q,
+ }
+}
+
+// AsNode returns this CurrentModule as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *CurrentModule) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// The SDK-role data for the currently executing module, as installed in the active workspace.
+type CurrentModuleAsSDK struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+}
+
+func (r *CurrentModuleAsSDK) WithGraphQLQuery(q *querybuilder.Selection) *CurrentModuleAsSDK {
+ return &CurrentModuleAsSDK{
+ query: q,
+ }
+}
+
+// The generated clients this SDK produces in the workspace.
+func (r *CurrentModuleAsSDK) Clients(ctx context.Context) ([]CurrentModuleAsSDKClient, error) {
+ q := r.query.Select("clients")
+
+ q = q.Select("id")
+
+ type clients struct {
+ Id ID
+ }
+
+ convert := func(fields []clients) []CurrentModuleAsSDKClient {
+ out := []CurrentModuleAsSDKClient{}
+
+ for i := range fields {
+ val := CurrentModuleAsSDKClient{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "CurrentModuleAsSDKClient")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []clients
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// A unique identifier for this CurrentModuleAsSDK.
+func (r *CurrentModuleAsSDK) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *CurrentModuleAsSDK) XXX_GraphQLType() string {
+ return "CurrentModuleAsSDK"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *CurrentModuleAsSDK) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *CurrentModuleAsSDK) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *CurrentModuleAsSDK) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *CurrentModuleAsSDK) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = CurrentModuleAsSDK{query: selectNode(dag.query, id, "CurrentModuleAsSDK")}
+ return nil
+}
+
+// The workspace-local modules this SDK authors and manages.
+func (r *CurrentModuleAsSDK) Modules(ctx context.Context) ([]CurrentModuleAsSDKModule, error) {
+ q := r.query.Select("modules")
+
+ q = q.Select("id")
+
+ type modules struct {
+ Id ID
+ }
+
+ convert := func(fields []modules) []CurrentModuleAsSDKModule {
+ out := []CurrentModuleAsSDKModule{}
+
+ for i := range fields {
+ val := CurrentModuleAsSDKModule{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "CurrentModuleAsSDKModule")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []modules
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The user-facing name of this SDK in the workspace.
+func (r *CurrentModuleAsSDK) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this CurrentModuleAsSDK as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *CurrentModuleAsSDK) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A generated client the current SDK produces in the workspace.
+type CurrentModuleAsSDKClient struct {
+ query *querybuilder.Selection
+
+ id *ID
+ module *string
+ path *string
+ pin *string
+}
+
+func (r *CurrentModuleAsSDKClient) WithGraphQLQuery(q *querybuilder.Selection) *CurrentModuleAsSDKClient {
+ return &CurrentModuleAsSDKClient{
+ query: q,
+ }
+}
+
+// A unique identifier for this CurrentModuleAsSDKClient.
+func (r *CurrentModuleAsSDKClient) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *CurrentModuleAsSDKClient) XXX_GraphQLType() string {
+ return "CurrentModuleAsSDKClient"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *CurrentModuleAsSDKClient) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *CurrentModuleAsSDKClient) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *CurrentModuleAsSDKClient) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *CurrentModuleAsSDKClient) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = CurrentModuleAsSDKClient{query: selectNode(dag.query, id, "CurrentModuleAsSDKClient")}
+ return nil
+}
+
+// The module the client is bound to (workspace-relative path or canonical ref).
+func (r *CurrentModuleAsSDKClient) Module(ctx context.Context) (string, error) {
+ if r.module != nil {
+ return *r.module, nil
+ }
+ q := r.query.Select("module")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Workspace-root-relative path of the generated client.
+func (r *CurrentModuleAsSDKClient) Path(ctx context.Context) (string, error) {
+ if r.path != nil {
+ return *r.path, nil
+ }
+ q := r.query.Select("path")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The pinned version of the bound module, if any.
+func (r *CurrentModuleAsSDKClient) Pin(ctx context.Context) (string, error) {
+ if r.pin != nil {
+ return *r.pin, nil
+ }
+ q := r.query.Select("pin")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this CurrentModuleAsSDKClient as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *CurrentModuleAsSDKClient) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A workspace-local module managed by the current SDK.
+type CurrentModuleAsSDKModule struct {
+ query *querybuilder.Selection
+
+ id *ID
+ path *string
+}
+
+func (r *CurrentModuleAsSDKModule) WithGraphQLQuery(q *querybuilder.Selection) *CurrentModuleAsSDKModule {
+ return &CurrentModuleAsSDKModule{
+ query: q,
+ }
+}
+
+// A unique identifier for this CurrentModuleAsSDKModule.
+func (r *CurrentModuleAsSDKModule) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *CurrentModuleAsSDKModule) XXX_GraphQLType() string {
+ return "CurrentModuleAsSDKModule"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *CurrentModuleAsSDKModule) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *CurrentModuleAsSDKModule) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *CurrentModuleAsSDKModule) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *CurrentModuleAsSDKModule) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = CurrentModuleAsSDKModule{query: selectNode(dag.query, id, "CurrentModuleAsSDKModule")}
+ return nil
+}
+
+// Workspace-root-relative path to the managed module.
+func (r *CurrentModuleAsSDKModule) Path(ctx context.Context) (string, error) {
+ if r.path != nil {
+ return *r.path, nil
+ }
+ q := r.query.Select("path")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this CurrentModuleAsSDKModule as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *CurrentModuleAsSDKModule) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type DiffStat struct {
+ query *querybuilder.Selection
+
+ addedLines *int
+ id *ID
+ kind *DiffStatKind
+ oldPath *string
+ path *string
+ removedLines *int
+}
+
+func (r *DiffStat) WithGraphQLQuery(q *querybuilder.Selection) *DiffStat {
+ return &DiffStat{
+ query: q,
+ }
+}
+
+// Number of added lines for this path.
+func (r *DiffStat) AddedLines(ctx context.Context) (int, error) {
+ if r.addedLines != nil {
+ return *r.addedLines, nil
+ }
+ q := r.query.Select("addedLines")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this DiffStat.
+func (r *DiffStat) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *DiffStat) XXX_GraphQLType() string {
+ return "DiffStat"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *DiffStat) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *DiffStat) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *DiffStat) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *DiffStat) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = DiffStat{query: selectNode(dag.query, id, "DiffStat")}
+ return nil
+}
+
+// Type of change.
+func (r *DiffStat) Kind(ctx context.Context) (DiffStatKind, error) {
+ if r.kind != nil {
+ return *r.kind, nil
+ }
+ q := r.query.Select("kind")
+
+ var response DiffStatKind
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Previous path of the file, set only for renames.
+func (r *DiffStat) OldPath(ctx context.Context) (string, error) {
+ if r.oldPath != nil {
+ return *r.oldPath, nil
+ }
+ q := r.query.Select("oldPath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Path of the changed file or directory.
+func (r *DiffStat) Path(ctx context.Context) (string, error) {
+ if r.path != nil {
+ return *r.path, nil
+ }
+ q := r.query.Select("path")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Number of removed lines for this path.
+func (r *DiffStat) RemovedLines(ctx context.Context) (int, error) {
+ if r.removedLines != nil {
+ return *r.removedLines, nil
+ }
+ q := r.query.Select("removedLines")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this DiffStat as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *DiffStat) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A directory.
+type Directory struct {
+ query *querybuilder.Selection
+
+ digest *string
+ exists *bool
+ export *string
+ findUp *string
+ id *ID
+ name *string
+ sync *ID
+}
+type WithDirectoryFunc func(r *Directory) *Directory
+
+// With calls the provided function with current Directory.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Directory) With(f WithDirectoryFunc) *Directory {
+ return f(r)
+}
+
+func (r *Directory) WithGraphQLQuery(q *querybuilder.Selection) *Directory {
+ return &Directory{
+ query: q,
+ }
+}
+
+// Converts this directory to a local git repository
+func (r *Directory) AsGit() *GitRepository {
+ q := r.query.Select("asGit")
+
+ return &GitRepository{
+ query: q,
+ }
+}
+
+// DirectoryAsModuleOpts contains options for Directory.AsModule
+type DirectoryAsModuleOpts struct {
+ // An optional subpath of the directory which contains the module's configuration file.
+ //
+ // If not set, the module source code is loaded from the root of the directory.
+ //
+ // Default: "."
+ SourceRootPath string
+}
+
+// Load the directory as a Dagger module source
+func (r *Directory) AsModule(opts ...DirectoryAsModuleOpts) *Module {
+ q := r.query.Select("asModule")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `sourceRootPath` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceRootPath) {
+ q = q.Arg("sourceRootPath", opts[i].SourceRootPath)
+ }
+ }
+
+ return &Module{
+ query: q,
+ }
+}
+
+// DirectoryAsModuleSourceOpts contains options for Directory.AsModuleSource
+type DirectoryAsModuleSourceOpts struct {
+ // An optional subpath of the directory which contains the module's configuration file.
+ //
+ // If not set, the module source code is loaded from the root of the directory.
+ //
+ // Default: "."
+ SourceRootPath string
+}
+
+// Load the directory as a Dagger module source
+func (r *Directory) AsModuleSource(opts ...DirectoryAsModuleSourceOpts) *ModuleSource {
+ q := r.query.Select("asModuleSource")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `sourceRootPath` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceRootPath) {
+ q = q.Arg("sourceRootPath", opts[i].SourceRootPath)
+ }
+ }
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// DirectoryAsWorkspaceOpts contains options for Directory.AsWorkspace
+type DirectoryAsWorkspaceOpts struct {
+ // Current working directory inside the workspace root. Defaults to the workspace root.
+ //
+ // Default: "/"
+ Cwd string
+}
+
+// Creates a synthetic workspace from this directory.
+func (r *Directory) AsWorkspace(opts ...DirectoryAsWorkspaceOpts) *Workspace {
+ q := r.query.Select("asWorkspace")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `cwd` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Cwd) {
+ q = q.Arg("cwd", opts[i].Cwd)
+ }
+ }
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// Return the difference between this directory and another directory, typically an older snapshot.
+//
+// The difference is encoded as a changeset, which also tracks removed files, and can be applied to other directories.
+func (r *Directory) Changes(from *Directory) *Changeset {
+ assertNotNil("from", from)
+ q := r.query.Select("changes")
+ q = q.Arg("from", from)
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Change the owner of the directory contents recursively.
+func (r *Directory) Chown(path string, owner string) *Directory {
+ q := r.query.Select("chown")
+ q = q.Arg("path", path)
+ q = q.Arg("owner", owner)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return the difference between this directory and an another directory. The difference is encoded as a directory.
+func (r *Directory) Diff(other *Directory) *Directory {
+ assertNotNil("other", other)
+ q := r.query.Select("diff")
+ q = q.Arg("other", other)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return the directory's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
+func (r *Directory) Digest(ctx context.Context) (string, error) {
+ if r.digest != nil {
+ return *r.digest, nil
+ }
+ q := r.query.Select("digest")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieves a directory at the given path.
+func (r *Directory) Directory(path string) *Directory {
+ q := r.query.Select("directory")
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// DirectoryDockerBuildOpts contains options for Directory.DockerBuild
+type DirectoryDockerBuildOpts struct {
+ // Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
+ //
+ // Default: "Dockerfile"
+ Dockerfile string
+ // The platform to build.
+ Platform Platform
+ // Build arguments to use in the build.
+ BuildArgs []BuildArg
+ // Target build stage to build.
+ Target string
+ // Secrets to pass to the build.
+ //
+ // They will be mounted at /run/secrets/[secret-name].
+ Secrets []*Secret
+ // If set, skip the automatic init process injected into containers created by RUN statements.
+ //
+ // This should only be used if the user requires that their exec processes be the pid 1 process in the container. Otherwise it may result in unexpected behavior.
+ NoInit bool
+ // A socket to use for SSH authentication during the build
+ //
+ // (e.g., for Dockerfile RUN --mount=type=ssh instructions).
+ //
+ // Typically obtained via host.unixSocket() pointing to the SSH_AUTH_SOCK.
+ SSH *Socket
+}
+
+// Use Dockerfile compatibility to build a container from this directory. Only use this function for Dockerfile compatibility. Otherwise use the native Container type directly, it is feature-complete and supports all Dockerfile features.
+func (r *Directory) DockerBuild(opts ...DirectoryDockerBuildOpts) *Container {
+ q := r.query.Select("dockerBuild")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `dockerfile` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Dockerfile) {
+ q = q.Arg("dockerfile", opts[i].Dockerfile)
+ }
+ // `platform` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Platform) {
+ q = q.Arg("platform", opts[i].Platform)
+ }
+ // `buildArgs` optional argument
+ if !querybuilder.IsZeroValue(opts[i].BuildArgs) {
+ q = q.Arg("buildArgs", opts[i].BuildArgs)
+ }
+ // `target` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Target) {
+ q = q.Arg("target", opts[i].Target)
+ }
+ // `secrets` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Secrets) {
+ q = q.Arg("secrets", opts[i].Secrets)
+ }
+ // `noInit` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoInit) {
+ q = q.Arg("noInit", opts[i].NoInit)
+ }
+ // `ssh` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SSH) {
+ q = q.Arg("ssh", opts[i].SSH)
+ }
+ }
+
+ return &Container{
+ query: q,
+ }
+}
+
+// DirectoryEntriesOpts contains options for Directory.Entries
+type DirectoryEntriesOpts struct {
+ // Location of the directory to look at (e.g., "/src").
+ Path string
+}
+
+// Returns a list of files and directories at the given path.
+func (r *Directory) Entries(ctx context.Context, opts ...DirectoryEntriesOpts) ([]string, error) {
+ q := r.query.Select("entries")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `path` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Path) {
+ q = q.Arg("path", opts[i].Path)
+ }
+ }
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// DirectoryExistsOpts contains options for Directory.Exists
+type DirectoryExistsOpts struct {
+ // If specified, also validate the type of file (e.g. "REGULAR_TYPE", "DIRECTORY_TYPE", or "SYMLINK_TYPE").
+ ExpectedType ExistsType
+ // If specified, do not follow symlinks.
+ DoNotFollowSymlinks bool
+}
+
+// check if a file or directory exists
+func (r *Directory) Exists(ctx context.Context, path string, opts ...DirectoryExistsOpts) (bool, error) {
+ if r.exists != nil {
+ return *r.exists, nil
+ }
+ q := r.query.Select("exists")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expectedType` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExpectedType) {
+ q = q.Arg("expectedType", opts[i].ExpectedType)
+ }
+ // `doNotFollowSymlinks` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DoNotFollowSymlinks) {
+ q = q.Arg("doNotFollowSymlinks", opts[i].DoNotFollowSymlinks)
+ }
+ }
+ q = q.Arg("path", path)
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// DirectoryExportOpts contains options for Directory.Export
+type DirectoryExportOpts struct {
+ // If true, then the host directory will be wiped clean before exporting so that it exactly matches the directory being exported; this means it will delete any files on the host that aren't in the exported dir. If false (the default), the contents of the directory will be merged with any existing contents of the host directory, leaving any existing files on the host that aren't in the exported directory alone.
+ Wipe bool
+}
+
+// Writes the contents of the directory to a path on the host.
+func (r *Directory) Export(ctx context.Context, path string, opts ...DirectoryExportOpts) (string, error) {
+ if r.export != nil {
+ return *r.export, nil
+ }
+ q := r.query.Select("export")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `wipe` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Wipe) {
+ q = q.Arg("wipe", opts[i].Wipe)
+ }
+ }
+ q = q.Arg("path", path)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieve a file at the given path.
+func (r *Directory) File(path string) *File {
+ q := r.query.Select("file")
+ q = q.Arg("path", path)
+
+ return &File{
+ query: q,
+ }
+}
+
+// DirectoryFilterOpts contains options for Directory.Filter
+type DirectoryFilterOpts struct {
+ // If set, paths matching one of these glob patterns is excluded from the new snapshot. Example: ["node_modules/", ".git*", ".env"]
+ Exclude []string
+ // If set, only paths matching one of these glob patterns is included in the new snapshot. Example: (e.g., ["app/", "package.*"]).
+ Include []string
+ // If set, apply .gitignore rules when filtering the directory.
+ Gitignore bool
+}
+
+// Return a snapshot with some paths included or excluded
+func (r *Directory) Filter(opts ...DirectoryFilterOpts) *Directory {
+ q := r.query.Select("filter")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ }
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Search up the directory tree for a file or directory, and return its path. If no match, return null
+func (r *Directory) FindUp(ctx context.Context, name string, start string) (string, error) {
+ if r.findUp != nil {
+ return *r.findUp, nil
+ }
+ q := r.query.Select("findUp")
+ q = q.Arg("name", name)
+ q = q.Arg("start", start)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Returns a list of files and directories that matche the given pattern.
+func (r *Directory) Glob(ctx context.Context, pattern string) ([]string, error) {
+ q := r.query.Select("glob")
+ q = q.Arg("pattern", pattern)
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Directory.
+func (r *Directory) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Directory) XXX_GraphQLType() string {
+ return "Directory"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Directory) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Directory) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Directory) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Directory) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Directory{query: selectNode(dag.query, id, "Directory")}
+ return nil
+}
+
+// Returns the name of the directory.
+func (r *Directory) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// DirectorySearchOpts contains options for Directory.Search
+type DirectorySearchOpts struct {
+ // Directory or file paths to search
+ Paths []string
+ // Glob patterns to match (e.g., "*.md")
+ Globs []string
+ // Interpret the pattern as a literal string instead of a regular expression.
+ Literal bool
+ // Enable searching across multiple lines.
+ Multiline bool
+ // Allow the . pattern to match newlines in multiline mode.
+ Dotall bool
+ // Enable case-insensitive matching.
+ Insensitive bool
+ // Honor .gitignore, .ignore, and .rgignore files.
+ SkipIgnored bool
+ // Skip hidden files (files starting with .).
+ SkipHidden bool
+ // Only return matching files, not lines and content
+ FilesOnly bool
+ // Limit the number of results to return
+ Limit int
+}
+
+// Searches for content matching the given regular expression or literal string.
+//
+// Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.
+func (r *Directory) Search(ctx context.Context, pattern string, opts ...DirectorySearchOpts) ([]SearchResult, error) {
+ q := r.query.Select("search")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `paths` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Paths) {
+ q = q.Arg("paths", opts[i].Paths)
+ }
+ // `globs` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Globs) {
+ q = q.Arg("globs", opts[i].Globs)
+ }
+ // `literal` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Literal) {
+ q = q.Arg("literal", opts[i].Literal)
+ }
+ // `multiline` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Multiline) {
+ q = q.Arg("multiline", opts[i].Multiline)
+ }
+ // `dotall` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Dotall) {
+ q = q.Arg("dotall", opts[i].Dotall)
+ }
+ // `insensitive` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Insensitive) {
+ q = q.Arg("insensitive", opts[i].Insensitive)
+ }
+ // `skipIgnored` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SkipIgnored) {
+ q = q.Arg("skipIgnored", opts[i].SkipIgnored)
+ }
+ // `skipHidden` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SkipHidden) {
+ q = q.Arg("skipHidden", opts[i].SkipHidden)
+ }
+ // `filesOnly` optional argument
+ if !querybuilder.IsZeroValue(opts[i].FilesOnly) {
+ q = q.Arg("filesOnly", opts[i].FilesOnly)
+ }
+ // `limit` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Limit) {
+ q = q.Arg("limit", opts[i].Limit)
+ }
+ }
+ q = q.Arg("pattern", pattern)
+
+ q = q.Select("id")
+
+ type search struct {
+ Id ID
+ }
+
+ convert := func(fields []search) []SearchResult {
+ out := []SearchResult{}
+
+ for i := range fields {
+ val := SearchResult{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "SearchResult")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []search
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// DirectoryStatOpts contains options for Directory.Stat
+type DirectoryStatOpts struct {
+ // If specified, do not follow symlinks.
+ DoNotFollowSymlinks bool
+}
+
+// Return file status
+func (r *Directory) Stat(path string, opts ...DirectoryStatOpts) *Stat {
+ q := r.query.Select("stat")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `doNotFollowSymlinks` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DoNotFollowSymlinks) {
+ q = q.Arg("doNotFollowSymlinks", opts[i].DoNotFollowSymlinks)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Stat{
+ query: q,
+ }
+}
+
+// Force evaluation in the engine.
+func (r *Directory) Sync(ctx context.Context) (*Directory, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Directory{
+ query: selectNode(q.Root(), id, "Directory"),
+ }, nil
+}
+
+// DirectoryTerminalOpts contains options for Directory.Terminal
+type DirectoryTerminalOpts struct {
+ // If set, override the default container used for the terminal.
+ Container *Container
+ // If set, override the container's default terminal command and invoke these command arguments instead.
+ Cmd []string
+ // Provides Dagger access to the executed command.
+ ExperimentalPrivilegedNesting bool
+ // Execute the command with all root capabilities. This is similar to running a command with "sudo" or executing "docker run" with the "--privileged" flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
+ InsecureRootCapabilities bool
+}
+
+// Opens an interactive terminal in new container with this directory mounted inside.
+func (r *Directory) Terminal(opts ...DirectoryTerminalOpts) *Directory {
+ q := r.query.Select("terminal")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `container` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Container) {
+ q = q.Arg("container", opts[i].Container)
+ }
+ // `cmd` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Cmd) {
+ q = q.Arg("cmd", opts[i].Cmd)
+ }
+ // `experimentalPrivilegedNesting` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) {
+ q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting)
+ }
+ // `insecureRootCapabilities` optional argument
+ if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) {
+ q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities)
+ }
+ }
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return a directory with changes from another directory applied to it.
+func (r *Directory) WithChanges(changes *Changeset) *Directory {
+ assertNotNil("changes", changes)
+ q := r.query.Select("withChanges")
+ q = q.Arg("changes", changes)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// DirectoryWithDirectoryOpts contains options for Directory.WithDirectory
+type DirectoryWithDirectoryOpts struct {
+ // Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
+ Exclude []string
+ // Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
+ Include []string
+ // Apply .gitignore filter rules inside the directory
+ Gitignore bool
+ // A user:group to set for the copied directory and its contents.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+ // Permission given to the copied directory and contents (e.g., 0755).
+ Permissions int
+}
+
+// Return a snapshot with a directory added
+func (r *Directory) WithDirectory(path string, source *Directory, opts ...DirectoryWithDirectoryOpts) *Directory {
+ assertNotNil("source", source)
+ q := r.query.Select("withDirectory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Raise an error.
+func (r *Directory) WithError(err string) *Directory {
+ q := r.query.Select("withError")
+ q = q.Arg("err", err)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// DirectoryWithFileOpts contains options for Directory.WithFile
+type DirectoryWithFileOpts struct {
+ // Permission given to the copied file (e.g., 0600).
+ Permissions int
+ // A user:group to set for the copied directory and its contents.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+}
+
+// Retrieves this directory plus the contents of the given file copied to the given path.
+func (r *Directory) WithFile(path string, source *File, opts ...DirectoryWithFileOpts) *Directory {
+ assertNotNil("source", source)
+ q := r.query.Select("withFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// DirectoryWithFilesOpts contains options for Directory.WithFiles
+type DirectoryWithFilesOpts struct {
+ // Permission given to the copied files (e.g., 0600).
+ Permissions int
+}
+
+// Retrieves this directory plus the contents of the given files copied to the given path.
+func (r *Directory) WithFiles(path string, sources []*File, opts ...DirectoryWithFilesOpts) *Directory {
+ q := r.query.Select("withFiles")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("sources", sources)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// DirectoryWithNewDirectoryOpts contains options for Directory.WithNewDirectory
+type DirectoryWithNewDirectoryOpts struct {
+ // Permission granted to the created directory (e.g., 0777).
+ //
+ // Default: 420
+ Permissions int
+}
+
+// Retrieves this directory plus a new directory created at the given path.
+func (r *Directory) WithNewDirectory(path string, opts ...DirectoryWithNewDirectoryOpts) *Directory {
+ q := r.query.Select("withNewDirectory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// DirectoryWithNewFileOpts contains options for Directory.WithNewFile
+type DirectoryWithNewFileOpts struct {
+ // Permissions of the new file. Example: 0600
+ //
+ // Default: 420
+ Permissions int
+}
+
+// Return a snapshot with a new file added
+func (r *Directory) WithNewFile(path string, contents string, opts ...DirectoryWithNewFileOpts) *Directory {
+ q := r.query.Select("withNewFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("contents", contents)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Retrieves this directory with the given Git-compatible patch applied.
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Directory) WithPatch(patch string) *Directory {
+ q := r.query.Select("withPatch")
+ q = q.Arg("patch", patch)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Retrieves this directory with the given Git-compatible patch file applied.
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Directory) WithPatchFile(patch *File) *Directory {
+ assertNotNil("patch", patch)
+ q := r.query.Select("withPatchFile")
+ q = q.Arg("patch", patch)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return a snapshot with a symlink
+func (r *Directory) WithSymlink(target string, linkName string) *Directory {
+ q := r.query.Select("withSymlink")
+ q = q.Arg("target", target)
+ q = q.Arg("linkName", linkName)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Retrieves this directory with all file/dir timestamps set to the given time.
+func (r *Directory) WithTimestamps(timestamp int) *Directory {
+ q := r.query.Select("withTimestamps")
+ q = q.Arg("timestamp", timestamp)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return a snapshot with a subdirectory removed
+func (r *Directory) WithoutDirectory(path string) *Directory {
+ q := r.query.Select("withoutDirectory")
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return a snapshot with a file removed
+func (r *Directory) WithoutFile(path string) *Directory {
+ q := r.query.Select("withoutFile")
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return a snapshot with files removed
+func (r *Directory) WithoutFiles(paths []string) *Directory {
+ q := r.query.Select("withoutFiles")
+ q = q.Arg("paths", paths)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// AsExportable returns this Directory as a Exportable.
+// This is a local type conversion — no GraphQL call.
+func (r *Directory) AsExportable() Exportable {
+ return &ExportableClient{
+ query: r.query,
+ }
+}
+
+// AsNode returns this Directory as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Directory) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this Directory as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *Directory) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// A definition of a custom enum defined in a Module.
+type EnumTypeDef struct {
+ query *querybuilder.Selection
+
+ description *string
+ id *ID
+ name *string
+ sourceModuleName *string
+}
+
+func (r *EnumTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *EnumTypeDef {
+ return &EnumTypeDef{
+ query: q,
+ }
+}
+
+// A doc string for the enum, if any.
+func (r *EnumTypeDef) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this EnumTypeDef.
+func (r *EnumTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *EnumTypeDef) XXX_GraphQLType() string {
+ return "EnumTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *EnumTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *EnumTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *EnumTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *EnumTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = EnumTypeDef{query: selectNode(dag.query, id, "EnumTypeDef")}
+ return nil
+}
+
+// The members of the enum.
+func (r *EnumTypeDef) Members(ctx context.Context) ([]EnumValueTypeDef, error) {
+ q := r.query.Select("members")
+
+ q = q.Select("id")
+
+ type members struct {
+ Id ID
+ }
+
+ convert := func(fields []members) []EnumValueTypeDef {
+ out := []EnumValueTypeDef{}
+
+ for i := range fields {
+ val := EnumValueTypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "EnumValueTypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []members
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The name of the enum.
+func (r *EnumTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The location of this enum declaration.
+func (r *EnumTypeDef) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// If this EnumTypeDef is associated with a Module, the name of the module. Unset otherwise.
+func (r *EnumTypeDef) SourceModuleName(ctx context.Context) (string, error) {
+ if r.sourceModuleName != nil {
+ return *r.sourceModuleName, nil
+ }
+ q := r.query.Select("sourceModuleName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The members of the enum.
+//
+// Deprecated: use members instead
+func (r *EnumTypeDef) Values(ctx context.Context) ([]EnumValueTypeDef, error) {
+ q := r.query.Select("values")
+
+ q = q.Select("id")
+
+ type values struct {
+ Id ID
+ }
+
+ convert := func(fields []values) []EnumValueTypeDef {
+ out := []EnumValueTypeDef{}
+
+ for i := range fields {
+ val := EnumValueTypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "EnumValueTypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []values
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// AsNode returns this EnumTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *EnumTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A definition of a value in a custom enum defined in a Module.
+type EnumValueTypeDef struct {
+ query *querybuilder.Selection
+
+ deprecated *string
+ description *string
+ id *ID
+ name *string
+ value *string
+}
+
+func (r *EnumValueTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *EnumValueTypeDef {
+ return &EnumValueTypeDef{
+ query: q,
+ }
+}
+
+// The reason this enum member is deprecated, if any.
+func (r *EnumValueTypeDef) Deprecated(ctx context.Context) (string, error) {
+ if r.deprecated != nil {
+ return *r.deprecated, nil
+ }
+ q := r.query.Select("deprecated")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A doc string for the enum member, if any.
+func (r *EnumValueTypeDef) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this EnumValueTypeDef.
+func (r *EnumValueTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *EnumValueTypeDef) XXX_GraphQLType() string {
+ return "EnumValueTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *EnumValueTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *EnumValueTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *EnumValueTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *EnumValueTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = EnumValueTypeDef{query: selectNode(dag.query, id, "EnumValueTypeDef")}
+ return nil
+}
+
+// The name of the enum member.
+func (r *EnumValueTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The location of this enum member declaration.
+func (r *EnumValueTypeDef) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// The value of the enum member
+func (r *EnumValueTypeDef) Value(ctx context.Context) (string, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this EnumValueTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *EnumValueTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type Env struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+type WithEnvFunc func(r *Env) *Env
+
+// With calls the provided function with current Env.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Env) With(f WithEnvFunc) *Env {
+ return f(r)
+}
+
+func (r *Env) WithGraphQLQuery(q *querybuilder.Selection) *Env {
+ return &Env{
+ query: q,
+ }
+}
+
+// Return the check with the given name from the installed modules. Must match exactly one check.
+//
+// Experimental: Checks API is highly experimental and may be removed or replaced entirely.
+func (r *Env) Check(name string) *Check {
+ q := r.query.Select("check")
+ q = q.Arg("name", name)
+
+ return &Check{
+ query: q,
+ }
+}
+
+// EnvChecksOpts contains options for Env.Checks
+type EnvChecksOpts struct {
+ // Only include checks matching the specified patterns
+ Include []string
+ // When true, only return annotated check functions; exclude generate-as-checks
+ NoGenerate bool
+}
+
+// Return all checks defined by the installed modules
+//
+// Experimental: Checks API is highly experimental and may be removed or replaced entirely.
+func (r *Env) Checks(opts ...EnvChecksOpts) *CheckGroup {
+ q := r.query.Select("checks")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `noGenerate` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoGenerate) {
+ q = q.Arg("noGenerate", opts[i].NoGenerate)
+ }
+ }
+
+ return &CheckGroup{
+ query: q,
+ }
+}
+
+// A unique identifier for this Env.
+func (r *Env) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Env) XXX_GraphQLType() string {
+ return "Env"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Env) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Env) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Env) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Env) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Env{query: selectNode(dag.query, id, "Env")}
+ return nil
+}
+
+// Retrieves an input binding by name
+func (r *Env) Input(name string) *Binding {
+ q := r.query.Select("input")
+ q = q.Arg("name", name)
+
+ return &Binding{
+ query: q,
+ }
+}
+
+// Returns all input bindings provided to the environment
+func (r *Env) Inputs(ctx context.Context) ([]Binding, error) {
+ q := r.query.Select("inputs")
+
+ q = q.Select("id")
+
+ type inputs struct {
+ Id ID
+ }
+
+ convert := func(fields []inputs) []Binding {
+ out := []Binding{}
+
+ for i := range fields {
+ val := Binding{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Binding")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []inputs
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Retrieves an output binding by name
+func (r *Env) Output(name string) *Binding {
+ q := r.query.Select("output")
+ q = q.Arg("name", name)
+
+ return &Binding{
+ query: q,
+ }
+}
+
+// Returns all declared output bindings for the environment
+func (r *Env) Outputs(ctx context.Context) ([]Binding, error) {
+ q := r.query.Select("outputs")
+
+ q = q.Select("id")
+
+ type outputs struct {
+ Id ID
+ }
+
+ convert := func(fields []outputs) []Binding {
+ out := []Binding{}
+
+ for i := range fields {
+ val := Binding{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Binding")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []outputs
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// EnvServicesOpts contains options for Env.Services
+type EnvServicesOpts struct {
+ // Only include services matching the specified patterns
+ Include []string
+}
+
+// Return all services defined by the installed modules
+//
+// Experimental: Services API is highly experimental and may be removed or replaced entirely.
+func (r *Env) Services(opts ...EnvServicesOpts) *UpGroup {
+ q := r.query.Select("services")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ }
+
+ return &UpGroup{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Address in the environment
+func (r *Env) WithAddressInput(name string, value *Address, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withAddressInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Address output to be assigned in the environment
+func (r *Env) WithAddressOutput(name string, description string) *Env {
+ q := r.query.Select("withAddressOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type CacheVolume in the environment
+func (r *Env) WithCacheVolumeInput(name string, value *CacheVolume, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCacheVolumeInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired CacheVolume output to be assigned in the environment
+func (r *Env) WithCacheVolumeOutput(name string, description string) *Env {
+ q := r.query.Select("withCacheVolumeOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Changeset in the environment
+func (r *Env) WithChangesetInput(name string, value *Changeset, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withChangesetInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Changeset output to be assigned in the environment
+func (r *Env) WithChangesetOutput(name string, description string) *Env {
+ q := r.query.Select("withChangesetOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type CheckGroup in the environment
+func (r *Env) WithCheckGroupInput(name string, value *CheckGroup, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCheckGroupInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired CheckGroup output to be assigned in the environment
+func (r *Env) WithCheckGroupOutput(name string, description string) *Env {
+ q := r.query.Select("withCheckGroupOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Check in the environment
+func (r *Env) WithCheckInput(name string, value *Check, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCheckInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Check output to be assigned in the environment
+func (r *Env) WithCheckOutput(name string, description string) *Env {
+ q := r.query.Select("withCheckOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Cloud in the environment
+func (r *Env) WithCloudInput(name string, value *Cloud, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCloudInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Cloud output to be assigned in the environment
+func (r *Env) WithCloudOutput(name string, description string) *Env {
+ q := r.query.Select("withCloudOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Container in the environment
+func (r *Env) WithContainerInput(name string, value *Container, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withContainerInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Container output to be assigned in the environment
+func (r *Env) WithContainerOutput(name string, description string) *Env {
+ q := r.query.Select("withContainerOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Installs the current module into the environment, exposing its functions to the model
+//
+// Contextual path arguments will be populated using the environment's workspace.
+func (r *Env) WithCurrentModule() *Env {
+ q := r.query.Select("withCurrentModule")
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type CurrentModuleAsSDKClient in the environment
+func (r *Env) WithCurrentModuleAsSDKClientInput(name string, value *CurrentModuleAsSDKClient, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCurrentModuleAsSDKClientInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired CurrentModuleAsSDKClient output to be assigned in the environment
+func (r *Env) WithCurrentModuleAsSDKClientOutput(name string, description string) *Env {
+ q := r.query.Select("withCurrentModuleAsSDKClientOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type CurrentModuleAsSDK in the environment
+func (r *Env) WithCurrentModuleAsSDKInput(name string, value *CurrentModuleAsSDK, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCurrentModuleAsSDKInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type CurrentModuleAsSDKModule in the environment
+func (r *Env) WithCurrentModuleAsSDKModuleInput(name string, value *CurrentModuleAsSDKModule, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withCurrentModuleAsSDKModuleInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired CurrentModuleAsSDKModule output to be assigned in the environment
+func (r *Env) WithCurrentModuleAsSDKModuleOutput(name string, description string) *Env {
+ q := r.query.Select("withCurrentModuleAsSDKModuleOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired CurrentModuleAsSDK output to be assigned in the environment
+func (r *Env) WithCurrentModuleAsSDKOutput(name string, description string) *Env {
+ q := r.query.Select("withCurrentModuleAsSDKOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type DiffStat in the environment
+func (r *Env) WithDiffStatInput(name string, value *DiffStat, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withDiffStatInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired DiffStat output to be assigned in the environment
+func (r *Env) WithDiffStatOutput(name string, description string) *Env {
+ q := r.query.Select("withDiffStatOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Directory in the environment
+func (r *Env) WithDirectoryInput(name string, value *Directory, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withDirectoryInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Directory output to be assigned in the environment
+func (r *Env) WithDirectoryOutput(name string, description string) *Env {
+ q := r.query.Select("withDirectoryOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type EnvFile in the environment
+func (r *Env) WithEnvFileInput(name string, value *EnvFile, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withEnvFileInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired EnvFile output to be assigned in the environment
+func (r *Env) WithEnvFileOutput(name string, description string) *Env {
+ q := r.query.Select("withEnvFileOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Env in the environment
+func (r *Env) WithEnvInput(name string, value *Env, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withEnvInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Env output to be assigned in the environment
+func (r *Env) WithEnvOutput(name string, description string) *Env {
+ q := r.query.Select("withEnvOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type File in the environment
+func (r *Env) WithFileInput(name string, value *File, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withFileInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired File output to be assigned in the environment
+func (r *Env) WithFileOutput(name string, description string) *Env {
+ q := r.query.Select("withFileOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type GeneratorGroup in the environment
+func (r *Env) WithGeneratorGroupInput(name string, value *GeneratorGroup, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withGeneratorGroupInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired GeneratorGroup output to be assigned in the environment
+func (r *Env) WithGeneratorGroupOutput(name string, description string) *Env {
+ q := r.query.Select("withGeneratorGroupOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Generator in the environment
+func (r *Env) WithGeneratorInput(name string, value *Generator, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withGeneratorInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Generator output to be assigned in the environment
+func (r *Env) WithGeneratorOutput(name string, description string) *Env {
+ q := r.query.Select("withGeneratorOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type GitRef in the environment
+func (r *Env) WithGitRefInput(name string, value *GitRef, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withGitRefInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired GitRef output to be assigned in the environment
+func (r *Env) WithGitRefOutput(name string, description string) *Env {
+ q := r.query.Select("withGitRefOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type GitRepository in the environment
+func (r *Env) WithGitRepositoryInput(name string, value *GitRepository, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withGitRepositoryInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired GitRepository output to be assigned in the environment
+func (r *Env) WithGitRepositoryOutput(name string, description string) *Env {
+ q := r.query.Select("withGitRepositoryOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type HTTPState in the environment
+func (r *Env) WithHTTPStateInput(name string, value *HTTPState, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withHTTPStateInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired HTTPState output to be assigned in the environment
+func (r *Env) WithHTTPStateOutput(name string, description string) *Env {
+ q := r.query.Select("withHTTPStateOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type JSONValue in the environment
+func (r *Env) WithJSONValueInput(name string, value *JSONValue, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withJSONValueInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired JSONValue output to be assigned in the environment
+func (r *Env) WithJSONValueOutput(name string, description string) *Env {
+ q := r.query.Select("withJSONValueOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Sets the main module for this environment (the project being worked on)
+//
+// Contextual path arguments will be populated using the environment's workspace.
+func (r *Env) WithMainModule(module *Module) *Env {
+ assertNotNil("module", module)
+ q := r.query.Select("withMainModule")
+ q = q.Arg("module", module)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Installs a module into the environment, exposing its functions to the model
+//
+// Contextual path arguments will be populated using the environment's workspace.
+//
+// Deprecated: Use withMainModule instead
+func (r *Env) WithModule(module *Module) *Env {
+ assertNotNil("module", module)
+ q := r.query.Select("withModule")
+ q = q.Arg("module", module)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type ModuleConfigClient in the environment
+func (r *Env) WithModuleConfigClientInput(name string, value *ModuleConfigClient, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withModuleConfigClientInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired ModuleConfigClient output to be assigned in the environment
+func (r *Env) WithModuleConfigClientOutput(name string, description string) *Env {
+ q := r.query.Select("withModuleConfigClientOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Module in the environment
+func (r *Env) WithModuleInput(name string, value *Module, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withModuleInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Module output to be assigned in the environment
+func (r *Env) WithModuleOutput(name string, description string) *Env {
+ q := r.query.Select("withModuleOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type ModuleSource in the environment
+func (r *Env) WithModuleSourceInput(name string, value *ModuleSource, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withModuleSourceInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired ModuleSource output to be assigned in the environment
+func (r *Env) WithModuleSourceOutput(name string, description string) *Env {
+ q := r.query.Select("withModuleSourceOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type SearchResult in the environment
+func (r *Env) WithSearchResultInput(name string, value *SearchResult, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withSearchResultInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired SearchResult output to be assigned in the environment
+func (r *Env) WithSearchResultOutput(name string, description string) *Env {
+ q := r.query.Select("withSearchResultOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type SearchSubmatch in the environment
+func (r *Env) WithSearchSubmatchInput(name string, value *SearchSubmatch, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withSearchSubmatchInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired SearchSubmatch output to be assigned in the environment
+func (r *Env) WithSearchSubmatchOutput(name string, description string) *Env {
+ q := r.query.Select("withSearchSubmatchOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Secret in the environment
+func (r *Env) WithSecretInput(name string, value *Secret, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withSecretInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Secret output to be assigned in the environment
+func (r *Env) WithSecretOutput(name string, description string) *Env {
+ q := r.query.Select("withSecretOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Service in the environment
+func (r *Env) WithServiceInput(name string, value *Service, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withServiceInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Service output to be assigned in the environment
+func (r *Env) WithServiceOutput(name string, description string) *Env {
+ q := r.query.Select("withServiceOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Socket in the environment
+func (r *Env) WithSocketInput(name string, value *Socket, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withSocketInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Socket output to be assigned in the environment
+func (r *Env) WithSocketOutput(name string, description string) *Env {
+ q := r.query.Select("withSocketOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Stat in the environment
+func (r *Env) WithStatInput(name string, value *Stat, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withStatInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Stat output to be assigned in the environment
+func (r *Env) WithStatOutput(name string, description string) *Env {
+ q := r.query.Select("withStatOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Provides a string input binding to the environment
+func (r *Env) WithStringInput(name string, value string, description string) *Env {
+ q := r.query.Select("withStringInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declares a desired string output binding
+func (r *Env) WithStringOutput(name string, description string) *Env {
+ q := r.query.Select("withStringOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type UpGroup in the environment
+func (r *Env) WithUpGroupInput(name string, value *UpGroup, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withUpGroupInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired UpGroup output to be assigned in the environment
+func (r *Env) WithUpGroupOutput(name string, description string) *Env {
+ q := r.query.Select("withUpGroupOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Up in the environment
+func (r *Env) WithUpInput(name string, value *Up, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withUpInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Up output to be assigned in the environment
+func (r *Env) WithUpOutput(name string, description string) *Env {
+ q := r.query.Select("withUpOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Returns a new environment with the provided workspace
+func (r *Env) WithWorkspace(workspace *Directory) *Env {
+ assertNotNil("workspace", workspace)
+ q := r.query.Select("withWorkspace")
+ q = q.Arg("workspace", workspace)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type WorkspaceGit in the environment
+func (r *Env) WithWorkspaceGitInput(name string, value *WorkspaceGit, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withWorkspaceGitInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired WorkspaceGit output to be assigned in the environment
+func (r *Env) WithWorkspaceGitOutput(name string, description string) *Env {
+ q := r.query.Select("withWorkspaceGitOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type Workspace in the environment
+func (r *Env) WithWorkspaceInput(name string, value *Workspace, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withWorkspaceInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type WorkspaceMigration in the environment
+func (r *Env) WithWorkspaceMigrationInput(name string, value *WorkspaceMigration, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withWorkspaceMigrationInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired WorkspaceMigration output to be assigned in the environment
+func (r *Env) WithWorkspaceMigrationOutput(name string, description string) *Env {
+ q := r.query.Select("withWorkspaceMigrationOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type WorkspaceMigrationStep in the environment
+func (r *Env) WithWorkspaceMigrationStepInput(name string, value *WorkspaceMigrationStep, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withWorkspaceMigrationStepInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired WorkspaceMigrationStep output to be assigned in the environment
+func (r *Env) WithWorkspaceMigrationStepOutput(name string, description string) *Env {
+ q := r.query.Select("withWorkspaceMigrationStepOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type WorkspaceModule in the environment
+func (r *Env) WithWorkspaceModuleInput(name string, value *WorkspaceModule, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withWorkspaceModuleInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired WorkspaceModule output to be assigned in the environment
+func (r *Env) WithWorkspaceModuleOutput(name string, description string) *Env {
+ q := r.query.Select("withWorkspaceModuleOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Create or update a binding of type WorkspaceModuleSetting in the environment
+func (r *Env) WithWorkspaceModuleSettingInput(name string, value *WorkspaceModuleSetting, description string) *Env {
+ assertNotNil("value", value)
+ q := r.query.Select("withWorkspaceModuleSettingInput")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired WorkspaceModuleSetting output to be assigned in the environment
+func (r *Env) WithWorkspaceModuleSettingOutput(name string, description string) *Env {
+ q := r.query.Select("withWorkspaceModuleSettingOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Declare a desired Workspace output to be assigned in the environment
+func (r *Env) WithWorkspaceOutput(name string, description string) *Env {
+ q := r.query.Select("withWorkspaceOutput")
+ q = q.Arg("name", name)
+ q = q.Arg("description", description)
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Returns a new environment without any outputs
+func (r *Env) WithoutOutputs() *Env {
+ q := r.query.Select("withoutOutputs")
+
+ return &Env{
+ query: q,
+ }
+}
+
+func (r *Env) Workspace() *Directory {
+ q := r.query.Select("workspace")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// AsNode returns this Env as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Env) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A collection of environment variables.
+type EnvFile struct {
+ query *querybuilder.Selection
+
+ exists *bool
+ get *string
+ id *ID
+}
+type WithEnvFileFunc func(r *EnvFile) *EnvFile
+
+// With calls the provided function with current EnvFile.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *EnvFile) With(f WithEnvFileFunc) *EnvFile {
+ return f(r)
+}
+
+func (r *EnvFile) WithGraphQLQuery(q *querybuilder.Selection) *EnvFile {
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// Return as a file
+func (r *EnvFile) AsFile() *File {
+ q := r.query.Select("asFile")
+
+ return &File{
+ query: q,
+ }
+}
+
+// Check if a variable exists
+func (r *EnvFile) Exists(ctx context.Context, name string) (bool, error) {
+ if r.exists != nil {
+ return *r.exists, nil
+ }
+ q := r.query.Select("exists")
+ q = q.Arg("name", name)
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// EnvFileGetOpts contains options for EnvFile.Get
+type EnvFileGetOpts struct {
+ // Return the value exactly as written to the file. No quote removal or variable expansion
+ Raw bool
+}
+
+// Lookup a variable (last occurrence wins) and return its value, or an empty string
+func (r *EnvFile) Get(ctx context.Context, name string, opts ...EnvFileGetOpts) (string, error) {
+ if r.get != nil {
+ return *r.get, nil
+ }
+ q := r.query.Select("get")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `raw` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Raw) {
+ q = q.Arg("raw", opts[i].Raw)
+ }
+ }
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this EnvFile.
+func (r *EnvFile) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *EnvFile) XXX_GraphQLType() string {
+ return "EnvFile"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *EnvFile) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *EnvFile) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *EnvFile) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *EnvFile) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = EnvFile{query: selectNode(dag.query, id, "EnvFile")}
+ return nil
+}
+
+// Filters variables by prefix and removes the pref from keys. Variables without the prefix are excluded. For example, with the prefix "MY_APP_" and variables: MY_APP_TOKEN=topsecret MY_APP_NAME=hello FOO=bar the resulting environment will contain: TOKEN=topsecret NAME=hello
+func (r *EnvFile) Namespace(prefix string) *EnvFile {
+ q := r.query.Select("namespace")
+ q = q.Arg("prefix", prefix)
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// EnvFileVariablesOpts contains options for EnvFile.Variables
+type EnvFileVariablesOpts struct {
+ // Return values exactly as written to the file. No quote removal or variable expansion
+ Raw bool
+}
+
+// Return all variables
+func (r *EnvFile) Variables(ctx context.Context, opts ...EnvFileVariablesOpts) ([]EnvVariable, error) {
+ q := r.query.Select("variables")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `raw` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Raw) {
+ q = q.Arg("raw", opts[i].Raw)
+ }
+ }
+
+ q = q.Select("id")
+
+ type variables struct {
+ Id ID
+ }
+
+ convert := func(fields []variables) []EnvVariable {
+ out := []EnvVariable{}
+
+ for i := range fields {
+ val := EnvVariable{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "EnvVariable")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []variables
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Add a variable
+func (r *EnvFile) WithVariable(name string, value string) *EnvFile {
+ q := r.query.Select("withVariable")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// Remove all occurrences of the named variable
+func (r *EnvFile) WithoutVariable(name string) *EnvFile {
+ q := r.query.Select("withoutVariable")
+ q = q.Arg("name", name)
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// AsNode returns this EnvFile as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *EnvFile) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An environment variable name and value.
+type EnvVariable struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+ value *string
+}
+
+func (r *EnvVariable) WithGraphQLQuery(q *querybuilder.Selection) *EnvVariable {
+ return &EnvVariable{
+ query: q,
+ }
+}
+
+// A unique identifier for this EnvVariable.
+func (r *EnvVariable) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *EnvVariable) XXX_GraphQLType() string {
+ return "EnvVariable"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *EnvVariable) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *EnvVariable) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *EnvVariable) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *EnvVariable) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = EnvVariable{query: selectNode(dag.query, id, "EnvVariable")}
+ return nil
+}
+
+// The environment variable name.
+func (r *EnvVariable) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The environment variable value.
+func (r *EnvVariable) Value(ctx context.Context) (string, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this EnvVariable as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *EnvVariable) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type Error struct {
+ query *querybuilder.Selection
+
+ id *ID
+ message *string
+}
+type WithErrorFunc func(r *Error) *Error
+
+// With calls the provided function with current Error.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Error) With(f WithErrorFunc) *Error {
+ return f(r)
+}
+
+func (r *Error) WithGraphQLQuery(q *querybuilder.Selection) *Error {
+ return &Error{
+ query: q,
+ }
+}
+
+// A unique identifier for this Error.
+func (r *Error) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Error) XXX_GraphQLType() string {
+ return "Error"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Error) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Error) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Error) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Error) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Error{query: selectNode(dag.query, id, "Error")}
+ return nil
+}
+
+// A description of the error.
+func (r *Error) Message(ctx context.Context) (string, error) {
+ if r.message != nil {
+ return *r.message, nil
+ }
+ q := r.query.Select("message")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The extensions of the error.
+func (r *Error) Values(ctx context.Context) ([]ErrorValue, error) {
+ q := r.query.Select("values")
+
+ q = q.Select("id")
+
+ type values struct {
+ Id ID
+ }
+
+ convert := func(fields []values) []ErrorValue {
+ out := []ErrorValue{}
+
+ for i := range fields {
+ val := ErrorValue{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "ErrorValue")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []values
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Add a value to the error.
+func (r *Error) WithValue(name string, value JSON) *Error {
+ q := r.query.Select("withValue")
+ q = q.Arg("name", name)
+ q = q.Arg("value", value)
+
+ return &Error{
+ query: q,
+ }
+}
+
+// AsNode returns this Error as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Error) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type ErrorValue struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+ value *JSON
+}
+
+func (r *ErrorValue) WithGraphQLQuery(q *querybuilder.Selection) *ErrorValue {
+ return &ErrorValue{
+ query: q,
+ }
+}
+
+// A unique identifier for this ErrorValue.
+func (r *ErrorValue) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ErrorValue) XXX_GraphQLType() string {
+ return "ErrorValue"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ErrorValue) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ErrorValue) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ErrorValue) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ErrorValue) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ErrorValue{query: selectNode(dag.query, id, "ErrorValue")}
+ return nil
+}
+
+// The name of the value.
+func (r *ErrorValue) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The value.
+func (r *ErrorValue) Value(ctx context.Context) (JSON, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response JSON
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this ErrorValue as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ErrorValue) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A definition of a field on a custom object defined in a Module.
+//
+// A field on an object has a static value, as opposed to a function on an object whose value is computed by invoking code (and can accept arguments).
+type FieldTypeDef struct {
+ query *querybuilder.Selection
+
+ deprecated *string
+ description *string
+ id *ID
+ name *string
+}
+
+func (r *FieldTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *FieldTypeDef {
+ return &FieldTypeDef{
+ query: q,
+ }
+}
+
+// The reason this enum member is deprecated, if any.
+func (r *FieldTypeDef) Deprecated(ctx context.Context) (string, error) {
+ if r.deprecated != nil {
+ return *r.deprecated, nil
+ }
+ q := r.query.Select("deprecated")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A doc string for the field, if any.
+func (r *FieldTypeDef) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this FieldTypeDef.
+func (r *FieldTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *FieldTypeDef) XXX_GraphQLType() string {
+ return "FieldTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *FieldTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *FieldTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *FieldTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *FieldTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = FieldTypeDef{query: selectNode(dag.query, id, "FieldTypeDef")}
+ return nil
+}
+
+// The name of the field in lowerCamelCase format.
+func (r *FieldTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The location of this field declaration.
+func (r *FieldTypeDef) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// The type of the field.
+func (r *FieldTypeDef) TypeDef() *TypeDef {
+ q := r.query.Select("typeDef")
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// AsNode returns this FieldTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *FieldTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A file.
+type File struct {
+ query *querybuilder.Selection
+
+ contents *string
+ digest *string
+ export *string
+ id *ID
+ name *string
+ size *int
+ sync *ID
+}
+type WithFileFunc func(r *File) *File
+
+// With calls the provided function with current File.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *File) With(f WithFileFunc) *File {
+ return f(r)
+}
+
+func (r *File) WithGraphQLQuery(q *querybuilder.Selection) *File {
+ return &File{
+ query: q,
+ }
+}
+
+// FileAsEnvFileOpts contains options for File.AsEnvFile
+type FileAsEnvFileOpts struct {
+ // Replace "${VAR}" or "$VAR" with the value of other vars
+ // Deprecated: Variable expansion is now enabled by default
+ Expand bool
+}
+
+// Parse as an env file
+func (r *File) AsEnvFile(opts ...FileAsEnvFileOpts) *EnvFile {
+ q := r.query.Select("asEnvFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// Parse the file contents as JSON.
+func (r *File) AsJSON() *JSONValue {
+ q := r.query.Select("asJSON")
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Change the owner of the file recursively.
+func (r *File) Chown(owner string) *File {
+ q := r.query.Select("chown")
+ q = q.Arg("owner", owner)
+
+ return &File{
+ query: q,
+ }
+}
+
+// FileContentsOpts contains options for File.Contents
+type FileContentsOpts struct {
+ // Start reading after this line
+ OffsetLines int
+ // Maximum number of lines to read
+ LimitLines int
+}
+
+// Retrieves the contents of the file.
+func (r *File) Contents(ctx context.Context, opts ...FileContentsOpts) (string, error) {
+ if r.contents != nil {
+ return *r.contents, nil
+ }
+ q := r.query.Select("contents")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `offsetLines` optional argument
+ if !querybuilder.IsZeroValue(opts[i].OffsetLines) {
+ q = q.Arg("offsetLines", opts[i].OffsetLines)
+ }
+ // `limitLines` optional argument
+ if !querybuilder.IsZeroValue(opts[i].LimitLines) {
+ q = q.Arg("limitLines", opts[i].LimitLines)
+ }
+ }
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// FileDigestOpts contains options for File.Digest
+type FileDigestOpts struct {
+ // If true, exclude metadata from the digest.
+ ExcludeMetadata bool
+}
+
+// Return the file's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
+func (r *File) Digest(ctx context.Context, opts ...FileDigestOpts) (string, error) {
+ if r.digest != nil {
+ return *r.digest, nil
+ }
+ q := r.query.Select("digest")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `excludeMetadata` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExcludeMetadata) {
+ q = q.Arg("excludeMetadata", opts[i].ExcludeMetadata)
+ }
+ }
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// FileExportOpts contains options for File.Export
+type FileExportOpts struct {
+ // If allowParentDirPath is true, the path argument can be a directory path, in which case the file will be created in that directory.
+ AllowParentDirPath bool
+}
+
+// Writes the file to a file path on the host.
+func (r *File) Export(ctx context.Context, path string, opts ...FileExportOpts) (string, error) {
+ if r.export != nil {
+ return *r.export, nil
+ }
+ q := r.query.Select("export")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `allowParentDirPath` optional argument
+ if !querybuilder.IsZeroValue(opts[i].AllowParentDirPath) {
+ q = q.Arg("allowParentDirPath", opts[i].AllowParentDirPath)
+ }
+ }
+ q = q.Arg("path", path)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this File.
+func (r *File) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *File) XXX_GraphQLType() string {
+ return "File"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *File) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *File) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *File) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *File) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = File{query: selectNode(dag.query, id, "File")}
+ return nil
+}
+
+// Retrieves the name of the file.
+func (r *File) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// FileSearchOpts contains options for File.Search
+type FileSearchOpts struct {
+ // Interpret the pattern as a literal string instead of a regular expression.
+ Literal bool
+ // Enable searching across multiple lines.
+ Multiline bool
+ // Allow the . pattern to match newlines in multiline mode.
+ Dotall bool
+ // Enable case-insensitive matching.
+ Insensitive bool
+ // Honor .gitignore, .ignore, and .rgignore files.
+ SkipIgnored bool
+ // Skip hidden files (files starting with .).
+ SkipHidden bool
+ // Only return matching files, not lines and content
+ FilesOnly bool
+ // Limit the number of results to return
+ Limit int
+
+ Paths []string
+
+ Globs []string
+}
+
+// Searches for content matching the given regular expression or literal string.
+//
+// Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.
+func (r *File) Search(ctx context.Context, pattern string, opts ...FileSearchOpts) ([]SearchResult, error) {
+ q := r.query.Select("search")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `literal` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Literal) {
+ q = q.Arg("literal", opts[i].Literal)
+ }
+ // `multiline` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Multiline) {
+ q = q.Arg("multiline", opts[i].Multiline)
+ }
+ // `dotall` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Dotall) {
+ q = q.Arg("dotall", opts[i].Dotall)
+ }
+ // `insensitive` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Insensitive) {
+ q = q.Arg("insensitive", opts[i].Insensitive)
+ }
+ // `skipIgnored` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SkipIgnored) {
+ q = q.Arg("skipIgnored", opts[i].SkipIgnored)
+ }
+ // `skipHidden` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SkipHidden) {
+ q = q.Arg("skipHidden", opts[i].SkipHidden)
+ }
+ // `filesOnly` optional argument
+ if !querybuilder.IsZeroValue(opts[i].FilesOnly) {
+ q = q.Arg("filesOnly", opts[i].FilesOnly)
+ }
+ // `limit` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Limit) {
+ q = q.Arg("limit", opts[i].Limit)
+ }
+ // `paths` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Paths) {
+ q = q.Arg("paths", opts[i].Paths)
+ }
+ // `globs` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Globs) {
+ q = q.Arg("globs", opts[i].Globs)
+ }
+ }
+ q = q.Arg("pattern", pattern)
+
+ q = q.Select("id")
+
+ type search struct {
+ Id ID
+ }
+
+ convert := func(fields []search) []SearchResult {
+ out := []SearchResult{}
+
+ for i := range fields {
+ val := SearchResult{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "SearchResult")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []search
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Retrieves the size of the file, in bytes.
+func (r *File) Size(ctx context.Context) (int, error) {
+ if r.size != nil {
+ return *r.size, nil
+ }
+ q := r.query.Select("size")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return file status
+func (r *File) Stat() *Stat {
+ q := r.query.Select("stat")
+
+ return &Stat{
+ query: q,
+ }
+}
+
+// Force evaluation in the engine.
+func (r *File) Sync(ctx context.Context) (*File, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &File{
+ query: selectNode(q.Root(), id, "File"),
+ }, nil
+}
+
+// Retrieves this file with its name set to the given name.
+func (r *File) WithName(name string) *File {
+ q := r.query.Select("withName")
+ q = q.Arg("name", name)
+
+ return &File{
+ query: q,
+ }
+}
+
+// FileWithReplacedOpts contains options for File.WithReplaced
+type FileWithReplacedOpts struct {
+ // Replace all occurrences of the pattern.
+ All bool
+ // Replace the first match starting from the specified line.
+ FirstFrom int
+}
+
+// Retrieves the file with content replaced with the given text.
+//
+// If 'all' is true, all occurrences of the pattern will be replaced.
+//
+// If 'firstAfter' is specified, only the first match starting at the specified line will be replaced.
+//
+// If neither are specified, and there are multiple matches for the pattern, this will error.
+//
+// If there are no matches for the pattern, this will error.
+func (r *File) WithReplaced(search string, replacement string, opts ...FileWithReplacedOpts) *File {
+ q := r.query.Select("withReplaced")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `all` optional argument
+ if !querybuilder.IsZeroValue(opts[i].All) {
+ q = q.Arg("all", opts[i].All)
+ }
+ // `firstFrom` optional argument
+ if !querybuilder.IsZeroValue(opts[i].FirstFrom) {
+ q = q.Arg("firstFrom", opts[i].FirstFrom)
+ }
+ }
+ q = q.Arg("search", search)
+ q = q.Arg("replacement", replacement)
+
+ return &File{
+ query: q,
+ }
+}
+
+// Retrieves this file with its created/modified timestamps set to the given time.
+func (r *File) WithTimestamps(timestamp int) *File {
+ q := r.query.Select("withTimestamps")
+ q = q.Arg("timestamp", timestamp)
+
+ return &File{
+ query: q,
+ }
+}
+
+// AsExportable returns this File as a Exportable.
+// This is a local type conversion — no GraphQL call.
+func (r *File) AsExportable() Exportable {
+ return &ExportableClient{
+ query: r.query,
+ }
+}
+
+// AsNode returns this File as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *File) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this File as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *File) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// Function represents a resolver provided by a Module.
+//
+// A function always evaluates against a parent object and is given a set of named arguments.
+type Function struct {
+ query *querybuilder.Selection
+
+ deprecated *string
+ description *string
+ id *ID
+ name *string
+ sourceModuleName *string
+}
+type WithFunctionFunc func(r *Function) *Function
+
+// With calls the provided function with current Function.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Function) With(f WithFunctionFunc) *Function {
+ return f(r)
+}
+
+func (r *Function) WithGraphQLQuery(q *querybuilder.Selection) *Function {
+ return &Function{
+ query: q,
+ }
+}
+
+// Arguments accepted by the function, if any.
+func (r *Function) Args(ctx context.Context) ([]FunctionArg, error) {
+ q := r.query.Select("args")
+
+ q = q.Select("id")
+
+ type args struct {
+ Id ID
+ }
+
+ convert := func(fields []args) []FunctionArg {
+ out := []FunctionArg{}
+
+ for i := range fields {
+ val := FunctionArg{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "FunctionArg")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []args
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The reason this function is deprecated, if any.
+func (r *Function) Deprecated(ctx context.Context) (string, error) {
+ if r.deprecated != nil {
+ return *r.deprecated, nil
+ }
+ q := r.query.Select("deprecated")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A doc string for the function, if any.
+func (r *Function) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Function.
+func (r *Function) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Function) XXX_GraphQLType() string {
+ return "Function"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Function) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Function) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Function) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Function) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Function{query: selectNode(dag.query, id, "Function")}
+ return nil
+}
+
+// The name of the function.
+func (r *Function) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The type returned by the function.
+func (r *Function) ReturnType() *TypeDef {
+ q := r.query.Select("returnType")
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// The location of this function declaration.
+func (r *Function) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// If this function is provided by a module, the name of the module. Unset otherwise.
+func (r *Function) SourceModuleName(ctx context.Context) (string, error) {
+ if r.sourceModuleName != nil {
+ return *r.sourceModuleName, nil
+ }
+ q := r.query.Select("sourceModuleName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// FunctionWithArgOpts contains options for Function.WithArg
+type FunctionWithArgOpts struct {
+ // A doc string for the argument, if any
+ Description string
+ // A default value to use for this argument if not explicitly set by the caller, if any
+ DefaultValue JSON
+ // If the argument is a Directory or File type, default to load path from context directory, relative to root directory.
+ DefaultPath string
+ // Patterns to ignore when loading the contextual argument value.
+ Ignore []string
+ // The source map for the argument definition.
+ SourceMap *SourceMap
+ // If deprecated, the reason or migration path.
+ Deprecated string
+
+ DefaultAddress string
+}
+
+// Returns the function with the provided argument
+func (r *Function) WithArg(name string, typeDef *TypeDef, opts ...FunctionWithArgOpts) *Function {
+ assertNotNil("typeDef", typeDef)
+ q := r.query.Select("withArg")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `defaultValue` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DefaultValue) {
+ q = q.Arg("defaultValue", opts[i].DefaultValue)
+ }
+ // `defaultPath` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DefaultPath) {
+ q = q.Arg("defaultPath", opts[i].DefaultPath)
+ }
+ // `ignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Ignore) {
+ q = q.Arg("ignore", opts[i].Ignore)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ // `deprecated` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Deprecated) {
+ q = q.Arg("deprecated", opts[i].Deprecated)
+ }
+ // `defaultAddress` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DefaultAddress) {
+ q = q.Arg("defaultAddress", opts[i].DefaultAddress)
+ }
+ }
+ q = q.Arg("name", name)
+ q = q.Arg("typeDef", typeDef)
+
+ return &Function{
+ query: q,
+ }
+}
+
+// FunctionWithCachePolicyOpts contains options for Function.WithCachePolicy
+type FunctionWithCachePolicyOpts struct {
+ // The TTL for the cache policy, if applicable. Provided as a duration string, e.g. "5m", "1h30s".
+ TimeToLive string
+}
+
+// Returns the function updated to use the provided cache policy.
+func (r *Function) WithCachePolicy(policy FunctionCachePolicy, opts ...FunctionWithCachePolicyOpts) *Function {
+ q := r.query.Select("withCachePolicy")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `timeToLive` optional argument
+ if !querybuilder.IsZeroValue(opts[i].TimeToLive) {
+ q = q.Arg("timeToLive", opts[i].TimeToLive)
+ }
+ }
+ q = q.Arg("policy", policy)
+
+ return &Function{
+ query: q,
+ }
+}
+
+// Returns the function with a flag indicating it's a check.
+func (r *Function) WithCheck() *Function {
+ q := r.query.Select("withCheck")
+
+ return &Function{
+ query: q,
+ }
+}
+
+// FunctionWithDeprecatedOpts contains options for Function.WithDeprecated
+type FunctionWithDeprecatedOpts struct {
+ // Reason or migration path describing the deprecation.
+ Reason string
+}
+
+// Returns the function with the provided deprecation reason.
+func (r *Function) WithDeprecated(opts ...FunctionWithDeprecatedOpts) *Function {
+ q := r.query.Select("withDeprecated")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `reason` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Reason) {
+ q = q.Arg("reason", opts[i].Reason)
+ }
+ }
+
+ return &Function{
+ query: q,
+ }
+}
+
+// Returns the function with the given doc string.
+func (r *Function) WithDescription(description string) *Function {
+ q := r.query.Select("withDescription")
+ q = q.Arg("description", description)
+
+ return &Function{
+ query: q,
+ }
+}
+
+// Returns the function with a flag indicating it's a generator.
+func (r *Function) WithGenerator() *Function {
+ q := r.query.Select("withGenerator")
+
+ return &Function{
+ query: q,
+ }
+}
+
+// Returns the function with the given source map.
+func (r *Function) WithSourceMap(sourceMap *SourceMap) *Function {
+ assertNotNil("sourceMap", sourceMap)
+ q := r.query.Select("withSourceMap")
+ q = q.Arg("sourceMap", sourceMap)
+
+ return &Function{
+ query: q,
+ }
+}
+
+// Returns the function with a flag indicating it returns a service for dagger up.
+func (r *Function) WithUp() *Function {
+ q := r.query.Select("withUp")
+
+ return &Function{
+ query: q,
+ }
+}
+
+// AsNode returns this Function as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Function) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An argument accepted by a function.
+//
+// This is a specification for an argument at function definition time, not an argument passed at function call time.
+type FunctionArg struct {
+ query *querybuilder.Selection
+
+ defaultAddress *string
+ defaultPath *string
+ defaultValue *JSON
+ deprecated *string
+ description *string
+ id *ID
+ name *string
+}
+
+func (r *FunctionArg) WithGraphQLQuery(q *querybuilder.Selection) *FunctionArg {
+ return &FunctionArg{
+ query: q,
+ }
+}
+
+// Only applies to arguments of type Container. If the argument is not set, load it from the given address (e.g. alpine:latest)
+func (r *FunctionArg) DefaultAddress(ctx context.Context) (string, error) {
+ if r.defaultAddress != nil {
+ return *r.defaultAddress, nil
+ }
+ q := r.query.Select("defaultAddress")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Only applies to arguments of type File or Directory. If the argument is not set, load it from the given path in the context directory
+func (r *FunctionArg) DefaultPath(ctx context.Context) (string, error) {
+ if r.defaultPath != nil {
+ return *r.defaultPath, nil
+ }
+ q := r.query.Select("defaultPath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A default value to use for this argument when not explicitly set by the caller, if any.
+func (r *FunctionArg) DefaultValue(ctx context.Context) (JSON, error) {
+ if r.defaultValue != nil {
+ return *r.defaultValue, nil
+ }
+ q := r.query.Select("defaultValue")
+
+ var response JSON
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The reason this function is deprecated, if any.
+func (r *FunctionArg) Deprecated(ctx context.Context) (string, error) {
+ if r.deprecated != nil {
+ return *r.deprecated, nil
+ }
+ q := r.query.Select("deprecated")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A doc string for the argument, if any.
+func (r *FunctionArg) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this FunctionArg.
+func (r *FunctionArg) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *FunctionArg) XXX_GraphQLType() string {
+ return "FunctionArg"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *FunctionArg) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *FunctionArg) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *FunctionArg) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *FunctionArg) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = FunctionArg{query: selectNode(dag.query, id, "FunctionArg")}
+ return nil
+}
+
+// Only applies to arguments of type Directory. The ignore patterns are applied to the input directory, and matching entries are filtered out, in a cache-efficient manner.
+func (r *FunctionArg) Ignore(ctx context.Context) ([]string, error) {
+ q := r.query.Select("ignore")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The name of the argument in lowerCamelCase format.
+func (r *FunctionArg) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The location of this arg declaration.
+func (r *FunctionArg) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// The type of the argument.
+func (r *FunctionArg) TypeDef() *TypeDef {
+ q := r.query.Select("typeDef")
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// AsNode returns this FunctionArg as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *FunctionArg) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An active function call.
+type FunctionCall struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+ parent *JSON
+ parentName *string
+ returnError *Void
+ returnValue *Void
+}
+
+func (r *FunctionCall) WithGraphQLQuery(q *querybuilder.Selection) *FunctionCall {
+ return &FunctionCall{
+ query: q,
+ }
+}
+
+// A unique identifier for this FunctionCall.
+func (r *FunctionCall) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *FunctionCall) XXX_GraphQLType() string {
+ return "FunctionCall"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *FunctionCall) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *FunctionCall) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *FunctionCall) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *FunctionCall) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = FunctionCall{query: selectNode(dag.query, id, "FunctionCall")}
+ return nil
+}
+
+// The argument values the function is being invoked with.
+func (r *FunctionCall) InputArgs(ctx context.Context) ([]FunctionCallArgValue, error) {
+ q := r.query.Select("inputArgs")
+
+ q = q.Select("id")
+
+ type inputArgs struct {
+ Id ID
+ }
+
+ convert := func(fields []inputArgs) []FunctionCallArgValue {
+ out := []FunctionCallArgValue{}
+
+ for i := range fields {
+ val := FunctionCallArgValue{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "FunctionCallArgValue")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []inputArgs
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The name of the function being called.
+func (r *FunctionCall) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The value of the parent object of the function being called. If the function is top-level to the module, this is always an empty object.
+func (r *FunctionCall) Parent(ctx context.Context) (JSON, error) {
+ if r.parent != nil {
+ return *r.parent, nil
+ }
+ q := r.query.Select("parent")
+
+ var response JSON
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The name of the parent object of the function being called. If the function is top-level to the module, this is the name of the module.
+func (r *FunctionCall) ParentName(ctx context.Context) (string, error) {
+ if r.parentName != nil {
+ return *r.parentName, nil
+ }
+ q := r.query.Select("parentName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return an error from the function.
+func (r *FunctionCall) ReturnError(ctx context.Context, error *Error) error {
+ assertNotNil("error", error)
+ if r.returnError != nil {
+ return nil
+ }
+ q := r.query.Select("returnError")
+ q = q.Arg("error", error)
+
+ return q.Execute(ctx)
+}
+
+// Set the return value of the function call to the provided value.
+func (r *FunctionCall) ReturnValue(ctx context.Context, value JSON) error {
+ if r.returnValue != nil {
+ return nil
+ }
+ q := r.query.Select("returnValue")
+ q = q.Arg("value", value)
+
+ return q.Execute(ctx)
+}
+
+// AsNode returns this FunctionCall as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *FunctionCall) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A value passed as a named argument to a function call.
+type FunctionCallArgValue struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+ value *JSON
+}
+
+func (r *FunctionCallArgValue) WithGraphQLQuery(q *querybuilder.Selection) *FunctionCallArgValue {
+ return &FunctionCallArgValue{
+ query: q,
+ }
+}
+
+// A unique identifier for this FunctionCallArgValue.
+func (r *FunctionCallArgValue) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *FunctionCallArgValue) XXX_GraphQLType() string {
+ return "FunctionCallArgValue"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *FunctionCallArgValue) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *FunctionCallArgValue) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *FunctionCallArgValue) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *FunctionCallArgValue) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = FunctionCallArgValue{query: selectNode(dag.query, id, "FunctionCallArgValue")}
+ return nil
+}
+
+// The name of the argument.
+func (r *FunctionCallArgValue) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The value of the argument represented as a JSON serialized string.
+func (r *FunctionCallArgValue) Value(ctx context.Context) (JSON, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response JSON
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this FunctionCallArgValue as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *FunctionCallArgValue) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// The result of running an SDK's codegen.
+type GeneratedCode struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+type WithGeneratedCodeFunc func(r *GeneratedCode) *GeneratedCode
+
+// With calls the provided function with current GeneratedCode.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *GeneratedCode) With(f WithGeneratedCodeFunc) *GeneratedCode {
+ return f(r)
+}
+
+func (r *GeneratedCode) WithGraphQLQuery(q *querybuilder.Selection) *GeneratedCode {
+ return &GeneratedCode{
+ query: q,
+ }
+}
+
+// The directory containing the generated code.
+func (r *GeneratedCode) Code() *Directory {
+ q := r.query.Select("code")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// A unique identifier for this GeneratedCode.
+func (r *GeneratedCode) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *GeneratedCode) XXX_GraphQLType() string {
+ return "GeneratedCode"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *GeneratedCode) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *GeneratedCode) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *GeneratedCode) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *GeneratedCode) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = GeneratedCode{query: selectNode(dag.query, id, "GeneratedCode")}
+ return nil
+}
+
+// List of paths to mark generated in version control (i.e. .gitattributes).
+func (r *GeneratedCode) VcsGeneratedPaths(ctx context.Context) ([]string, error) {
+ q := r.query.Select("vcsGeneratedPaths")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// List of paths to ignore in version control (i.e. .gitignore).
+func (r *GeneratedCode) VcsIgnoredPaths(ctx context.Context) ([]string, error) {
+ q := r.query.Select("vcsIgnoredPaths")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Set the list of paths to mark generated in version control.
+func (r *GeneratedCode) WithVCSGeneratedPaths(paths []string) *GeneratedCode {
+ q := r.query.Select("withVCSGeneratedPaths")
+ q = q.Arg("paths", paths)
+
+ return &GeneratedCode{
+ query: q,
+ }
+}
+
+// Set the list of paths to ignore in version control.
+func (r *GeneratedCode) WithVCSIgnoredPaths(paths []string) *GeneratedCode {
+ q := r.query.Select("withVCSIgnoredPaths")
+ q = q.Arg("paths", paths)
+
+ return &GeneratedCode{
+ query: q,
+ }
+}
+
+// AsNode returns this GeneratedCode as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *GeneratedCode) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type Generator struct {
+ query *querybuilder.Selection
+
+ completed *bool
+ description *string
+ id *ID
+ isEmpty *bool
+ name *string
+}
+type WithGeneratorFunc func(r *Generator) *Generator
+
+// With calls the provided function with current Generator.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Generator) With(f WithGeneratorFunc) *Generator {
+ return f(r)
+}
+
+func (r *Generator) WithGraphQLQuery(q *querybuilder.Selection) *Generator {
+ return &Generator{
+ query: q,
+ }
+}
+
+// The generated changeset from the last run
+func (r *Generator) Changes() *Changeset {
+ q := r.query.Select("changes")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Whether the generator complete
+func (r *Generator) Completed(ctx context.Context) (bool, error) {
+ if r.completed != nil {
+ return *r.completed, nil
+ }
+ q := r.query.Select("completed")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return the description of the generator
+func (r *Generator) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Generator.
+func (r *Generator) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Generator) XXX_GraphQLType() string {
+ return "Generator"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Generator) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Generator) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Generator) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Generator) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Generator{query: selectNode(dag.query, id, "Generator")}
+ return nil
+}
+
+// Whether changeset from the last generator run is empty or not
+func (r *Generator) IsEmpty(ctx context.Context) (bool, error) {
+ if r.isEmpty != nil {
+ return *r.isEmpty, nil
+ }
+ q := r.query.Select("isEmpty")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return the fully qualified name of the generator
+func (r *Generator) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The original module in which the generator has been defined
+func (r *Generator) OriginalModule() *Module {
+ q := r.query.Select("originalModule")
+
+ return &Module{
+ query: q,
+ }
+}
+
+// The path of the generator within its module
+func (r *Generator) Path(ctx context.Context) ([]string, error) {
+ q := r.query.Select("path")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Execute the generator
+func (r *Generator) Run() *Generator {
+ q := r.query.Select("run")
+
+ return &Generator{
+ query: q,
+ }
+}
+
+// AsNode returns this Generator as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Generator) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type GeneratorGroup struct {
+ query *querybuilder.Selection
+
+ id *ID
+ isEmpty *bool
+}
+type WithGeneratorGroupFunc func(r *GeneratorGroup) *GeneratorGroup
+
+// With calls the provided function with current GeneratorGroup.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *GeneratorGroup) With(f WithGeneratorGroupFunc) *GeneratorGroup {
+ return f(r)
+}
+
+func (r *GeneratorGroup) WithGraphQLQuery(q *querybuilder.Selection) *GeneratorGroup {
+ return &GeneratorGroup{
+ query: q,
+ }
+}
+
+// GeneratorGroupChangesOpts contains options for GeneratorGroup.Changes
+type GeneratorGroupChangesOpts struct {
+ // Strategy to apply on conflicts between generators
+ //
+ // Default: FAIL_EARLY
+ OnConflict ChangesetsMergeConflict
+}
+
+// The combined changes from the last run of the generators
+//
+// If any conflict occurs, for instance if the same file is modified by multiple generators, or if a file is both modified and deleted, an error is raised and the merge of the changesets will failed.
+//
+// Set 'continueOnConflicts' flag to force to merge the changes in a 'last write wins' strategy.
+func (r *GeneratorGroup) Changes(opts ...GeneratorGroupChangesOpts) *Changeset {
+ q := r.query.Select("changes")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `onConflict` optional argument
+ if !querybuilder.IsZeroValue(opts[i].OnConflict) {
+ q = q.Arg("onConflict", opts[i].OnConflict)
+ }
+ }
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// A unique identifier for this GeneratorGroup.
+func (r *GeneratorGroup) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *GeneratorGroup) XXX_GraphQLType() string {
+ return "GeneratorGroup"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *GeneratorGroup) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *GeneratorGroup) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *GeneratorGroup) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *GeneratorGroup) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = GeneratorGroup{query: selectNode(dag.query, id, "GeneratorGroup")}
+ return nil
+}
+
+// Whether the generated changeset from the last run is empty or not
+func (r *GeneratorGroup) IsEmpty(ctx context.Context) (bool, error) {
+ if r.isEmpty != nil {
+ return *r.isEmpty, nil
+ }
+ q := r.query.Select("isEmpty")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return a list of individual generators and their details
+func (r *GeneratorGroup) List(ctx context.Context) ([]Generator, error) {
+ q := r.query.Select("list")
+
+ q = q.Select("id")
+
+ type list struct {
+ Id ID
+ }
+
+ convert := func(fields []list) []Generator {
+ out := []Generator{}
+
+ for i := range fields {
+ val := Generator{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Generator")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []list
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Execute all selected generators
+func (r *GeneratorGroup) Run() *GeneratorGroup {
+ q := r.query.Select("run")
+
+ return &GeneratorGroup{
+ query: q,
+ }
+}
+
+// AsNode returns this GeneratorGroup as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *GeneratorGroup) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A git ref (tag, branch, or commit).
+type GitRef struct {
+ query *querybuilder.Selection
+
+ commit *string
+ id *ID
+ ref *string
+}
+type WithGitRefFunc func(r *GitRef) *GitRef
+
+// With calls the provided function with current GitRef.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *GitRef) With(f WithGitRefFunc) *GitRef {
+ return f(r)
+}
+
+func (r *GitRef) WithGraphQLQuery(q *querybuilder.Selection) *GitRef {
+ return &GitRef{
+ query: q,
+ }
+}
+
+// GitRefAsWorkspaceOpts contains options for GitRef.AsWorkspace
+type GitRefAsWorkspaceOpts struct {
+ // Current working directory inside the workspace root. Defaults to the workspace root.
+ //
+ // Default: "/"
+ Cwd string
+}
+
+// Creates a synthetic workspace from this git ref.
+func (r *GitRef) AsWorkspace(opts ...GitRefAsWorkspaceOpts) *Workspace {
+ q := r.query.Select("asWorkspace")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `cwd` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Cwd) {
+ q = q.Arg("cwd", opts[i].Cwd)
+ }
+ }
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// The resolved commit id at this ref.
+func (r *GitRef) Commit(ctx context.Context) (string, error) {
+ if r.commit != nil {
+ return *r.commit, nil
+ }
+ q := r.query.Select("commit")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Find the best common ancestor between this ref and another ref.
+func (r *GitRef) CommonAncestor(other *GitRef) *GitRef {
+ assertNotNil("other", other)
+ q := r.query.Select("commonAncestor")
+ q = q.Arg("other", other)
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// A unique identifier for this GitRef.
+func (r *GitRef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *GitRef) XXX_GraphQLType() string {
+ return "GitRef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *GitRef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *GitRef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *GitRef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *GitRef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = GitRef{query: selectNode(dag.query, id, "GitRef")}
+ return nil
+}
+
+// The resolved ref name at this ref.
+func (r *GitRef) Ref(ctx context.Context) (string, error) {
+ if r.ref != nil {
+ return *r.ref, nil
+ }
+ q := r.query.Select("ref")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// GitRefTreeOpts contains options for GitRef.Tree
+type GitRefTreeOpts struct {
+ // Set to true to discard .git directory.
+ DiscardGitDir bool
+ // The depth of the tree to fetch.
+ //
+ // Default: 1
+ Depth int
+ // Set to true to populate tag refs in the local checkout .git.
+ IncludeTags bool
+}
+
+// The filesystem tree at this ref.
+func (r *GitRef) Tree(opts ...GitRefTreeOpts) *Directory {
+ q := r.query.Select("tree")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `discardGitDir` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DiscardGitDir) {
+ q = q.Arg("discardGitDir", opts[i].DiscardGitDir)
+ }
+ // `depth` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Depth) {
+ q = q.Arg("depth", opts[i].Depth)
+ }
+ // `includeTags` optional argument
+ if !querybuilder.IsZeroValue(opts[i].IncludeTags) {
+ q = q.Arg("includeTags", opts[i].IncludeTags)
+ }
+ }
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// AsNode returns this GitRef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *GitRef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A git repository.
+type GitRepository struct {
+ query *querybuilder.Selection
+
+ id *ID
+ url *string
+}
+
+func (r *GitRepository) WithGraphQLQuery(q *querybuilder.Selection) *GitRepository {
+ return &GitRepository{
+ query: q,
+ }
+}
+
+// GitRepositoryAsWorkspaceOpts contains options for GitRepository.AsWorkspace
+type GitRepositoryAsWorkspaceOpts struct {
+ // Current working directory inside the workspace root. Defaults to the workspace root.
+ //
+ // Default: "/"
+ Cwd string
+}
+
+// Creates a synthetic workspace from this git repository.
+func (r *GitRepository) AsWorkspace(opts ...GitRepositoryAsWorkspaceOpts) *Workspace {
+ q := r.query.Select("asWorkspace")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `cwd` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Cwd) {
+ q = q.Arg("cwd", opts[i].Cwd)
+ }
+ }
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// Returns details of a branch.
+func (r *GitRepository) Branch(name string) *GitRef {
+ q := r.query.Select("branch")
+ q = q.Arg("name", name)
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// GitRepositoryBranchesOpts contains options for GitRepository.Branches
+type GitRepositoryBranchesOpts struct {
+ // Glob patterns (e.g., "refs/tags/v*").
+ Patterns []string
+}
+
+// branches that match any of the given glob patterns.
+func (r *GitRepository) Branches(ctx context.Context, opts ...GitRepositoryBranchesOpts) ([]string, error) {
+ q := r.query.Select("branches")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `patterns` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Patterns) {
+ q = q.Arg("patterns", opts[i].Patterns)
+ }
+ }
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Returns details of a commit.
+func (r *GitRepository) Commit(id string) *GitRef {
+ q := r.query.Select("commit")
+ q = q.Arg("id", id)
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// Returns details for HEAD.
+func (r *GitRepository) Head() *GitRef {
+ q := r.query.Select("head")
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// A unique identifier for this GitRepository.
+func (r *GitRepository) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *GitRepository) XXX_GraphQLType() string {
+ return "GitRepository"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *GitRepository) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *GitRepository) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *GitRepository) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *GitRepository) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = GitRepository{query: selectNode(dag.query, id, "GitRepository")}
+ return nil
+}
+
+// Returns details for the latest semver tag.
+func (r *GitRepository) LatestVersion() *GitRef {
+ q := r.query.Select("latestVersion")
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// Returns details of a ref.
+func (r *GitRepository) Ref(name string) *GitRef {
+ q := r.query.Select("ref")
+ q = q.Arg("name", name)
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// Returns details of a tag.
+func (r *GitRepository) Tag(name string) *GitRef {
+ q := r.query.Select("tag")
+ q = q.Arg("name", name)
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// GitRepositoryTagsOpts contains options for GitRepository.Tags
+type GitRepositoryTagsOpts struct {
+ // Glob patterns (e.g., "refs/tags/v*").
+ Patterns []string
+}
+
+// tags that match any of the given glob patterns.
+func (r *GitRepository) Tags(ctx context.Context, opts ...GitRepositoryTagsOpts) ([]string, error) {
+ q := r.query.Select("tags")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `patterns` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Patterns) {
+ q = q.Arg("patterns", opts[i].Patterns)
+ }
+ }
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Returns the changeset of uncommitted changes in the git repository.
+func (r *GitRepository) Uncommitted() *Changeset {
+ q := r.query.Select("uncommitted")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// The URL of the git repository.
+func (r *GitRepository) URL(ctx context.Context) (string, error) {
+ if r.url != nil {
+ return *r.url, nil
+ }
+ q := r.query.Select("url")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this GitRepository as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *GitRepository) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An internal persistent HTTP state.
+type HTTPState struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *HTTPState) WithGraphQLQuery(q *querybuilder.Selection) *HTTPState {
+ return &HTTPState{
+ query: q,
+ }
+}
+
+// A unique identifier for this HTTPState.
+func (r *HTTPState) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *HTTPState) XXX_GraphQLType() string {
+ return "HTTPState"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *HTTPState) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *HTTPState) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *HTTPState) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *HTTPState) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = HTTPState{query: selectNode(dag.query, id, "HTTPState")}
+ return nil
+}
+
+// AsNode returns this HTTPState as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *HTTPState) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// Image healthcheck configuration.
+type HealthcheckConfig struct {
+ query *querybuilder.Selection
+
+ id *ID
+ interval *string
+ retries *int
+ shell *bool
+ startInterval *string
+ startPeriod *string
+ timeout *string
+}
+
+func (r *HealthcheckConfig) WithGraphQLQuery(q *querybuilder.Selection) *HealthcheckConfig {
+ return &HealthcheckConfig{
+ query: q,
+ }
+}
+
+// Healthcheck command arguments.
+func (r *HealthcheckConfig) Args(ctx context.Context) ([]string, error) {
+ q := r.query.Select("args")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this HealthcheckConfig.
+func (r *HealthcheckConfig) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *HealthcheckConfig) XXX_GraphQLType() string {
+ return "HealthcheckConfig"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *HealthcheckConfig) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *HealthcheckConfig) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *HealthcheckConfig) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *HealthcheckConfig) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = HealthcheckConfig{query: selectNode(dag.query, id, "HealthcheckConfig")}
+ return nil
+}
+
+// Interval between running healthcheck. Example:30s
+func (r *HealthcheckConfig) Interval(ctx context.Context) (string, error) {
+ if r.interval != nil {
+ return *r.interval, nil
+ }
+ q := r.query.Select("interval")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The maximum number of consecutive failures before the container is marked as unhealthy. Example:3
+func (r *HealthcheckConfig) Retries(ctx context.Context) (int, error) {
+ if r.retries != nil {
+ return *r.retries, nil
+ }
+ q := r.query.Select("retries")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Healthcheck command is a shell command.
+func (r *HealthcheckConfig) Shell(ctx context.Context) (bool, error) {
+ if r.shell != nil {
+ return *r.shell, nil
+ }
+ q := r.query.Select("shell")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// StartInterval configures the duration between checks during the startup phase. Example:5s
+func (r *HealthcheckConfig) StartInterval(ctx context.Context) (string, error) {
+ if r.startInterval != nil {
+ return *r.startInterval, nil
+ }
+ q := r.query.Select("startInterval")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// StartPeriod allows for failures during this initial startup period which do not count towards maximum number of retries. Example:0s
+func (r *HealthcheckConfig) StartPeriod(ctx context.Context) (string, error) {
+ if r.startPeriod != nil {
+ return *r.startPeriod, nil
+ }
+ q := r.query.Select("startPeriod")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Healthcheck timeout. Example:3s
+func (r *HealthcheckConfig) Timeout(ctx context.Context) (string, error) {
+ if r.timeout != nil {
+ return *r.timeout, nil
+ }
+ q := r.query.Select("timeout")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this HealthcheckConfig as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *HealthcheckConfig) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A graphql input type, which is essentially just a group of named args.
+// This is currently only used to represent pre-existing usage of graphql input types
+// in the core API. It is not used by user modules and shouldn't ever be as user
+// module accept input objects via their id rather than graphql input types.
+type InputTypeDef struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+}
+
+func (r *InputTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *InputTypeDef {
+ return &InputTypeDef{
+ query: q,
+ }
+}
+
+// Static fields defined on this input object, if any.
+func (r *InputTypeDef) Fields(ctx context.Context) ([]FieldTypeDef, error) {
+ q := r.query.Select("fields")
+
+ q = q.Select("id")
+
+ type fields struct {
+ Id ID
+ }
+
+ convert := func(fields []fields) []FieldTypeDef {
+ out := []FieldTypeDef{}
+
+ for i := range fields {
+ val := FieldTypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "FieldTypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []fields
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// A unique identifier for this InputTypeDef.
+func (r *InputTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *InputTypeDef) XXX_GraphQLType() string {
+ return "InputTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *InputTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *InputTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *InputTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *InputTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = InputTypeDef{query: selectNode(dag.query, id, "InputTypeDef")}
+ return nil
+}
+
+// The name of the input object.
+func (r *InputTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this InputTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *InputTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A definition of a custom interface defined in a Module.
+type InterfaceTypeDef struct {
+ query *querybuilder.Selection
+
+ description *string
+ id *ID
+ name *string
+ sourceModuleName *string
+}
+
+func (r *InterfaceTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *InterfaceTypeDef {
+ return &InterfaceTypeDef{
+ query: q,
+ }
+}
+
+// The doc string for the interface, if any.
+func (r *InterfaceTypeDef) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Functions defined on this interface, if any.
+func (r *InterfaceTypeDef) Functions(ctx context.Context) ([]Function, error) {
+ q := r.query.Select("functions")
+
+ q = q.Select("id")
+
+ type functions struct {
+ Id ID
+ }
+
+ convert := func(fields []functions) []Function {
+ out := []Function{}
+
+ for i := range fields {
+ val := Function{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Function")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []functions
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// A unique identifier for this InterfaceTypeDef.
+func (r *InterfaceTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *InterfaceTypeDef) XXX_GraphQLType() string {
+ return "InterfaceTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *InterfaceTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *InterfaceTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *InterfaceTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *InterfaceTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = InterfaceTypeDef{query: selectNode(dag.query, id, "InterfaceTypeDef")}
+ return nil
+}
+
+// The name of the interface.
+func (r *InterfaceTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The location of this interface declaration.
+func (r *InterfaceTypeDef) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// If this InterfaceTypeDef is associated with a Module, the name of the module. Unset otherwise.
+func (r *InterfaceTypeDef) SourceModuleName(ctx context.Context) (string, error) {
+ if r.sourceModuleName != nil {
+ return *r.sourceModuleName, nil
+ }
+ q := r.query.Select("sourceModuleName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this InterfaceTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *InterfaceTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type JSONValue struct {
+ query *querybuilder.Selection
+
+ asBoolean *bool
+ asInteger *int
+ asString *string
+ contents *JSON
+ id *ID
+}
+type WithJSONValueFunc func(r *JSONValue) *JSONValue
+
+// With calls the provided function with current JSONValue.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *JSONValue) With(f WithJSONValueFunc) *JSONValue {
+ return f(r)
+}
+
+func (r *JSONValue) WithGraphQLQuery(q *querybuilder.Selection) *JSONValue {
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Decode an array from json
+func (r *JSONValue) AsArray(ctx context.Context) ([]JSONValue, error) {
+ q := r.query.Select("asArray")
+
+ q = q.Select("id")
+
+ type asArray struct {
+ Id ID
+ }
+
+ convert := func(fields []asArray) []JSONValue {
+ out := []JSONValue{}
+
+ for i := range fields {
+ val := JSONValue{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "JSONValue")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []asArray
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Decode a boolean from json
+func (r *JSONValue) AsBoolean(ctx context.Context) (bool, error) {
+ if r.asBoolean != nil {
+ return *r.asBoolean, nil
+ }
+ q := r.query.Select("asBoolean")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Decode an integer from json
+func (r *JSONValue) AsInteger(ctx context.Context) (int, error) {
+ if r.asInteger != nil {
+ return *r.asInteger, nil
+ }
+ q := r.query.Select("asInteger")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Decode a string from json
+func (r *JSONValue) AsString(ctx context.Context) (string, error) {
+ if r.asString != nil {
+ return *r.asString, nil
+ }
+ q := r.query.Select("asString")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// JSONValueContentsOpts contains options for JSONValue.Contents
+type JSONValueContentsOpts struct {
+ // Pretty-print
+ Pretty bool
+ // Optional line prefix
+ //
+ // Default: " "
+ Indent string
+}
+
+// Return the value encoded as json
+func (r *JSONValue) Contents(ctx context.Context, opts ...JSONValueContentsOpts) (JSON, error) {
+ if r.contents != nil {
+ return *r.contents, nil
+ }
+ q := r.query.Select("contents")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `pretty` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Pretty) {
+ q = q.Arg("pretty", opts[i].Pretty)
+ }
+ // `indent` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Indent) {
+ q = q.Arg("indent", opts[i].Indent)
+ }
+ }
+
+ var response JSON
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Lookup the field at the given path, and return its value.
+func (r *JSONValue) Field(path []string) *JSONValue {
+ q := r.query.Select("field")
+ q = q.Arg("path", path)
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// List fields of the encoded object
+func (r *JSONValue) Fields(ctx context.Context) ([]string, error) {
+ q := r.query.Select("fields")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this JSONValue.
+func (r *JSONValue) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *JSONValue) XXX_GraphQLType() string {
+ return "JSONValue"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *JSONValue) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *JSONValue) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *JSONValue) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *JSONValue) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = JSONValue{query: selectNode(dag.query, id, "JSONValue")}
+ return nil
+}
+
+// Encode a boolean to json
+func (r *JSONValue) NewBoolean(value bool) *JSONValue {
+ q := r.query.Select("newBoolean")
+ q = q.Arg("value", value)
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Encode an integer to json
+func (r *JSONValue) NewInteger(value int) *JSONValue {
+ q := r.query.Select("newInteger")
+ q = q.Arg("value", value)
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Encode a string to json
+func (r *JSONValue) NewString(value string) *JSONValue {
+ q := r.query.Select("newString")
+ q = q.Arg("value", value)
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Return a new json value, decoded from the given content
+func (r *JSONValue) WithContents(contents JSON) *JSONValue {
+ q := r.query.Select("withContents")
+ q = q.Arg("contents", contents)
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// Set a new field at the given path
+func (r *JSONValue) WithField(path []string, value *JSONValue) *JSONValue {
+ assertNotNil("value", value)
+ q := r.query.Select("withField")
+ q = q.Arg("path", path)
+ q = q.Arg("value", value)
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// AsNode returns this JSONValue as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *JSONValue) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type LLM struct {
+ query *querybuilder.Selection
+
+ hasPrompt *bool
+ historyJSON *JSON
+ id *ID
+ lastReply *string
+ model *string
+ provider *string
+ step *ID
+ sync *ID
+ tools *string
+}
+type WithLLMFunc func(r *LLM) *LLM
+
+// With calls the provided function with current LLM.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *LLM) With(f WithLLMFunc) *LLM {
+ return f(r)
+}
+
+func (r *LLM) WithGraphQLQuery(q *querybuilder.Selection) *LLM {
+ return &LLM{
+ query: q,
+ }
+}
+
+// create a branch in the LLM's history
+func (r *LLM) Attempt(number int) *LLM {
+ q := r.query.Select("attempt")
+ q = q.Arg("number", number)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// returns the type of the current state
+func (r *LLM) BindResult(name string) *Binding {
+ q := r.query.Select("bindResult")
+ q = q.Arg("name", name)
+
+ return &Binding{
+ query: q,
+ }
+}
+
+// return the LLM's current environment
+func (r *LLM) Env() *Env {
+ q := r.query.Select("env")
+
+ return &Env{
+ query: q,
+ }
+}
+
+// Indicates whether there are any queued prompts or tool results to send to the model
+func (r *LLM) HasPrompt(ctx context.Context) (bool, error) {
+ if r.hasPrompt != nil {
+ return *r.hasPrompt, nil
+ }
+ q := r.query.Select("hasPrompt")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// return the llm message history
+func (r *LLM) History(ctx context.Context) ([]string, error) {
+ q := r.query.Select("history")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// return the raw llm message history as json
+func (r *LLM) HistoryJSON(ctx context.Context) (JSON, error) {
+ if r.historyJSON != nil {
+ return *r.historyJSON, nil
+ }
+ q := r.query.Select("historyJSON")
+
+ var response JSON
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this LLM.
+func (r *LLM) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *LLM) XXX_GraphQLType() string {
+ return "LLM"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *LLM) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *LLM) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *LLM) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *LLM) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = LLM{query: selectNode(dag.query, id, "LLM")}
+ return nil
+}
+
+// return the last llm reply from the history
+func (r *LLM) LastReply(ctx context.Context) (string, error) {
+ if r.lastReply != nil {
+ return *r.lastReply, nil
+ }
+ q := r.query.Select("lastReply")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Submit the queued prompt, evaluate any tool calls, queue their results, and keep going until the model ends its turn
+func (r *LLM) Loop() *LLM {
+ q := r.query.Select("loop")
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// return the model used by the llm
+func (r *LLM) Model(ctx context.Context) (string, error) {
+ if r.model != nil {
+ return *r.model, nil
+ }
+ q := r.query.Select("model")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// return the provider used by the llm
+func (r *LLM) Provider(ctx context.Context) (string, error) {
+ if r.provider != nil {
+ return *r.provider, nil
+ }
+ q := r.query.Select("provider")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Submit the queued prompt or tool call results, evaluate any tool calls, and queue their results
+func (r *LLM) Step(ctx context.Context) (*LLM, error) {
+ q := r.query.Select("step")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &LLM{
+ query: selectNode(q.Root(), id, "LLM"),
+ }, nil
+}
+
+// synchronize LLM state
+func (r *LLM) Sync(ctx context.Context) (*LLM, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &LLM{
+ query: selectNode(q.Root(), id, "LLM"),
+ }, nil
+}
+
+// returns the token usage of the current state
+func (r *LLM) TokenUsage() *LLMTokenUsage {
+ q := r.query.Select("tokenUsage")
+
+ return &LLMTokenUsage{
+ query: q,
+ }
+}
+
+// print documentation for available tools
+func (r *LLM) Tools(ctx context.Context) (string, error) {
+ if r.tools != nil {
+ return *r.tools, nil
+ }
+ q := r.query.Select("tools")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return a new LLM with the specified function no longer exposed as a tool
+func (r *LLM) WithBlockedFunction(typeName string, function string) *LLM {
+ q := r.query.Select("withBlockedFunction")
+ q = q.Arg("typeName", typeName)
+ q = q.Arg("function", function)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// allow the LLM to interact with an environment via MCP
+func (r *LLM) WithEnv(env *Env) *LLM {
+ assertNotNil("env", env)
+ q := r.query.Select("withEnv")
+ q = q.Arg("env", env)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Add an external MCP server to the LLM
+func (r *LLM) WithMCPServer(name string, service *Service) *LLM {
+ assertNotNil("service", service)
+ q := r.query.Select("withMCPServer")
+ q = q.Arg("name", name)
+ q = q.Arg("service", service)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// swap out the llm model
+func (r *LLM) WithModel(model string) *LLM {
+ q := r.query.Select("withModel")
+ q = q.Arg("model", model)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// append a prompt to the llm context
+func (r *LLM) WithPrompt(prompt string) *LLM {
+ q := r.query.Select("withPrompt")
+ q = q.Arg("prompt", prompt)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// append the contents of a file to the llm context
+func (r *LLM) WithPromptFile(file *File) *LLM {
+ assertNotNil("file", file)
+ q := r.query.Select("withPromptFile")
+ q = q.Arg("file", file)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Use a static set of tools for method calls, e.g. for MCP clients that do not support dynamic tool registration
+func (r *LLM) WithStaticTools() *LLM {
+ q := r.query.Select("withStaticTools")
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Add a system prompt to the LLM's environment
+func (r *LLM) WithSystemPrompt(prompt string) *LLM {
+ q := r.query.Select("withSystemPrompt")
+ q = q.Arg("prompt", prompt)
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Disable the default system prompt
+func (r *LLM) WithoutDefaultSystemPrompt() *LLM {
+ q := r.query.Select("withoutDefaultSystemPrompt")
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Clear the message history, leaving only the system prompts
+func (r *LLM) WithoutMessageHistory() *LLM {
+ q := r.query.Select("withoutMessageHistory")
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Clear the system prompts, leaving only the default system prompt
+func (r *LLM) WithoutSystemPrompts() *LLM {
+ q := r.query.Select("withoutSystemPrompts")
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// AsNode returns this LLM as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *LLM) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this LLM as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *LLM) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+type LLMTokenUsage struct {
+ query *querybuilder.Selection
+
+ cachedTokenReads *int
+ cachedTokenWrites *int
+ id *ID
+ inputTokens *int
+ outputTokens *int
+ totalTokens *int
+}
+
+func (r *LLMTokenUsage) WithGraphQLQuery(q *querybuilder.Selection) *LLMTokenUsage {
+ return &LLMTokenUsage{
+ query: q,
+ }
+}
+
+func (r *LLMTokenUsage) CachedTokenReads(ctx context.Context) (int, error) {
+ if r.cachedTokenReads != nil {
+ return *r.cachedTokenReads, nil
+ }
+ q := r.query.Select("cachedTokenReads")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+func (r *LLMTokenUsage) CachedTokenWrites(ctx context.Context) (int, error) {
+ if r.cachedTokenWrites != nil {
+ return *r.cachedTokenWrites, nil
+ }
+ q := r.query.Select("cachedTokenWrites")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this LLMTokenUsage.
+func (r *LLMTokenUsage) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *LLMTokenUsage) XXX_GraphQLType() string {
+ return "LLMTokenUsage"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *LLMTokenUsage) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *LLMTokenUsage) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *LLMTokenUsage) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *LLMTokenUsage) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = LLMTokenUsage{query: selectNode(dag.query, id, "LLMTokenUsage")}
+ return nil
+}
+
+func (r *LLMTokenUsage) InputTokens(ctx context.Context) (int, error) {
+ if r.inputTokens != nil {
+ return *r.inputTokens, nil
+ }
+ q := r.query.Select("inputTokens")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+func (r *LLMTokenUsage) OutputTokens(ctx context.Context) (int, error) {
+ if r.outputTokens != nil {
+ return *r.outputTokens, nil
+ }
+ q := r.query.Select("outputTokens")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+func (r *LLMTokenUsage) TotalTokens(ctx context.Context) (int, error) {
+ if r.totalTokens != nil {
+ return *r.totalTokens, nil
+ }
+ q := r.query.Select("totalTokens")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this LLMTokenUsage as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *LLMTokenUsage) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A simple key value object that represents a label.
+type Label struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+ value *string
+}
+
+func (r *Label) WithGraphQLQuery(q *querybuilder.Selection) *Label {
+ return &Label{
+ query: q,
+ }
+}
+
+// A unique identifier for this Label.
+func (r *Label) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Label) XXX_GraphQLType() string {
+ return "Label"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Label) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Label) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Label) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Label) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Label{query: selectNode(dag.query, id, "Label")}
+ return nil
+}
+
+// The label name.
+func (r *Label) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The label value.
+func (r *Label) Value(ctx context.Context) (string, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Label as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Label) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A definition of a list type in a Module.
+type ListTypeDef struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *ListTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *ListTypeDef {
+ return &ListTypeDef{
+ query: q,
+ }
+}
+
+// The type of the elements in the list.
+func (r *ListTypeDef) ElementTypeDef() *TypeDef {
+ q := r.query.Select("elementTypeDef")
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// A unique identifier for this ListTypeDef.
+func (r *ListTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ListTypeDef) XXX_GraphQLType() string {
+ return "ListTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ListTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ListTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ListTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ListTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ListTypeDef{query: selectNode(dag.query, id, "ListTypeDef")}
+ return nil
+}
+
+// AsNode returns this ListTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ListTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A Dagger module.
+type Module struct {
+ query *querybuilder.Selection
+
+ description *string
+ id *ID
+ name *string
+ serve *Void
+ sync *ID
+}
+type WithModuleFunc func(r *Module) *Module
+
+// With calls the provided function with current Module.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Module) With(f WithModuleFunc) *Module {
+ return f(r)
+}
+
+func (r *Module) WithGraphQLQuery(q *querybuilder.Selection) *Module {
+ return &Module{
+ query: q,
+ }
+}
+
+// Return the check defined by the module with the given name. Must match to exactly one check.
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Module) Check(name string) *Check {
+ q := r.query.Select("check")
+ q = q.Arg("name", name)
+
+ return &Check{
+ query: q,
+ }
+}
+
+// ModuleChecksOpts contains options for Module.Checks
+type ModuleChecksOpts struct {
+ // Only include checks matching the specified patterns
+ Include []string
+ // When true, only return annotated check functions; exclude generate-as-checks
+ NoGenerate bool
+}
+
+// Return all checks defined by the module
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Module) Checks(opts ...ModuleChecksOpts) *CheckGroup {
+ q := r.query.Select("checks")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `noGenerate` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoGenerate) {
+ q = q.Arg("noGenerate", opts[i].NoGenerate)
+ }
+ }
+
+ return &CheckGroup{
+ query: q,
+ }
+}
+
+// The dependencies of the module.
+func (r *Module) Dependencies(ctx context.Context) ([]Module, error) {
+ q := r.query.Select("dependencies")
+
+ q = q.Select("id")
+
+ type dependencies struct {
+ Id ID
+ }
+
+ convert := func(fields []dependencies) []Module {
+ out := []Module{}
+
+ for i := range fields {
+ val := Module{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Module")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []dependencies
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The doc string of the module, if any
+func (r *Module) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Enumerations served by this module.
+func (r *Module) Enums(ctx context.Context) ([]TypeDef, error) {
+ q := r.query.Select("enums")
+
+ q = q.Select("id")
+
+ type enums struct {
+ Id ID
+ }
+
+ convert := func(fields []enums) []TypeDef {
+ out := []TypeDef{}
+
+ for i := range fields {
+ val := TypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "TypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []enums
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The generated files and directories made on top of the module source's context directory.
+func (r *Module) GeneratedContextDirectory() *Directory {
+ q := r.query.Select("generatedContextDirectory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// Return the generator defined by the module with the given name. Must match to exactly one generator.
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Module) Generator(name string) *Generator {
+ q := r.query.Select("generator")
+ q = q.Arg("name", name)
+
+ return &Generator{
+ query: q,
+ }
+}
+
+// ModuleGeneratorsOpts contains options for Module.Generators
+type ModuleGeneratorsOpts struct {
+ // Only include generators matching the specified patterns
+ Include []string
+}
+
+// Return all generators defined by the module
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Module) Generators(opts ...ModuleGeneratorsOpts) *GeneratorGroup {
+ q := r.query.Select("generators")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ }
+
+ return &GeneratorGroup{
+ query: q,
+ }
+}
+
+// A unique identifier for this Module.
+func (r *Module) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Module) XXX_GraphQLType() string {
+ return "Module"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Module) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Module) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Module) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Module) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Module{query: selectNode(dag.query, id, "Module")}
+ return nil
+}
+
+// Interfaces served by this module.
+func (r *Module) Interfaces(ctx context.Context) ([]TypeDef, error) {
+ q := r.query.Select("interfaces")
+
+ q = q.Select("id")
+
+ type interfaces struct {
+ Id ID
+ }
+
+ convert := func(fields []interfaces) []TypeDef {
+ out := []TypeDef{}
+
+ for i := range fields {
+ val := TypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "TypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []interfaces
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The introspection schema JSON file for this module.
+//
+// This file represents the schema visible to the module's source code, including all core types and those from the dependencies.
+//
+// Note: this is in the context of a module, so some core types may be hidden.
+func (r *Module) IntrospectionSchemaJSON() *File {
+ q := r.query.Select("introspectionSchemaJSON")
+
+ return &File{
+ query: q,
+ }
+}
+
+// The name of the module
+func (r *Module) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Objects served by this module.
+func (r *Module) Objects(ctx context.Context) ([]TypeDef, error) {
+ q := r.query.Select("objects")
+
+ q = q.Select("id")
+
+ type objects struct {
+ Id ID
+ }
+
+ convert := func(fields []objects) []TypeDef {
+ out := []TypeDef{}
+
+ for i := range fields {
+ val := TypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "TypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []objects
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The container that runs the module's entrypoint. It will fail to execute if the module doesn't compile.
+func (r *Module) Runtime() *Container {
+ q := r.query.Select("runtime")
+
+ return &Container{
+ query: q,
+ }
+}
+
+// The SDK config used by this module.
+func (r *Module) SDK() *SDKConfig {
+ q := r.query.Select("sdk")
+
+ return &SDKConfig{
+ query: q,
+ }
+}
+
+// ModuleServeOpts contains options for Module.Serve
+type ModuleServeOpts struct {
+ // Expose the dependencies of this module to the client
+ IncludeDependencies bool
+ // Install the module as the entrypoint, promoting its main-object methods onto the Query root
+ Entrypoint bool
+}
+
+// Serve a module's API in the current session.
+//
+// Note: this can only be called once per session. In the future, it could return a stream or service to remove the side effect.
+func (r *Module) Serve(ctx context.Context, opts ...ModuleServeOpts) error {
+ if r.serve != nil {
+ return nil
+ }
+ q := r.query.Select("serve")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `includeDependencies` optional argument
+ if !querybuilder.IsZeroValue(opts[i].IncludeDependencies) {
+ q = q.Arg("includeDependencies", opts[i].IncludeDependencies)
+ }
+ // `entrypoint` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Entrypoint) {
+ q = q.Arg("entrypoint", opts[i].Entrypoint)
+ }
+ }
+
+ return q.Execute(ctx)
+}
+
+// ModuleServicesOpts contains options for Module.Services
+type ModuleServicesOpts struct {
+ // Only include services matching the specified patterns
+ Include []string
+}
+
+// Return all services defined by the module
+//
+// Experimental: This API is highly experimental and may be removed or replaced entirely.
+func (r *Module) Services(opts ...ModuleServicesOpts) *UpGroup {
+ q := r.query.Select("services")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ }
+
+ return &UpGroup{
+ query: q,
+ }
+}
+
+// The source for the module.
+func (r *Module) Source() *ModuleSource {
+ q := r.query.Select("source")
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Forces evaluation of the module, including any loading into the engine and associated validation.
+func (r *Module) Sync(ctx context.Context) (*Module, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Module{
+ query: selectNode(q.Root(), id, "Module"),
+ }, nil
+}
+
+// User-defined default values, loaded from local .env files.
+func (r *Module) UserDefaults() *EnvFile {
+ q := r.query.Select("userDefaults")
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// Retrieves the module with the given description
+func (r *Module) WithDescription(description string) *Module {
+ q := r.query.Select("withDescription")
+ q = q.Arg("description", description)
+
+ return &Module{
+ query: q,
+ }
+}
+
+// This module plus the given Enum type and associated values
+func (r *Module) WithEnum(enum *TypeDef) *Module {
+ assertNotNil("enum", enum)
+ q := r.query.Select("withEnum")
+ q = q.Arg("enum", enum)
+
+ return &Module{
+ query: q,
+ }
+}
+
+// This module plus the given Interface type and associated functions
+func (r *Module) WithInterface(iface *TypeDef) *Module {
+ assertNotNil("iface", iface)
+ q := r.query.Select("withInterface")
+ q = q.Arg("iface", iface)
+
+ return &Module{
+ query: q,
+ }
+}
+
+// This module plus the given Object type and associated functions.
+func (r *Module) WithObject(object *TypeDef) *Module {
+ assertNotNil("object", object)
+ q := r.query.Select("withObject")
+ q = q.Arg("object", object)
+
+ return &Module{
+ query: q,
+ }
+}
+
+// AsNode returns this Module as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Module) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this Module as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *Module) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// The client generated for the module.
+type ModuleConfigClient struct {
+ query *querybuilder.Selection
+
+ directory *string
+ generator *string
+ id *ID
+}
+
+func (r *ModuleConfigClient) WithGraphQLQuery(q *querybuilder.Selection) *ModuleConfigClient {
+ return &ModuleConfigClient{
+ query: q,
+ }
+}
+
+// The directory the client is generated in.
+func (r *ModuleConfigClient) Directory(ctx context.Context) (string, error) {
+ if r.directory != nil {
+ return *r.directory, nil
+ }
+ q := r.query.Select("directory")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The generator to use
+func (r *ModuleConfigClient) Generator(ctx context.Context) (string, error) {
+ if r.generator != nil {
+ return *r.generator, nil
+ }
+ q := r.query.Select("generator")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this ModuleConfigClient.
+func (r *ModuleConfigClient) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ModuleConfigClient) XXX_GraphQLType() string {
+ return "ModuleConfigClient"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ModuleConfigClient) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ModuleConfigClient) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ModuleConfigClient) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ModuleConfigClient) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ModuleConfigClient{query: selectNode(dag.query, id, "ModuleConfigClient")}
+ return nil
+}
+
+// AsNode returns this ModuleConfigClient as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ModuleConfigClient) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc.
+type ModuleSource struct {
+ query *querybuilder.Selection
+
+ asString *string
+ cloneRef *string
+ commit *string
+ configExists *bool
+ digest *string
+ engineVersion *string
+ htmlRepoURL *string
+ htmlURL *string
+ id *ID
+ kind *ModuleSourceKind
+ localContextDirectoryPath *string
+ moduleName *string
+ moduleOriginalName *string
+ originalSubpath *string
+ pin *string
+ repoRootPath *string
+ sourceRootSubpath *string
+ sourceSubpath *string
+ sync *ID
+ version *string
+}
+type WithModuleSourceFunc func(r *ModuleSource) *ModuleSource
+
+// With calls the provided function with current ModuleSource.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *ModuleSource) With(f WithModuleSourceFunc) *ModuleSource {
+ return f(r)
+}
+
+func (r *ModuleSource) WithGraphQLQuery(q *querybuilder.Selection) *ModuleSource {
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation
+func (r *ModuleSource) AsModule() *Module {
+ q := r.query.Select("asModule")
+
+ return &Module{
+ query: q,
+ }
+}
+
+// A human readable ref string representation of this module source.
+func (r *ModuleSource) AsString(ctx context.Context) (string, error) {
+ if r.asString != nil {
+ return *r.asString, nil
+ }
+ q := r.query.Select("asString")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The blueprint referenced by the module source.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in dagger.toml instead.
+func (r *ModuleSource) Blueprint() *ModuleSource {
+ q := r.query.Select("blueprint")
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// The ref to clone the root of the git repo from. Only valid for git sources.
+func (r *ModuleSource) CloneRef(ctx context.Context) (string, error) {
+ if r.cloneRef != nil {
+ return *r.cloneRef, nil
+ }
+ q := r.query.Select("cloneRef")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The resolved commit of the git repo this source points to.
+func (r *ModuleSource) Commit(ctx context.Context) (string, error) {
+ if r.commit != nil {
+ return *r.commit, nil
+ }
+ q := r.query.Select("commit")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The clients generated for the module.
+func (r *ModuleSource) ConfigClients(ctx context.Context) ([]ModuleConfigClient, error) {
+ q := r.query.Select("configClients")
+
+ q = q.Select("id")
+
+ type configClients struct {
+ Id ID
+ }
+
+ convert := func(fields []configClients) []ModuleConfigClient {
+ out := []ModuleConfigClient{}
+
+ for i := range fields {
+ val := ModuleConfigClient{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "ModuleConfigClient")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []configClients
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Whether an existing module config file was found.
+func (r *ModuleSource) ConfigExists(ctx context.Context) (bool, error) {
+ if r.configExists != nil {
+ return *r.configExists, nil
+ }
+ q := r.query.Select("configExists")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The full directory loaded for the module source, including the source code as a subdirectory.
+func (r *ModuleSource) ContextDirectory() *Directory {
+ q := r.query.Select("contextDirectory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// The dependencies of the module source.
+func (r *ModuleSource) Dependencies(ctx context.Context) ([]ModuleSource, error) {
+ q := r.query.Select("dependencies")
+
+ q = q.Select("id")
+
+ type dependencies struct {
+ Id ID
+ }
+
+ convert := func(fields []dependencies) []ModuleSource {
+ out := []ModuleSource{}
+
+ for i := range fields {
+ val := ModuleSource{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "ModuleSource")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []dependencies
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// A content-hash of the module source. Module sources with the same digest will output the same generated context and convert into the same module instance.
+func (r *ModuleSource) Digest(ctx context.Context) (string, error) {
+ if r.digest != nil {
+ return *r.digest, nil
+ }
+ q := r.query.Select("digest")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The directory containing the module configuration and source code (source code may be in a subdir).
+func (r *ModuleSource) Directory(path string) *Directory {
+ q := r.query.Select("directory")
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// The engine version of the module.
+func (r *ModuleSource) EngineVersion(ctx context.Context) (string, error) {
+ if r.engineVersion != nil {
+ return *r.engineVersion, nil
+ }
+ q := r.query.Select("engineVersion")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The generated files and directories made on top of the module source's context directory, returned as a Changeset.
+func (r *ModuleSource) GeneratedContextChangeset() *Changeset {
+ q := r.query.Select("generatedContextChangeset")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// The generated files and directories made on top of the module source's context directory.
+func (r *ModuleSource) GeneratedContextDirectory() *Directory {
+ q := r.query.Select("generatedContextDirectory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// The URL to access the web view of the repository (e.g., GitHub, GitLab, Bitbucket).
+func (r *ModuleSource) HTMLRepoURL(ctx context.Context) (string, error) {
+ if r.htmlRepoURL != nil {
+ return *r.htmlRepoURL, nil
+ }
+ q := r.query.Select("htmlRepoURL")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The URL to the source's git repo in a web browser. Only valid for git sources.
+func (r *ModuleSource) HTMLURL(ctx context.Context) (string, error) {
+ if r.htmlURL != nil {
+ return *r.htmlURL, nil
+ }
+ q := r.query.Select("htmlURL")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this ModuleSource.
+func (r *ModuleSource) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ModuleSource) XXX_GraphQLType() string {
+ return "ModuleSource"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ModuleSource) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ModuleSource) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ModuleSource) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ModuleSource) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ModuleSource{query: selectNode(dag.query, id, "ModuleSource")}
+ return nil
+}
+
+// The introspection schema JSON file for this module source.
+//
+// This file represents the schema visible to the module's source code, including all core types and those from the dependencies.
+//
+// Note: this is in the context of a module, so some core types may be hidden.
+func (r *ModuleSource) IntrospectionSchemaJSON() *File {
+ q := r.query.Select("introspectionSchemaJSON")
+
+ return &File{
+ query: q,
+ }
+}
+
+// The kind of module source (currently local, git or dir).
+func (r *ModuleSource) Kind(ctx context.Context) (ModuleSourceKind, error) {
+ if r.kind != nil {
+ return *r.kind, nil
+ }
+ q := r.query.Select("kind")
+
+ var response ModuleSourceKind
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The full absolute path to the context directory on the caller's host filesystem that this module source is loaded from. Only valid for local module sources.
+func (r *ModuleSource) LocalContextDirectoryPath(ctx context.Context) (string, error) {
+ if r.localContextDirectoryPath != nil {
+ return *r.localContextDirectoryPath, nil
+ }
+ q := r.query.Select("localContextDirectoryPath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The name of the module, including any setting via the withName API.
+func (r *ModuleSource) ModuleName(ctx context.Context) (string, error) {
+ if r.moduleName != nil {
+ return *r.moduleName, nil
+ }
+ q := r.query.Select("moduleName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The original name of the module as read from the module config file (or set for the first time with the withName API).
+func (r *ModuleSource) ModuleOriginalName(ctx context.Context) (string, error) {
+ if r.moduleOriginalName != nil {
+ return *r.moduleOriginalName, nil
+ }
+ q := r.query.Select("moduleOriginalName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The original subpath used when instantiating this module source, relative to the context directory.
+func (r *ModuleSource) OriginalSubpath(ctx context.Context) (string, error) {
+ if r.originalSubpath != nil {
+ return *r.originalSubpath, nil
+ }
+ q := r.query.Select("originalSubpath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The pinned version of this module source.
+func (r *ModuleSource) Pin(ctx context.Context) (string, error) {
+ if r.pin != nil {
+ return *r.pin, nil
+ }
+ q := r.query.Select("pin")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The import path corresponding to the root of the git repo this source points to. Only valid for git sources.
+func (r *ModuleSource) RepoRootPath(ctx context.Context) (string, error) {
+ if r.repoRootPath != nil {
+ return *r.repoRootPath, nil
+ }
+ q := r.query.Select("repoRootPath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The SDK configuration of the module.
+func (r *ModuleSource) SDK() *SDKConfig {
+ q := r.query.Select("sdk")
+
+ return &SDKConfig{
+ query: q,
+ }
+}
+
+// The path, relative to the context directory, that contains the module config.
+func (r *ModuleSource) SourceRootSubpath(ctx context.Context) (string, error) {
+ if r.sourceRootSubpath != nil {
+ return *r.sourceRootSubpath, nil
+ }
+ q := r.query.Select("sourceRootSubpath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The path to the directory containing the module's source code, relative to the context directory.
+func (r *ModuleSource) SourceSubpath(ctx context.Context) (string, error) {
+ if r.sourceSubpath != nil {
+ return *r.sourceSubpath, nil
+ }
+ q := r.query.Select("sourceSubpath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Forces evaluation of the module source, including any loading into the engine and associated validation.
+func (r *ModuleSource) Sync(ctx context.Context) (*ModuleSource, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &ModuleSource{
+ query: selectNode(q.Root(), id, "ModuleSource"),
+ }, nil
+}
+
+// The toolchains referenced by the module source.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in dagger.toml instead.
+func (r *ModuleSource) Toolchains(ctx context.Context) ([]ModuleSource, error) {
+ q := r.query.Select("toolchains")
+
+ q = q.Select("id")
+
+ type toolchains struct {
+ Id ID
+ }
+
+ convert := func(fields []toolchains) []ModuleSource {
+ out := []ModuleSource{}
+
+ for i := range fields {
+ val := ModuleSource{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "ModuleSource")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []toolchains
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The module's dagger.json with any in-memory edits from with* APIs applied, as a diff relative to the source's context directory.
+//
+// Unlike generatedContextDirectory, this does not run codegen and does not validate the engine version against the running engine, so it can be used to declare an engine requirement newer than the running engine. Loading or serving such a module still fails at moduleSource.asModule.
+func (r *ModuleSource) UpdatedConfigDirectory() *Directory {
+ q := r.query.Select("updatedConfigDirectory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// User-defined defaults read from local .env files
+func (r *ModuleSource) UserDefaults() *EnvFile {
+ q := r.query.Select("userDefaults")
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// The specified version of the git repo this source points to.
+func (r *ModuleSource) Version(ctx context.Context) (string, error) {
+ if r.version != nil {
+ return *r.version, nil
+ }
+ q := r.query.Select("version")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Set a blueprint for the module source.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in `dagger.toml` instead.
+func (r *ModuleSource) WithBlueprint(blueprint *ModuleSource) *ModuleSource {
+ assertNotNil("blueprint", blueprint)
+ q := r.query.Select("withBlueprint")
+ q = q.Arg("blueprint", blueprint)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update the module source with a new client to generate.
+func (r *ModuleSource) WithClient(generator string, outputDir string) *ModuleSource {
+ q := r.query.Select("withClient")
+ q = q.Arg("generator", generator)
+ q = q.Arg("outputDir", outputDir)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Append the provided dependencies to the module source's dependency list.
+func (r *ModuleSource) WithDependencies(dependencies []*ModuleSource) *ModuleSource {
+ q := r.query.Select("withDependencies")
+ q = q.Arg("dependencies", dependencies)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Upgrade the engine version of the module to the given value.
+func (r *ModuleSource) WithEngineVersion(version string) *ModuleSource {
+ q := r.query.Select("withEngineVersion")
+ q = q.Arg("version", version)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Enable the experimental features for the module source.
+func (r *ModuleSource) WithExperimentalFeatures(features []ModuleSourceExperimentalFeature) *ModuleSource {
+ q := r.query.Select("withExperimentalFeatures")
+ q = q.Arg("features", features)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update the module source with additional include patterns for files+directories from its context that are required for building it
+func (r *ModuleSource) WithIncludes(patterns []string) *ModuleSource {
+ q := r.query.Select("withIncludes")
+ q = q.Arg("patterns", patterns)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update the module source with a new name.
+func (r *ModuleSource) WithName(name string) *ModuleSource {
+ q := r.query.Select("withName")
+ q = q.Arg("name", name)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update the module source with a new SDK.
+func (r *ModuleSource) WithSDK(source string) *ModuleSource {
+ q := r.query.Select("withSDK")
+ q = q.Arg("source", source)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update the module source with a new source subpath.
+func (r *ModuleSource) WithSourceSubpath(path string) *ModuleSource {
+ q := r.query.Select("withSourceSubpath")
+ q = q.Arg("path", path)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Add toolchains to the module source.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in `dagger.toml` instead.
+func (r *ModuleSource) WithToolchains(toolchains []*ModuleSource) *ModuleSource {
+ q := r.query.Select("withToolchains")
+ q = q.Arg("toolchains", toolchains)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update the blueprint module to the latest version.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in `dagger.toml` instead.
+func (r *ModuleSource) WithUpdateBlueprint() *ModuleSource {
+ q := r.query.Select("withUpdateBlueprint")
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update one or more module dependencies.
+func (r *ModuleSource) WithUpdateDependencies(dependencies []string) *ModuleSource {
+ q := r.query.Select("withUpdateDependencies")
+ q = q.Arg("dependencies", dependencies)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update one or more toolchains.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in `dagger.toml` instead.
+func (r *ModuleSource) WithUpdateToolchains(toolchains []string) *ModuleSource {
+ q := r.query.Select("withUpdateToolchains")
+ q = q.Arg("toolchains", toolchains)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Update one or more clients.
+func (r *ModuleSource) WithUpdatedClients(clients []string) *ModuleSource {
+ q := r.query.Select("withUpdatedClients")
+ q = q.Arg("clients", clients)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Remove the current blueprint from the module source.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in `dagger.toml` instead.
+func (r *ModuleSource) WithoutBlueprint() *ModuleSource {
+ q := r.query.Select("withoutBlueprint")
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Remove a client from the module source.
+func (r *ModuleSource) WithoutClient(path string) *ModuleSource {
+ q := r.query.Select("withoutClient")
+ q = q.Arg("path", path)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Remove the provided dependencies from the module source's dependency list.
+func (r *ModuleSource) WithoutDependencies(dependencies []string) *ModuleSource {
+ q := r.query.Select("withoutDependencies")
+ q = q.Arg("dependencies", dependencies)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Disable experimental features for the module source.
+func (r *ModuleSource) WithoutExperimentalFeatures(features []ModuleSourceExperimentalFeature) *ModuleSource {
+ q := r.query.Select("withoutExperimentalFeatures")
+ q = q.Arg("features", features)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Remove the provided toolchains from the module source.
+//
+// Deprecated: Legacy dagger.json field. Generic module loading no longer honors it; use workspace modules in `dagger.toml` instead.
+func (r *ModuleSource) WithoutToolchains(toolchains []string) *ModuleSource {
+ q := r.query.Select("withoutToolchains")
+ q = q.Arg("toolchains", toolchains)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// AsNode returns this ModuleSource as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ModuleSource) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this ModuleSource as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *ModuleSource) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// A definition of a custom object defined in a Module.
+type ObjectTypeDef struct {
+ query *querybuilder.Selection
+
+ deprecated *string
+ description *string
+ id *ID
+ name *string
+ sourceModuleName *string
+}
+
+func (r *ObjectTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *ObjectTypeDef {
+ return &ObjectTypeDef{
+ query: q,
+ }
+}
+
+// The function used to construct new instances of this object, if any.
+func (r *ObjectTypeDef) Constructor() *Function {
+ q := r.query.Select("constructor")
+
+ return &Function{
+ query: q,
+ }
+}
+
+// The reason this enum member is deprecated, if any.
+func (r *ObjectTypeDef) Deprecated(ctx context.Context) (string, error) {
+ if r.deprecated != nil {
+ return *r.deprecated, nil
+ }
+ q := r.query.Select("deprecated")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The doc string for the object, if any.
+func (r *ObjectTypeDef) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Static fields defined on this object, if any.
+func (r *ObjectTypeDef) Fields(ctx context.Context) ([]FieldTypeDef, error) {
+ q := r.query.Select("fields")
+
+ q = q.Select("id")
+
+ type fields struct {
+ Id ID
+ }
+
+ convert := func(fields []fields) []FieldTypeDef {
+ out := []FieldTypeDef{}
+
+ for i := range fields {
+ val := FieldTypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "FieldTypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []fields
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Functions defined on this object, if any.
+func (r *ObjectTypeDef) Functions(ctx context.Context) ([]Function, error) {
+ q := r.query.Select("functions")
+
+ q = q.Select("id")
+
+ type functions struct {
+ Id ID
+ }
+
+ convert := func(fields []functions) []Function {
+ out := []Function{}
+
+ for i := range fields {
+ val := Function{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Function")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []functions
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// A unique identifier for this ObjectTypeDef.
+func (r *ObjectTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ObjectTypeDef) XXX_GraphQLType() string {
+ return "ObjectTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ObjectTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ObjectTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ObjectTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ObjectTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ObjectTypeDef{query: selectNode(dag.query, id, "ObjectTypeDef")}
+ return nil
+}
+
+// The name of the object.
+func (r *ObjectTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The location of this object declaration.
+func (r *ObjectTypeDef) SourceMap() *SourceMap {
+ q := r.query.Select("sourceMap")
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// If this ObjectTypeDef is associated with a Module, the name of the module. Unset otherwise.
+func (r *ObjectTypeDef) SourceModuleName(ctx context.Context) (string, error) {
+ if r.sourceModuleName != nil {
+ return *r.sourceModuleName, nil
+ }
+ q := r.query.Select("sourceModuleName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this ObjectTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ObjectTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A port exposed by a container.
+type Port struct {
+ query *querybuilder.Selection
+
+ description *string
+ experimentalSkipHealthcheck *bool
+ id *ID
+ port *int
+ protocol *NetworkProtocol
+}
+
+func (r *Port) WithGraphQLQuery(q *querybuilder.Selection) *Port {
+ return &Port{
+ query: q,
+ }
+}
+
+// The port description.
+func (r *Port) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Skip the health check when run as a service.
+func (r *Port) ExperimentalSkipHealthcheck(ctx context.Context) (bool, error) {
+ if r.experimentalSkipHealthcheck != nil {
+ return *r.experimentalSkipHealthcheck, nil
+ }
+ q := r.query.Select("experimentalSkipHealthcheck")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Port.
+func (r *Port) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Port) XXX_GraphQLType() string {
+ return "Port"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Port) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Port) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Port) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Port) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Port{query: selectNode(dag.query, id, "Port")}
+ return nil
+}
+
+// The port number.
+func (r *Port) Port(ctx context.Context) (int, error) {
+ if r.port != nil {
+ return *r.port, nil
+ }
+ q := r.query.Select("port")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The transport layer protocol.
+func (r *Port) Protocol(ctx context.Context) (NetworkProtocol, error) {
+ if r.protocol != nil {
+ return *r.protocol, nil
+ }
+ q := r.query.Select("protocol")
+
+ var response NetworkProtocol
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Port as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Port) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// The root of the DAG.
+type Query struct {
+ query *querybuilder.Selection
+
+ defaultPlatform *Platform
+ id *ID
+ version *string
+}
+
+func (r *Query) WithGraphQLQuery(q *querybuilder.Selection) *Query {
+ return &Query{
+ query: q,
+ }
+}
+
+// initialize an address to load directories, containers, secrets or other object types.
+func (r *Query) Address(value string) *Address {
+ q := r.query.Select("address")
+ q = q.Arg("value", value)
+
+ return &Address{
+ query: q,
+ }
+}
+
+// CacheVolumeOpts contains options for Query.CacheVolume
+type CacheVolumeOpts struct {
+ // Identifier of the directory to use as the cache volume's root.
+ Source *Directory
+ // Sharing mode of the cache volume.
+ //
+ // Default: SHARED
+ Sharing CacheSharingMode
+ // A user:group to set for the cache volume root.
+ //
+ // The user and group can either be an ID (1000:1000) or a name (foo:bar).
+ //
+ // If the group is omitted, it defaults to the same as the user.
+ Owner string
+}
+
+// Constructs a cache volume for a given cache key.
+func (r *Query) CacheVolume(key string, opts ...CacheVolumeOpts) *CacheVolume {
+ q := r.query.Select("cacheVolume")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `source` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Source) {
+ q = q.Arg("source", opts[i].Source)
+ }
+ // `sharing` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Sharing) {
+ q = q.Arg("sharing", opts[i].Sharing)
+ }
+ // `owner` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Owner) {
+ q = q.Arg("owner", opts[i].Owner)
+ }
+ }
+ q = q.Arg("key", key)
+
+ return &CacheVolume{
+ query: q,
+ }
+}
+
+// Creates an empty changeset
+func (r *Query) Changeset() *Changeset {
+ q := r.query.Select("changeset")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Dagger Cloud configuration and state
+func (r *Query) Cloud() *Cloud {
+ q := r.query.Select("cloud")
+
+ return &Cloud{
+ query: q,
+ }
+}
+
+// ContainerOpts contains options for Query.Container
+type ContainerOpts struct {
+ // Platform to initialize the container with. Defaults to the native platform of the current engine
+ Platform Platform
+}
+
+// Creates a scratch container, with no image or metadata.
+//
+// To pull an image, follow up with the "from" function.
+func (r *Query) Container(opts ...ContainerOpts) *Container {
+ q := r.query.Select("container")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `platform` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Platform) {
+ q = q.Arg("platform", opts[i].Platform)
+ }
+ }
+
+ return &Container{
+ query: q,
+ }
+}
+
+// Returns the current environment
+//
+// When called from a function invoked via an LLM tool call, this will be the LLM's current environment, including any modifications made through calling tools. Env values returned by functions become the new environment for subsequent calls, and Changeset values returned by functions are applied to the environment's workspace.
+//
+// When called from a module function outside of an LLM, this returns an Env with the current module installed, and with the current module's source directory as its workspace.
+//
+// Experimental: Programmatic env access is speculative and might be replaced.
+func (r *Query) CurrentEnv() *Env {
+ q := r.query.Select("currentEnv")
+
+ return &Env{
+ query: q,
+ }
+}
+
+// The FunctionCall context that the SDK caller is currently executing in.
+//
+// If the caller is not currently executing in a function, this will return an error.
+func (r *Query) CurrentFunctionCall() *FunctionCall {
+ q := r.query.Select("currentFunctionCall")
+
+ return &FunctionCall{
+ query: q,
+ }
+}
+
+// The module currently being served in the session, if any.
+func (r *Query) CurrentModule() *CurrentModule {
+ q := r.query.Select("currentModule")
+
+ return &CurrentModule{
+ query: q,
+ }
+}
+
+// CurrentTypeDefsOpts contains options for Query.CurrentTypeDefs
+type CurrentTypeDefsOpts struct {
+ // Return the full referenced typedef closure instead of only top-level served typedefs.
+ ReturnAllTypes bool
+ // Strip core API functions from the Query type, leaving only module-sourced functions (constructors, entrypoint proxies, etc.).
+ //
+ // Core types (Container, Directory, etc.) are kept so return types and method chaining still work.
+ HideCore bool
+}
+
+// The TypeDef representations of the objects currently being served in the session.
+func (r *Query) CurrentTypeDefs(ctx context.Context, opts ...CurrentTypeDefsOpts) ([]TypeDef, error) {
+ q := r.query.Select("currentTypeDefs")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `returnAllTypes` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ReturnAllTypes) {
+ q = q.Arg("returnAllTypes", opts[i].ReturnAllTypes)
+ }
+ // `hideCore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].HideCore) {
+ q = q.Arg("hideCore", opts[i].HideCore)
+ }
+ }
+
+ q = q.Select("id")
+
+ type currentTypeDefs struct {
+ Id ID
+ }
+
+ convert := func(fields []currentTypeDefs) []TypeDef {
+ out := []TypeDef{}
+
+ for i := range fields {
+ val := TypeDef{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "TypeDef")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []currentTypeDefs
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Detect and return the current workspace.
+//
+// Experimental: Highly experimental API extracted from a more ambitious workspace implementation.
+func (r *Query) CurrentWorkspace() *Workspace {
+ q := r.query.Select("currentWorkspace")
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// The default platform of the engine.
+func (r *Query) DefaultPlatform(ctx context.Context) (Platform, error) {
+ q := r.query.Select("defaultPlatform")
+
+ var response Platform
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Creates an empty directory.
+func (r *Query) Directory() *Directory {
+ q := r.query.Select("directory")
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// EnvOpts contains options for Query.Env
+type EnvOpts struct {
+ // Give the environment the same privileges as the caller: core API including host access, current module, and dependencies
+ Privileged bool
+ // Allow new outputs to be declared and saved in the environment
+ Writable bool
+}
+
+// Initializes a new environment
+//
+// Experimental: Environments are not yet stabilized
+func (r *Query) Env(opts ...EnvOpts) *Env {
+ q := r.query.Select("env")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `privileged` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Privileged) {
+ q = q.Arg("privileged", opts[i].Privileged)
+ }
+ // `writable` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Writable) {
+ q = q.Arg("writable", opts[i].Writable)
+ }
+ }
+
+ return &Env{
+ query: q,
+ }
+}
+
+// EnvFileOpts contains options for Query.EnvFile
+type EnvFileOpts struct {
+ // Replace "${VAR}" or "$VAR" with the value of other vars
+ // Deprecated: Variable expansion is now enabled by default
+ Expand bool
+}
+
+// Initialize an environment file
+func (r *Query) EnvFile(opts ...EnvFileOpts) *EnvFile {
+ q := r.query.Select("envFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `expand` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Expand) {
+ q = q.Arg("expand", opts[i].Expand)
+ }
+ }
+
+ return &EnvFile{
+ query: q,
+ }
+}
+
+// Create a new error.
+func (r *Query) Error(message string) *Error {
+ q := r.query.Select("error")
+ q = q.Arg("message", message)
+
+ return &Error{
+ query: q,
+ }
+}
+
+// FileOpts contains options for Query.File
+type FileOpts struct {
+ // Permissions of the new file. Example: 0600
+ //
+ // Default: 420
+ Permissions int
+}
+
+// Creates a file with the specified contents.
+func (r *Query) File(name string, contents string, opts ...FileOpts) *File {
+ q := r.query.Select("file")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("name", name)
+ q = q.Arg("contents", contents)
+
+ return &File{
+ query: q,
+ }
+}
+
+// Creates a function.
+func (r *Query) Function(name string, returnType *TypeDef) *Function {
+ assertNotNil("returnType", returnType)
+ q := r.query.Select("function")
+ q = q.Arg("name", name)
+ q = q.Arg("returnType", returnType)
+
+ return &Function{
+ query: q,
+ }
+}
+
+// Create a code generation result, given a directory containing the generated code.
+func (r *Query) GeneratedCode(code *Directory) *GeneratedCode {
+ assertNotNil("code", code)
+ q := r.query.Select("generatedCode")
+ q = q.Arg("code", code)
+
+ return &GeneratedCode{
+ query: q,
+ }
+}
+
+// GitOpts contains options for Query.Git
+type GitOpts struct {
+ // DEPRECATED: Set to true to keep .git directory.
+ //
+ // Default: true
+ // Deprecated: Set to true to keep .git directory.
+ KeepGitDir bool
+ // Set SSH known hosts
+ SSHKnownHosts string
+ // Set SSH auth socket
+ SSHAuthSocket *Socket
+ // Username used to populate the password during basic HTTP Authorization
+ HTTPAuthUsername string
+ // Secret used to populate the password during basic HTTP Authorization
+ HTTPAuthToken *Secret
+ // Secret used to populate the Authorization HTTP header
+ HTTPAuthHeader *Secret
+ // A service which must be started before the repo is fetched.
+ ExperimentalServiceHost *Service
+}
+
+// Queries a Git repository.
+func (r *Query) Git(url string, opts ...GitOpts) *GitRepository {
+ q := r.query.Select("git")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `keepGitDir` optional argument
+ if !querybuilder.IsZeroValue(opts[i].KeepGitDir) {
+ q = q.Arg("keepGitDir", opts[i].KeepGitDir)
+ }
+ // `sshKnownHosts` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SSHKnownHosts) {
+ q = q.Arg("sshKnownHosts", opts[i].SSHKnownHosts)
+ }
+ // `sshAuthSocket` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SSHAuthSocket) {
+ q = q.Arg("sshAuthSocket", opts[i].SSHAuthSocket)
+ }
+ // `httpAuthUsername` optional argument
+ if !querybuilder.IsZeroValue(opts[i].HTTPAuthUsername) {
+ q = q.Arg("httpAuthUsername", opts[i].HTTPAuthUsername)
+ }
+ // `httpAuthToken` optional argument
+ if !querybuilder.IsZeroValue(opts[i].HTTPAuthToken) {
+ q = q.Arg("httpAuthToken", opts[i].HTTPAuthToken)
+ }
+ // `httpAuthHeader` optional argument
+ if !querybuilder.IsZeroValue(opts[i].HTTPAuthHeader) {
+ q = q.Arg("httpAuthHeader", opts[i].HTTPAuthHeader)
+ }
+ // `experimentalServiceHost` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalServiceHost) {
+ q = q.Arg("experimentalServiceHost", opts[i].ExperimentalServiceHost)
+ }
+ }
+ q = q.Arg("url", url)
+
+ return &GitRepository{
+ query: q,
+ }
+}
+
+// HTTPOpts contains options for Query.HTTP
+type HTTPOpts struct {
+ // File name to use for the file. Defaults to the last part of the URL.
+ Name string
+ // Permissions to set on the file.
+ Permissions int
+ // Expected digest of the downloaded content (e.g., "sha256:...").
+ Checksum string
+ // Secret used to populate the Authorization HTTP header
+ AuthHeader *Secret
+ // A service which must be started before the URL is fetched.
+ ExperimentalServiceHost *Service
+}
+
+// Returns a file containing an http remote url content.
+func (r *Query) HTTP(url string, opts ...HTTPOpts) *File {
+ q := r.query.Select("http")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `name` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Name) {
+ q = q.Arg("name", opts[i].Name)
+ }
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ // `checksum` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Checksum) {
+ q = q.Arg("checksum", opts[i].Checksum)
+ }
+ // `authHeader` optional argument
+ if !querybuilder.IsZeroValue(opts[i].AuthHeader) {
+ q = q.Arg("authHeader", opts[i].AuthHeader)
+ }
+ // `experimentalServiceHost` optional argument
+ if !querybuilder.IsZeroValue(opts[i].ExperimentalServiceHost) {
+ q = q.Arg("experimentalServiceHost", opts[i].ExperimentalServiceHost)
+ }
+ }
+ q = q.Arg("url", url)
+
+ return &File{
+ query: q,
+ }
+}
+
+// A unique identifier for this Query.
+func (r *Query) ID(ctx context.Context) (ID, error) {
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Query) XXX_GraphQLType() string {
+ return "Query"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Query) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Query) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Query) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Query) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Query{query: selectNode(dag.query, id, "Query")}
+ return nil
+}
+
+// Initialize a JSON value
+func (r *Query) JSON() *JSONValue {
+ q := r.query.Select("json")
+
+ return &JSONValue{
+ query: q,
+ }
+}
+
+// LLMOpts contains options for Query.LLM
+type LLMOpts struct {
+ // Model to use
+ Model string
+ // Cap the number of API calls for this LLM
+ MaxAPICalls int
+}
+
+// Initialize a Large Language Model (LLM)
+//
+// Experimental: LLM support is not yet stabilized
+func (r *Query) LLM(opts ...LLMOpts) *LLM {
+ q := r.query.Select("llm")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `model` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Model) {
+ q = q.Arg("model", opts[i].Model)
+ }
+ // `maxAPICalls` optional argument
+ if !querybuilder.IsZeroValue(opts[i].MaxAPICalls) {
+ q = q.Arg("maxAPICalls", opts[i].MaxAPICalls)
+ }
+ }
+
+ return &LLM{
+ query: q,
+ }
+}
+
+// Create a new module.
+func (r *Query) Module() *Module {
+ q := r.query.Select("module")
+
+ return &Module{
+ query: q,
+ }
+}
+
+// ModuleSourceOpts contains options for Query.ModuleSource
+type ModuleSourceOpts struct {
+ // The pinned version of the module source
+ RefPin string
+ // If true, do not attempt to find a module config file in a parent directory of the provided path. Only relevant for local module sources.
+ DisableFindUp bool
+ // If true, do not error out if the provided ref string is a local path and does not exist yet. Useful when initializing new modules in directories that don't exist yet.
+ AllowNotExists bool
+ // If set, error out if the ref string is not of the provided requireKind.
+ RequireKind ModuleSourceKind
+}
+
+// Create a new module source instance from a source ref string
+func (r *Query) ModuleSource(refString string, opts ...ModuleSourceOpts) *ModuleSource {
+ q := r.query.Select("moduleSource")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `refPin` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RefPin) {
+ q = q.Arg("refPin", opts[i].RefPin)
+ }
+ // `disableFindUp` optional argument
+ if !querybuilder.IsZeroValue(opts[i].DisableFindUp) {
+ q = q.Arg("disableFindUp", opts[i].DisableFindUp)
+ }
+ // `allowNotExists` optional argument
+ if !querybuilder.IsZeroValue(opts[i].AllowNotExists) {
+ q = q.Arg("allowNotExists", opts[i].AllowNotExists)
+ }
+ // `requireKind` optional argument
+ if !querybuilder.IsZeroValue(opts[i].RequireKind) {
+ q = q.Arg("requireKind", opts[i].RequireKind)
+ }
+ }
+ q = q.Arg("refString", refString)
+
+ return &ModuleSource{
+ query: q,
+ }
+}
+
+// Load any object by its ID.
+func (r *Query) Node(id ID) Node {
+ q := r.query.Select("node")
+ q = q.Arg("id", id)
+ return &NodeClient{
+ query: q,
+ }
+}
+
+// SecretOpts contains options for Query.Secret
+type SecretOpts struct {
+ // If set, the given string will be used as the cache key for this secret. This means that any secrets with the same cache key will be considered equivalent in terms of cache lookups, even if they have different URIs or plaintext values.
+ //
+ // For example, two secrets with the same cache key provided as secret env vars to other wise equivalent containers will result in the container withExecs hitting the cache for each other.
+ //
+ // If not set, the cache key for the secret will be derived from its plaintext value as looked up when the secret is constructed.
+ CacheKey string
+}
+
+// Creates a new secret.
+func (r *Query) Secret(uri string, opts ...SecretOpts) *Secret {
+ q := r.query.Select("secret")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `cacheKey` optional argument
+ if !querybuilder.IsZeroValue(opts[i].CacheKey) {
+ q = q.Arg("cacheKey", opts[i].CacheKey)
+ }
+ }
+ q = q.Arg("uri", uri)
+
+ return &Secret{
+ query: q,
+ }
+}
+
+// Sets a secret given a user defined name to its plaintext and returns the secret.
+//
+// The plaintext value is limited to a size of 128000 bytes.
+func (r *Query) SetSecret(name string, plaintext string) *Secret {
+ q := r.query.Select("setSecret")
+ q = q.Arg("name", name)
+ q = q.Arg("plaintext", plaintext)
+
+ return &Secret{
+ query: q,
+ }
+}
+
+// Creates source map metadata.
+func (r *Query) SourceMap(filename string, line int, column int) *SourceMap {
+ q := r.query.Select("sourceMap")
+ q = q.Arg("filename", filename)
+ q = q.Arg("line", line)
+ q = q.Arg("column", column)
+
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// Create a new TypeDef.
+func (r *Query) TypeDef() *TypeDef {
+ q := r.query.Select("typeDef")
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// Get the current Dagger Engine version.
+func (r *Query) Version(ctx context.Context) (string, error) {
+ q := r.query.Select("version")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Query as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Query) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An internal persistent bare git mirror.
+type RemoteGitMirror struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *RemoteGitMirror) WithGraphQLQuery(q *querybuilder.Selection) *RemoteGitMirror {
+ return &RemoteGitMirror{
+ query: q,
+ }
+}
+
+// A unique identifier for this RemoteGitMirror.
+func (r *RemoteGitMirror) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *RemoteGitMirror) XXX_GraphQLType() string {
+ return "RemoteGitMirror"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *RemoteGitMirror) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *RemoteGitMirror) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *RemoteGitMirror) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *RemoteGitMirror) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = RemoteGitMirror{query: selectNode(dag.query, id, "RemoteGitMirror")}
+ return nil
+}
+
+// AsNode returns this RemoteGitMirror as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *RemoteGitMirror) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// The SDK config of the module.
+type SDKConfig struct {
+ query *querybuilder.Selection
+
+ debug *bool
+ id *ID
+ source *string
+}
+
+func (r *SDKConfig) WithGraphQLQuery(q *querybuilder.Selection) *SDKConfig {
+ return &SDKConfig{
+ query: q,
+ }
+}
+
+// Whether to start the SDK runtime in debug mode with an interactive terminal.
+func (r *SDKConfig) Debug(ctx context.Context) (bool, error) {
+ if r.debug != nil {
+ return *r.debug, nil
+ }
+ q := r.query.Select("debug")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this SDKConfig.
+func (r *SDKConfig) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *SDKConfig) XXX_GraphQLType() string {
+ return "SDKConfig"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *SDKConfig) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *SDKConfig) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *SDKConfig) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *SDKConfig) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = SDKConfig{query: selectNode(dag.query, id, "SDKConfig")}
+ return nil
+}
+
+// Source of the SDK. Either a name of a builtin SDK or a module source ref string pointing to the SDK's implementation.
+func (r *SDKConfig) Source(ctx context.Context) (string, error) {
+ if r.source != nil {
+ return *r.source, nil
+ }
+ q := r.query.Select("source")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this SDKConfig as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *SDKConfig) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A definition of a custom scalar defined in a Module.
+type ScalarTypeDef struct {
+ query *querybuilder.Selection
+
+ description *string
+ id *ID
+ name *string
+ sourceModuleName *string
+}
+
+func (r *ScalarTypeDef) WithGraphQLQuery(q *querybuilder.Selection) *ScalarTypeDef {
+ return &ScalarTypeDef{
+ query: q,
+ }
+}
+
+// A doc string for the scalar, if any.
+func (r *ScalarTypeDef) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this ScalarTypeDef.
+func (r *ScalarTypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ScalarTypeDef) XXX_GraphQLType() string {
+ return "ScalarTypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ScalarTypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ScalarTypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ScalarTypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ScalarTypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ScalarTypeDef{query: selectNode(dag.query, id, "ScalarTypeDef")}
+ return nil
+}
+
+// The name of the scalar.
+func (r *ScalarTypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// If this ScalarTypeDef is associated with a Module, the name of the module. Unset otherwise.
+func (r *ScalarTypeDef) SourceModuleName(ctx context.Context) (string, error) {
+ if r.sourceModuleName != nil {
+ return *r.sourceModuleName, nil
+ }
+ q := r.query.Select("sourceModuleName")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this ScalarTypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *ScalarTypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type SearchResult struct {
+ query *querybuilder.Selection
+
+ absoluteOffset *int
+ filePath *string
+ id *ID
+ lineNumber *int
+ matchedLines *string
+}
+
+func (r *SearchResult) WithGraphQLQuery(q *querybuilder.Selection) *SearchResult {
+ return &SearchResult{
+ query: q,
+ }
+}
+
+// The byte offset of this line within the file.
+func (r *SearchResult) AbsoluteOffset(ctx context.Context) (int, error) {
+ if r.absoluteOffset != nil {
+ return *r.absoluteOffset, nil
+ }
+ q := r.query.Select("absoluteOffset")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The path to the file that matched.
+func (r *SearchResult) FilePath(ctx context.Context) (string, error) {
+ if r.filePath != nil {
+ return *r.filePath, nil
+ }
+ q := r.query.Select("filePath")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this SearchResult.
+func (r *SearchResult) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *SearchResult) XXX_GraphQLType() string {
+ return "SearchResult"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *SearchResult) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *SearchResult) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *SearchResult) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *SearchResult) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = SearchResult{query: selectNode(dag.query, id, "SearchResult")}
+ return nil
+}
+
+// The first line that matched.
+func (r *SearchResult) LineNumber(ctx context.Context) (int, error) {
+ if r.lineNumber != nil {
+ return *r.lineNumber, nil
+ }
+ q := r.query.Select("lineNumber")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The line content that matched.
+func (r *SearchResult) MatchedLines(ctx context.Context) (string, error) {
+ if r.matchedLines != nil {
+ return *r.matchedLines, nil
+ }
+ q := r.query.Select("matchedLines")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Sub-match positions and content within the matched lines.
+func (r *SearchResult) Submatches(ctx context.Context) ([]SearchSubmatch, error) {
+ q := r.query.Select("submatches")
+
+ q = q.Select("id")
+
+ type submatches struct {
+ Id ID
+ }
+
+ convert := func(fields []submatches) []SearchSubmatch {
+ out := []SearchSubmatch{}
+
+ for i := range fields {
+ val := SearchSubmatch{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "SearchSubmatch")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []submatches
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// AsNode returns this SearchResult as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *SearchResult) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type SearchSubmatch struct {
+ query *querybuilder.Selection
+
+ end *int
+ id *ID
+ start *int
+ text *string
+}
+
+func (r *SearchSubmatch) WithGraphQLQuery(q *querybuilder.Selection) *SearchSubmatch {
+ return &SearchSubmatch{
+ query: q,
+ }
+}
+
+// The match's end offset within the matched lines.
+func (r *SearchSubmatch) End(ctx context.Context) (int, error) {
+ if r.end != nil {
+ return *r.end, nil
+ }
+ q := r.query.Select("end")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this SearchSubmatch.
+func (r *SearchSubmatch) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *SearchSubmatch) XXX_GraphQLType() string {
+ return "SearchSubmatch"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *SearchSubmatch) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *SearchSubmatch) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *SearchSubmatch) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *SearchSubmatch) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = SearchSubmatch{query: selectNode(dag.query, id, "SearchSubmatch")}
+ return nil
+}
+
+// The match's start offset within the matched lines.
+func (r *SearchSubmatch) Start(ctx context.Context) (int, error) {
+ if r.start != nil {
+ return *r.start, nil
+ }
+ q := r.query.Select("start")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The matched text.
+func (r *SearchSubmatch) Text(ctx context.Context) (string, error) {
+ if r.text != nil {
+ return *r.text, nil
+ }
+ q := r.query.Select("text")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this SearchSubmatch as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *SearchSubmatch) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A reference to a secret value, which can be handled more safely than the value itself.
+type Secret struct {
+ query *querybuilder.Selection
+
+ id *ID
+ name *string
+ plaintext *string
+ uri *string
+}
+
+func (r *Secret) WithGraphQLQuery(q *querybuilder.Selection) *Secret {
+ return &Secret{
+ query: q,
+ }
+}
+
+// A unique identifier for this Secret.
+func (r *Secret) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Secret) XXX_GraphQLType() string {
+ return "Secret"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Secret) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Secret) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Secret) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Secret) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Secret{query: selectNode(dag.query, id, "Secret")}
+ return nil
+}
+
+// The name of this secret.
+func (r *Secret) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The value of this secret.
+func (r *Secret) Plaintext(ctx context.Context) (string, error) {
+ if r.plaintext != nil {
+ return *r.plaintext, nil
+ }
+ q := r.query.Select("plaintext")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The URI of this secret.
+func (r *Secret) URI(ctx context.Context) (string, error) {
+ if r.uri != nil {
+ return *r.uri, nil
+ }
+ q := r.query.Select("uri")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Secret as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Secret) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A content-addressed service providing TCP connectivity.
+type Service struct {
+ query *querybuilder.Selection
+
+ endpoint *string
+ hostname *string
+ id *ID
+ start *ID
+ stop *ID
+ sync *ID
+ up *Void
+}
+type WithServiceFunc func(r *Service) *Service
+
+// With calls the provided function with current Service.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Service) With(f WithServiceFunc) *Service {
+ return f(r)
+}
+
+func (r *Service) WithGraphQLQuery(q *querybuilder.Selection) *Service {
+ return &Service{
+ query: q,
+ }
+}
+
+// ServiceEndpointOpts contains options for Service.Endpoint
+type ServiceEndpointOpts struct {
+ // The exposed port number for the endpoint
+ Port int
+ // Return a URL with the given scheme, eg. http for http://
+ Scheme string
+}
+
+// Retrieves an endpoint that clients can use to reach this container.
+//
+// If no port is specified, the first exposed port is used. If none exist an error is returned.
+//
+// If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
+func (r *Service) Endpoint(ctx context.Context, opts ...ServiceEndpointOpts) (string, error) {
+ if r.endpoint != nil {
+ return *r.endpoint, nil
+ }
+ q := r.query.Select("endpoint")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `port` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Port) {
+ q = q.Arg("port", opts[i].Port)
+ }
+ // `scheme` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Scheme) {
+ q = q.Arg("scheme", opts[i].Scheme)
+ }
+ }
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Retrieves a hostname which can be used by clients to reach this container.
+func (r *Service) Hostname(ctx context.Context) (string, error) {
+ if r.hostname != nil {
+ return *r.hostname, nil
+ }
+ q := r.query.Select("hostname")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Service.
+func (r *Service) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Service) XXX_GraphQLType() string {
+ return "Service"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Service) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Service) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Service) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Service) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Service{query: selectNode(dag.query, id, "Service")}
+ return nil
+}
+
+// Retrieves the list of ports provided by the service.
+func (r *Service) Ports(ctx context.Context) ([]Port, error) {
+ q := r.query.Select("ports")
+
+ q = q.Select("id")
+
+ type ports struct {
+ Id ID
+ }
+
+ convert := func(fields []ports) []Port {
+ out := []Port{}
+
+ for i := range fields {
+ val := Port{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Port")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []ports
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Start the service and wait for its health checks to succeed.
+//
+// Services bound to a Container do not need to be manually started.
+func (r *Service) Start(ctx context.Context) (*Service, error) {
+ q := r.query.Select("start")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Service{
+ query: selectNode(q.Root(), id, "Service"),
+ }, nil
+}
+
+// ServiceStopOpts contains options for Service.Stop
+type ServiceStopOpts struct {
+ // Immediately kill the service without waiting for a graceful exit
+ Kill bool
+}
+
+// Stop the service.
+func (r *Service) Stop(ctx context.Context, opts ...ServiceStopOpts) (*Service, error) {
+ q := r.query.Select("stop")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `kill` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Kill) {
+ q = q.Arg("kill", opts[i].Kill)
+ }
+ }
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Service{
+ query: selectNode(q.Root(), id, "Service"),
+ }, nil
+}
+
+// Forces evaluation of the pipeline in the engine.
+func (r *Service) Sync(ctx context.Context) (*Service, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Service{
+ query: selectNode(q.Root(), id, "Service"),
+ }, nil
+}
+
+// ServiceTerminalOpts contains options for Service.Terminal
+type ServiceTerminalOpts struct {
+ Cmd []string
+}
+
+func (r *Service) Terminal(opts ...ServiceTerminalOpts) *Service {
+ q := r.query.Select("terminal")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `cmd` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Cmd) {
+ q = q.Arg("cmd", opts[i].Cmd)
+ }
+ }
+
+ return &Service{
+ query: q,
+ }
+}
+
+// ServiceUpOpts contains options for Service.Up
+type ServiceUpOpts struct {
+ // List of frontend/backend port mappings to forward.
+ //
+ // Frontend is the port accepting traffic on the host, backend is the service port.
+ Ports []PortForward
+ // Bind each tunnel port to a random port on the host.
+ Random bool
+}
+
+// Creates a tunnel that forwards traffic from the caller's network to this service.
+func (r *Service) Up(ctx context.Context, opts ...ServiceUpOpts) error {
+ if r.up != nil {
+ return nil
+ }
+ q := r.query.Select("up")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `ports` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Ports) {
+ q = q.Arg("ports", opts[i].Ports)
+ }
+ // `random` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Random) {
+ q = q.Arg("random", opts[i].Random)
+ }
+ }
+
+ return q.Execute(ctx)
+}
+
+// Configures a hostname which can be used by clients within the session to reach this container.
+func (r *Service) WithHostname(hostname string) *Service {
+ q := r.query.Select("withHostname")
+ q = q.Arg("hostname", hostname)
+
+ return &Service{
+ query: q,
+ }
+}
+
+// AsNode returns this Service as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Service) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this Service as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *Service) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// A Unix or TCP/IP socket that can be mounted into a container.
+type Socket struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *Socket) WithGraphQLQuery(q *querybuilder.Selection) *Socket {
+ return &Socket{
+ query: q,
+ }
+}
+
+// A unique identifier for this Socket.
+func (r *Socket) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Socket) XXX_GraphQLType() string {
+ return "Socket"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Socket) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Socket) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Socket) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Socket) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Socket{query: selectNode(dag.query, id, "Socket")}
+ return nil
+}
+
+// AsNode returns this Socket as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Socket) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// Source location information.
+type SourceMap struct {
+ query *querybuilder.Selection
+
+ column *int
+ filename *string
+ id *ID
+ line *int
+ module *string
+ url *string
+}
+
+func (r *SourceMap) WithGraphQLQuery(q *querybuilder.Selection) *SourceMap {
+ return &SourceMap{
+ query: q,
+ }
+}
+
+// The column number within the line.
+func (r *SourceMap) Column(ctx context.Context) (int, error) {
+ if r.column != nil {
+ return *r.column, nil
+ }
+ q := r.query.Select("column")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The filename from the module source.
+func (r *SourceMap) Filename(ctx context.Context) (string, error) {
+ if r.filename != nil {
+ return *r.filename, nil
+ }
+ q := r.query.Select("filename")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this SourceMap.
+func (r *SourceMap) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *SourceMap) XXX_GraphQLType() string {
+ return "SourceMap"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *SourceMap) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *SourceMap) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *SourceMap) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *SourceMap) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = SourceMap{query: selectNode(dag.query, id, "SourceMap")}
+ return nil
+}
+
+// The line number within the filename.
+func (r *SourceMap) Line(ctx context.Context) (int, error) {
+ if r.line != nil {
+ return *r.line, nil
+ }
+ q := r.query.Select("line")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The module dependency this was declared in.
+func (r *SourceMap) Module(ctx context.Context) (string, error) {
+ if r.module != nil {
+ return *r.module, nil
+ }
+ q := r.query.Select("module")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The URL to the file, if any. This can be used to link to the source map in the browser.
+func (r *SourceMap) URL(ctx context.Context) (string, error) {
+ if r.url != nil {
+ return *r.url, nil
+ }
+ q := r.query.Select("url")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this SourceMap as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *SourceMap) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A file or directory status object.
+type Stat struct {
+ query *querybuilder.Selection
+
+ fileType *FileType
+ id *ID
+ name *string
+ permissions *int
+ size *int
+}
+
+func (r *Stat) WithGraphQLQuery(q *querybuilder.Selection) *Stat {
+ return &Stat{
+ query: q,
+ }
+}
+
+// file type
+func (r *Stat) FileType(ctx context.Context) (FileType, error) {
+ if r.fileType != nil {
+ return *r.fileType, nil
+ }
+ q := r.query.Select("fileType")
+
+ var response FileType
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Stat.
+func (r *Stat) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Stat) XXX_GraphQLType() string {
+ return "Stat"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Stat) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Stat) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Stat) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Stat) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Stat{query: selectNode(dag.query, id, "Stat")}
+ return nil
+}
+
+// file name
+func (r *Stat) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// permission bits
+func (r *Stat) Permissions(ctx context.Context) (int, error) {
+ if r.permissions != nil {
+ return *r.permissions, nil
+ }
+ q := r.query.Select("permissions")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// file size
+func (r *Stat) Size(ctx context.Context) (int, error) {
+ if r.size != nil {
+ return *r.size, nil
+ }
+ q := r.query.Select("size")
+
+ var response int
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this Stat as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Stat) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An interactive terminal that clients can connect to.
+type Terminal struct {
+ query *querybuilder.Selection
+
+ id *ID
+ sync *ID
+}
+
+func (r *Terminal) WithGraphQLQuery(q *querybuilder.Selection) *Terminal {
+ return &Terminal{
+ query: q,
+ }
+}
+
+// A unique identifier for this Terminal.
+func (r *Terminal) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Terminal) XXX_GraphQLType() string {
+ return "Terminal"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Terminal) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Terminal) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Terminal) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Terminal) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Terminal{query: selectNode(dag.query, id, "Terminal")}
+ return nil
+}
+
+// Forces evaluation of the pipeline in the engine.
+//
+// It doesn't run the default command if no exec has been set.
+func (r *Terminal) Sync(ctx context.Context) (*Terminal, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &Terminal{
+ query: selectNode(q.Root(), id, "Terminal"),
+ }, nil
+}
+
+// AsNode returns this Terminal as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Terminal) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// AsSyncer returns this Terminal as a Syncer.
+// This is a local type conversion — no GraphQL call.
+func (r *Terminal) AsSyncer() Syncer {
+ return &SyncerClient{
+ query: r.query,
+ }
+}
+
+// A definition of a parameter or return type in a Module.
+type TypeDef struct {
+ query *querybuilder.Selection
+
+ id *ID
+ kind *TypeDefKind
+ name *string
+ optional *bool
+}
+type WithTypeDefFunc func(r *TypeDef) *TypeDef
+
+// With calls the provided function with current TypeDef.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *TypeDef) With(f WithTypeDefFunc) *TypeDef {
+ return f(r)
+}
+
+func (r *TypeDef) WithGraphQLQuery(q *querybuilder.Selection) *TypeDef {
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// If kind is ENUM, the enum-specific type definition. If kind is not ENUM, this will be null.
+func (r *TypeDef) AsEnum() *EnumTypeDef {
+ q := r.query.Select("asEnum")
+
+ return &EnumTypeDef{
+ query: q,
+ }
+}
+
+// If kind is INPUT, the input-specific type definition. If kind is not INPUT, this will be null.
+func (r *TypeDef) AsInput() *InputTypeDef {
+ q := r.query.Select("asInput")
+
+ return &InputTypeDef{
+ query: q,
+ }
+}
+
+// If kind is INTERFACE, the interface-specific type definition. If kind is not INTERFACE, this will be null.
+func (r *TypeDef) AsInterface() *InterfaceTypeDef {
+ q := r.query.Select("asInterface")
+
+ return &InterfaceTypeDef{
+ query: q,
+ }
+}
+
+// If kind is LIST, the list-specific type definition. If kind is not LIST, this will be null.
+func (r *TypeDef) AsList() *ListTypeDef {
+ q := r.query.Select("asList")
+
+ return &ListTypeDef{
+ query: q,
+ }
+}
+
+// If kind is OBJECT, the object-specific type definition. If kind is not OBJECT, this will be null.
+func (r *TypeDef) AsObject() *ObjectTypeDef {
+ q := r.query.Select("asObject")
+
+ return &ObjectTypeDef{
+ query: q,
+ }
+}
+
+// If kind is SCALAR, the scalar-specific type definition. If kind is not SCALAR, this will be null.
+func (r *TypeDef) AsScalar() *ScalarTypeDef {
+ q := r.query.Select("asScalar")
+
+ return &ScalarTypeDef{
+ query: q,
+ }
+}
+
+// A unique identifier for this TypeDef.
+func (r *TypeDef) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *TypeDef) XXX_GraphQLType() string {
+ return "TypeDef"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *TypeDef) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *TypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *TypeDef) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *TypeDef) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = TypeDef{query: selectNode(dag.query, id, "TypeDef")}
+ return nil
+}
+
+// The kind of type this is (e.g. primitive, list, object).
+func (r *TypeDef) Kind(ctx context.Context) (TypeDefKind, error) {
+ if r.kind != nil {
+ return *r.kind, nil
+ }
+ q := r.query.Select("kind")
+
+ var response TypeDefKind
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The canonical non-optional name of the type.
+func (r *TypeDef) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Whether this type can be set to null. Defaults to false.
+func (r *TypeDef) Optional(ctx context.Context) (bool, error) {
+ if r.optional != nil {
+ return *r.optional, nil
+ }
+ q := r.query.Select("optional")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Adds a function for constructing a new instance of an Object TypeDef, failing if the type is not an object.
+func (r *TypeDef) WithConstructor(function *Function) *TypeDef {
+ assertNotNil("function", function)
+ q := r.query.Select("withConstructor")
+ q = q.Arg("function", function)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithEnumOpts contains options for TypeDef.WithEnum
+type TypeDefWithEnumOpts struct {
+ // A doc string for the enum, if any
+ Description string
+ // The source map for the enum definition.
+ SourceMap *SourceMap
+}
+
+// Returns a TypeDef of kind Enum with the provided name.
+//
+// Note that an enum's values may be omitted if the intent is only to refer to an enum. This is how functions are able to return their own, or any other circular reference.
+func (r *TypeDef) WithEnum(name string, opts ...TypeDefWithEnumOpts) *TypeDef {
+ q := r.query.Select("withEnum")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithEnumMemberOpts contains options for TypeDef.WithEnumMember
+type TypeDefWithEnumMemberOpts struct {
+ // The value of the member in the enum
+ Value string
+ // A doc string for the member, if any
+ Description string
+ // The source map for the enum member definition.
+ SourceMap *SourceMap
+ // If deprecated, the reason or migration path.
+ Deprecated string
+}
+
+// Adds a static value for an Enum TypeDef, failing if the type is not an enum.
+func (r *TypeDef) WithEnumMember(name string, opts ...TypeDefWithEnumMemberOpts) *TypeDef {
+ q := r.query.Select("withEnumMember")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `value` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Value) {
+ q = q.Arg("value", opts[i].Value)
+ }
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ // `deprecated` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Deprecated) {
+ q = q.Arg("deprecated", opts[i].Deprecated)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithEnumValueOpts contains options for TypeDef.WithEnumValue
+type TypeDefWithEnumValueOpts struct {
+ // A doc string for the value, if any
+ Description string
+ // The source map for the enum value definition.
+ SourceMap *SourceMap
+ // If deprecated, the reason or migration path.
+ Deprecated string
+}
+
+// Adds a static value for an Enum TypeDef, failing if the type is not an enum.
+//
+// Deprecated: Use WithEnumMember instead
+func (r *TypeDef) WithEnumValue(value string, opts ...TypeDefWithEnumValueOpts) *TypeDef {
+ q := r.query.Select("withEnumValue")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ // `deprecated` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Deprecated) {
+ q = q.Arg("deprecated", opts[i].Deprecated)
+ }
+ }
+ q = q.Arg("value", value)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithFieldOpts contains options for TypeDef.WithField
+type TypeDefWithFieldOpts struct {
+ // A doc string for the field, if any
+ Description string
+ // The source map for the field definition.
+ SourceMap *SourceMap
+ // If deprecated, the reason or migration path.
+ Deprecated string
+}
+
+// Adds a static field for an Object TypeDef, failing if the type is not an object.
+func (r *TypeDef) WithField(name string, typeDef *TypeDef, opts ...TypeDefWithFieldOpts) *TypeDef {
+ assertNotNil("typeDef", typeDef)
+ q := r.query.Select("withField")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ // `deprecated` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Deprecated) {
+ q = q.Arg("deprecated", opts[i].Deprecated)
+ }
+ }
+ q = q.Arg("name", name)
+ q = q.Arg("typeDef", typeDef)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// Adds a function for an Object or Interface TypeDef, failing if the type is not one of those kinds.
+func (r *TypeDef) WithFunction(function *Function) *TypeDef {
+ assertNotNil("function", function)
+ q := r.query.Select("withFunction")
+ q = q.Arg("function", function)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithInterfaceOpts contains options for TypeDef.WithInterface
+type TypeDefWithInterfaceOpts struct {
+ Description string
+
+ SourceMap *SourceMap
+}
+
+// Returns a TypeDef of kind Interface with the provided name.
+func (r *TypeDef) WithInterface(name string, opts ...TypeDefWithInterfaceOpts) *TypeDef {
+ q := r.query.Select("withInterface")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// Sets the kind of the type.
+func (r *TypeDef) WithKind(kind TypeDefKind) *TypeDef {
+ q := r.query.Select("withKind")
+ q = q.Arg("kind", kind)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// Returns a TypeDef of kind List with the provided type for its elements.
+func (r *TypeDef) WithListOf(elementType *TypeDef) *TypeDef {
+ assertNotNil("elementType", elementType)
+ q := r.query.Select("withListOf")
+ q = q.Arg("elementType", elementType)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithObjectOpts contains options for TypeDef.WithObject
+type TypeDefWithObjectOpts struct {
+ Description string
+
+ SourceMap *SourceMap
+
+ Deprecated string
+}
+
+// Returns a TypeDef of kind Object with the provided name.
+//
+// Note that an object's fields and functions may be omitted if the intent is only to refer to an object. This is how functions are able to return their own object, or any other circular reference.
+func (r *TypeDef) WithObject(name string, opts ...TypeDefWithObjectOpts) *TypeDef {
+ q := r.query.Select("withObject")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ // `sourceMap` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SourceMap) {
+ q = q.Arg("sourceMap", opts[i].SourceMap)
+ }
+ // `deprecated` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Deprecated) {
+ q = q.Arg("deprecated", opts[i].Deprecated)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// Sets whether this type can be set to null.
+func (r *TypeDef) WithOptional(optional bool) *TypeDef {
+ q := r.query.Select("withOptional")
+ q = q.Arg("optional", optional)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// TypeDefWithScalarOpts contains options for TypeDef.WithScalar
+type TypeDefWithScalarOpts struct {
+ Description string
+}
+
+// Returns a TypeDef of kind Scalar with the provided name.
+func (r *TypeDef) WithScalar(name string, opts ...TypeDefWithScalarOpts) *TypeDef {
+ q := r.query.Select("withScalar")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `description` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Description) {
+ q = q.Arg("description", opts[i].Description)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return &TypeDef{
+ query: q,
+ }
+}
+
+// AsNode returns this TypeDef as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *TypeDef) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type Up struct {
+ query *querybuilder.Selection
+
+ description *string
+ id *ID
+ name *string
+}
+type WithUpFunc func(r *Up) *Up
+
+// With calls the provided function with current Up.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Up) With(f WithUpFunc) *Up {
+ return f(r)
+}
+
+func (r *Up) WithGraphQLQuery(q *querybuilder.Selection) *Up {
+ return &Up{
+ query: q,
+ }
+}
+
+// The description of the service
+func (r *Up) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this Up.
+func (r *Up) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Up) XXX_GraphQLType() string {
+ return "Up"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Up) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Up) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Up) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Up) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Up{query: selectNode(dag.query, id, "Up")}
+ return nil
+}
+
+// Return the fully qualified name of the service
+func (r *Up) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The original module in which the service has been defined
+func (r *Up) OriginalModule() *Module {
+ q := r.query.Select("originalModule")
+
+ return &Module{
+ query: q,
+ }
+}
+
+// The path of the service within its module
+func (r *Up) Path(ctx context.Context) ([]string, error) {
+ q := r.query.Select("path")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Execute the service function
+func (r *Up) Run() *Up {
+ q := r.query.Select("run")
+
+ return &Up{
+ query: q,
+ }
+}
+
+// AsNode returns this Up as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Up) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+type UpGroup struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+type WithUpGroupFunc func(r *UpGroup) *UpGroup
+
+// With calls the provided function with current UpGroup.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *UpGroup) With(f WithUpGroupFunc) *UpGroup {
+ return f(r)
+}
+
+func (r *UpGroup) WithGraphQLQuery(q *querybuilder.Selection) *UpGroup {
+ return &UpGroup{
+ query: q,
+ }
+}
+
+// A unique identifier for this UpGroup.
+func (r *UpGroup) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *UpGroup) XXX_GraphQLType() string {
+ return "UpGroup"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *UpGroup) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *UpGroup) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *UpGroup) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *UpGroup) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = UpGroup{query: selectNode(dag.query, id, "UpGroup")}
+ return nil
+}
+
+// Return a list of individual services and their details
+func (r *UpGroup) List(ctx context.Context) ([]Up, error) {
+ q := r.query.Select("list")
+
+ q = q.Select("id")
+
+ type list struct {
+ Id ID
+ }
+
+ convert := func(fields []list) []Up {
+ out := []Up{}
+
+ for i := range fields {
+ val := Up{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "Up")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []list
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// Execute all selected service functions
+func (r *UpGroup) Run() *UpGroup {
+ q := r.query.Select("run")
+
+ return &UpGroup{
+ query: q,
+ }
+}
+
+// AsNode returns this UpGroup as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *UpGroup) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A Dagger workspace detected from the current working directory or constructed from a Directory.
+type Workspace struct {
+ query *querybuilder.Selection
+
+ address *string
+ configFile *string
+ configRead *string
+ configWrite *string
+ cwd *string
+ envCreate *string
+ envRemove *string
+ findUp *string
+ id *ID
+ init *string
+ install *string
+ uninstall *string
+}
+type WithWorkspaceFunc func(r *Workspace) *Workspace
+
+// With calls the provided function with current Workspace.
+//
+// This is useful for reusability and readability by not breaking the calling chain.
+func (r *Workspace) With(f WithWorkspaceFunc) *Workspace {
+ return f(r)
+}
+
+func (r *Workspace) WithGraphQLQuery(q *querybuilder.Selection) *Workspace {
+ return &Workspace{
+ query: q,
+ }
+}
+
+// Canonical Dagger address of the workspace location, or an opaque identity for synthetic workspaces.
+func (r *Workspace) Address(ctx context.Context) (string, error) {
+ if r.address != nil {
+ return *r.address, nil
+ }
+ q := r.query.Select("address")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Return the changes from another workspace to this workspace.
+func (r *Workspace) Changes(other *Workspace) *Changeset {
+ assertNotNil("other", other)
+ q := r.query.Select("changes")
+ q = q.Arg("other", other)
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// WorkspaceChecksOpts contains options for Workspace.Checks
+type WorkspaceChecksOpts struct {
+ // Only include checks matching the specified patterns
+ Include []string
+ // Skip checks matching the specified patterns
+ Skip []string
+ // When true, only return annotated check functions; exclude generate-as-checks
+ NoGenerate bool
+ // When true, only return generate-as-checks; exclude annotated check functions
+ OnlyGenerate bool
+}
+
+// Return all checks from modules loaded in the workspace.
+func (r *Workspace) Checks(opts ...WorkspaceChecksOpts) *CheckGroup {
+ q := r.query.Select("checks")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `skip` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Skip) {
+ q = q.Arg("skip", opts[i].Skip)
+ }
+ // `noGenerate` optional argument
+ if !querybuilder.IsZeroValue(opts[i].NoGenerate) {
+ q = q.Arg("noGenerate", opts[i].NoGenerate)
+ }
+ // `onlyGenerate` optional argument
+ if !querybuilder.IsZeroValue(opts[i].OnlyGenerate) {
+ q = q.Arg("onlyGenerate", opts[i].OnlyGenerate)
+ }
+ }
+
+ return &CheckGroup{
+ query: q,
+ }
+}
+
+// Regenerate all generated API clients registered in workspace config and return the resulting Changeset.
+func (r *Workspace) ClientGenerate() *Changeset {
+ q := r.query.Select("clientGenerate")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// WorkspaceClientInitOpts contains options for Workspace.ClientInit
+type WorkspaceClientInitOpts struct {
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+
+ Args JSON
+}
+
+// Plan the workspace changes for initializing a generated API client: generated client files at `path` plus a [[modules..as-sdk.clients]] entry in dagger.toml. Returns the resulting Changeset for the caller to preview and apply.
+func (r *Workspace) ClientInit(path string, sdk string, module string, opts ...WorkspaceClientInitOpts) *Changeset {
+ q := r.query.Select("clientInit")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ // `args` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Args) {
+ q = q.Arg("args", opts[i].Args)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("sdk", sdk)
+ q = q.Arg("module", module)
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Selected native workspace config file relative to the workspace root, if any.
+func (r *Workspace) ConfigFile(ctx context.Context) (string, error) {
+ if r.configFile != nil {
+ return *r.configFile, nil
+ }
+ q := r.query.Select("configFile")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// WorkspaceConfigReadOpts contains options for Workspace.ConfigRead
+type WorkspaceConfigReadOpts struct {
+ // Dotted key path (e.g. modules.greeter.source). Empty for full config.
+ Key string
+}
+
+// Read a configuration value from dagger.toml.
+//
+// If key is empty, returns the full config.
+//
+// If key points to a scalar, returns the value.
+//
+// If key points to a table, returns flattened dotted-key output.
+func (r *Workspace) ConfigRead(ctx context.Context, opts ...WorkspaceConfigReadOpts) (string, error) {
+ if r.configRead != nil {
+ return *r.configRead, nil
+ }
+ q := r.query.Select("configRead")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `key` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Key) {
+ q = q.Arg("key", opts[i].Key)
+ }
+ }
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// WorkspaceConfigWriteOpts contains options for Workspace.ConfigWrite
+type WorkspaceConfigWriteOpts struct {
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+}
+
+// Write a configuration value to dagger.toml.
+func (r *Workspace) ConfigWrite(ctx context.Context, key string, value string, opts ...WorkspaceConfigWriteOpts) (string, error) {
+ if r.configWrite != nil {
+ return *r.configWrite, nil
+ }
+ q := r.query.Select("configWrite")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ }
+ q = q.Arg("key", key)
+ q = q.Arg("value", value)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Current location within the workspace root.
+//
+// The workspace root is returned as "/".
+//
+// Relative paths in workspace APIs resolve from here.
+func (r *Workspace) Cwd(ctx context.Context) (string, error) {
+ if r.cwd != nil {
+ return *r.cwd, nil
+ }
+ q := r.query.Select("cwd")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// WorkspaceDirectoryOpts contains options for Workspace.Directory
+type WorkspaceDirectoryOpts struct {
+ // Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
+ Exclude []string
+ // Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
+ Include []string
+ // Apply .gitignore filter rules inside the directory.
+ Gitignore bool
+}
+
+// Returns a Directory from the workspace.
+//
+// Relative paths resolve from the workspace cwd. Absolute paths resolve from the workspace root.
+func (r *Workspace) Directory(path string, opts ...WorkspaceDirectoryOpts) *Directory {
+ q := r.query.Select("directory")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `exclude` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Exclude) {
+ q = q.Arg("exclude", opts[i].Exclude)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `gitignore` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Gitignore) {
+ q = q.Arg("gitignore", opts[i].Gitignore)
+ }
+ }
+ q = q.Arg("path", path)
+
+ return &Directory{
+ query: q,
+ }
+}
+
+// WorkspaceEnvCreateOpts contains options for Workspace.EnvCreate
+type WorkspaceEnvCreateOpts struct {
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+}
+
+// Create a named workspace environment if it does not already exist.
+func (r *Workspace) EnvCreate(ctx context.Context, name string, opts ...WorkspaceEnvCreateOpts) (string, error) {
+ if r.envCreate != nil {
+ return *r.envCreate, nil
+ }
+ q := r.query.Select("envCreate")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ }
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// List named environments defined in the workspace configuration.
+func (r *Workspace) EnvList(ctx context.Context) ([]string, error) {
+ q := r.query.Select("envList")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// WorkspaceEnvRemoveOpts contains options for Workspace.EnvRemove
+type WorkspaceEnvRemoveOpts struct {
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+}
+
+// Remove a named workspace environment.
+func (r *Workspace) EnvRemove(ctx context.Context, name string, opts ...WorkspaceEnvRemoveOpts) (string, error) {
+ if r.envRemove != nil {
+ return *r.envRemove, nil
+ }
+ q := r.query.Select("envRemove")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ }
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Returns a File from the workspace.
+//
+// Relative paths resolve from the workspace cwd. Absolute paths resolve from the workspace root.
+func (r *Workspace) File(path string) *File {
+ q := r.query.Select("file")
+ q = q.Arg("path", path)
+
+ return &File{
+ query: q,
+ }
+}
+
+// WorkspaceFindUpOpts contains options for Workspace.FindUp
+type WorkspaceFindUpOpts struct {
+ // Path to start the search from. Relative paths resolve from the workspace cwd; absolute paths resolve from the workspace root.
+ //
+ // Default: "."
+ From string
+}
+
+// Search for a file or directory by walking up from the start path within the workspace.
+//
+// Returns the absolute workspace path if found, or null if not found.
+//
+// Relative start paths resolve from the workspace cwd.
+//
+// The search stops at the workspace root and will not traverse above it.
+func (r *Workspace) FindUp(ctx context.Context, name string, opts ...WorkspaceFindUpOpts) (string, error) {
+ if r.findUp != nil {
+ return *r.findUp, nil
+ }
+ q := r.query.Select("findUp")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `from` optional argument
+ if !querybuilder.IsZeroValue(opts[i].From) {
+ q = q.Arg("from", opts[i].From)
+ }
+ }
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// WorkspaceGeneratorsOpts contains options for Workspace.Generators
+type WorkspaceGeneratorsOpts struct {
+ // Only include generators matching the specified patterns
+ Include []string
+}
+
+// Return all generators from modules loaded in the workspace.
+func (r *Workspace) Generators(opts ...WorkspaceGeneratorsOpts) *GeneratorGroup {
+ q := r.query.Select("generators")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ }
+
+ return &GeneratorGroup{
+ query: q,
+ }
+}
+
+// Git state for this workspace. Errors if the workspace is not in a git repository.
+func (r *Workspace) Git() *WorkspaceGit {
+ q := r.query.Select("git")
+
+ return &WorkspaceGit{
+ query: q,
+ }
+}
+
+// A unique identifier for this Workspace.
+func (r *Workspace) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *Workspace) XXX_GraphQLType() string {
+ return "Workspace"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *Workspace) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *Workspace) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *Workspace) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *Workspace) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = Workspace{query: selectNode(dag.query, id, "Workspace")}
+ return nil
+}
+
+// WorkspaceInitOpts contains options for Workspace.Init
+type WorkspaceInitOpts struct {
+ // Create the workspace config directory at the workspace cwd instead of using the default write target.
+ Here bool
+}
+
+// Initialize workspace config, creating dagger.toml.
+func (r *Workspace) Init(ctx context.Context, opts ...WorkspaceInitOpts) (string, error) {
+ if r.init != nil {
+ return *r.init, nil
+ }
+ q := r.query.Select("init")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ }
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// WorkspaceInstallOpts contains options for Workspace.Install
+type WorkspaceInstallOpts struct {
+ // Override name for the installed module entry.
+ Name string
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+ // Mark the install as an SDK (writes the `[modules..as-sdk]` marker that dispatches `dagger module init ` and `dagger api client init `).
+ AsSDK bool
+ // User-facing SDK name to persist under `[modules..as-sdk] name = ...`.
+ AsSDKName string
+}
+
+// Install a module into the workspace, writing dagger.toml to the host.
+func (r *Workspace) Install(ctx context.Context, ref string, opts ...WorkspaceInstallOpts) (string, error) {
+ if r.install != nil {
+ return *r.install, nil
+ }
+ q := r.query.Select("install")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `name` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Name) {
+ q = q.Arg("name", opts[i].Name)
+ }
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ // `asSdk` optional argument
+ if !querybuilder.IsZeroValue(opts[i].AsSDK) {
+ q = q.Arg("asSdk", opts[i].AsSDK)
+ }
+ // `asSdkName` optional argument
+ if !querybuilder.IsZeroValue(opts[i].AsSDKName) {
+ q = q.Arg("asSdkName", opts[i].AsSDKName)
+ }
+ }
+ q = q.Arg("ref", ref)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Plan the explicit migration needed for the current workspace.
+//
+// The returned plan has an empty changeset and no steps when no migration is needed.
+func (r *Workspace) Migrate() *WorkspaceMigration {
+ q := r.query.Select("migrate")
+
+ return &WorkspaceMigration{
+ query: q,
+ }
+}
+
+// WorkspaceModuleInitOpts contains options for Workspace.ModuleInit
+type WorkspaceModuleInitOpts struct {
+ // Workspace SDK name or module entry name to use.
+ SDK string
+ // Workspace-relative path for the new module. Defaults to ".dagger/modules/"; using the default also installs the module in [modules.].
+ Path string
+ // Source subpath within the new module.
+ Source string
+ // Additional include patterns for the module.
+ Include []string
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+
+ Args JSON
+}
+
+// Plan the workspace changes for initializing a new module: dagger-module.toml + SDK codegen output at `path`, the authoring entry under [[modules..as-sdk.modules]], and (when path defaults) [modules.]. The SDK must already be installed as an SDK. Returns the resulting Changeset for the caller to preview and apply.
+func (r *Workspace) ModuleInit(name string, opts ...WorkspaceModuleInitOpts) *Changeset {
+ q := r.query.Select("moduleInit")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `sdk` optional argument
+ if !querybuilder.IsZeroValue(opts[i].SDK) {
+ q = q.Arg("sdk", opts[i].SDK)
+ }
+ // `path` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Path) {
+ q = q.Arg("path", opts[i].Path)
+ }
+ // `source` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Source) {
+ q = q.Arg("source", opts[i].Source)
+ }
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ // `args` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Args) {
+ q = q.Arg("args", opts[i].Args)
+ }
+ }
+ q = q.Arg("name", name)
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// WorkspaceModuleListOpts contains options for Workspace.ModuleList
+type WorkspaceModuleListOpts struct {
+ // Optional module alias to inspect.
+ Module string
+}
+
+// List modules defined in the workspace configuration.
+func (r *Workspace) ModuleList(ctx context.Context, opts ...WorkspaceModuleListOpts) ([]WorkspaceModule, error) {
+ q := r.query.Select("moduleList")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `module` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Module) {
+ q = q.Arg("module", opts[i].Module)
+ }
+ }
+
+ q = q.Select("id")
+
+ type moduleList struct {
+ Id ID
+ }
+
+ convert := func(fields []moduleList) []WorkspaceModule {
+ out := []WorkspaceModule{}
+
+ for i := range fields {
+ val := WorkspaceModule{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "WorkspaceModule")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []moduleList
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// WorkspaceServicesOpts contains options for Workspace.Services
+type WorkspaceServicesOpts struct {
+ // Only include services matching the specified patterns
+ Include []string
+}
+
+// Return all services from modules loaded in the workspace.
+func (r *Workspace) Services(opts ...WorkspaceServicesOpts) *UpGroup {
+ q := r.query.Select("services")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `include` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Include) {
+ q = q.Arg("include", opts[i].Include)
+ }
+ }
+
+ return &UpGroup{
+ query: q,
+ }
+}
+
+// WorkspaceUninstallOpts contains options for Workspace.Uninstall
+type WorkspaceUninstallOpts struct {
+ // Write to the workspace config directory at the workspace cwd.
+ Here bool
+}
+
+// Uninstall a module from the workspace, writing dagger.toml to the host.
+func (r *Workspace) Uninstall(ctx context.Context, name string, opts ...WorkspaceUninstallOpts) (string, error) {
+ if r.uninstall != nil {
+ return *r.uninstall, nil
+ }
+ q := r.query.Select("uninstall")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `here` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Here) {
+ q = q.Arg("here", opts[i].Here)
+ }
+ }
+ q = q.Arg("name", name)
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Refresh workspace-managed state and return the resulting changeset.
+//
+// Currently this refreshes existing lockfile entries only.
+//
+// Experimental: Experimental workspace update API currently refreshes existing lockfile entries only.
+func (r *Workspace) Update() *Changeset {
+ q := r.query.Select("update")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Return this workspace with a changeset applied, without mutating the source.
+func (r *Workspace) WithChanges(changes *Changeset) *Workspace {
+ assertNotNil("changes", changes)
+ q := r.query.Select("withChanges")
+ q = q.Arg("changes", changes)
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// Return this workspace with a directory added, without mutating the source.
+func (r *Workspace) WithNewDirectory(path string, source *Directory) *Workspace {
+ assertNotNil("source", source)
+ q := r.query.Select("withNewDirectory")
+ q = q.Arg("path", path)
+ q = q.Arg("source", source)
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// WorkspaceWithNewFileOpts contains options for Workspace.WithNewFile
+type WorkspaceWithNewFileOpts struct {
+ // Permissions of the new file.
+ //
+ // Default: 420
+ Permissions int
+}
+
+// Return this workspace with a new or replaced file, without mutating the source.
+func (r *Workspace) WithNewFile(path string, contents string, opts ...WorkspaceWithNewFileOpts) *Workspace {
+ q := r.query.Select("withNewFile")
+ for i := len(opts) - 1; i >= 0; i-- {
+ // `permissions` optional argument
+ if !querybuilder.IsZeroValue(opts[i].Permissions) {
+ q = q.Arg("permissions", opts[i].Permissions)
+ }
+ }
+ q = q.Arg("path", path)
+ q = q.Arg("contents", contents)
+
+ return &Workspace{
+ query: q,
+ }
+}
+
+// AsNode returns this Workspace as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *Workspace) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// Local git state for a workspace.
+type WorkspaceGit struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *WorkspaceGit) WithGraphQLQuery(q *querybuilder.Selection) *WorkspaceGit {
+ return &WorkspaceGit{
+ query: q,
+ }
+}
+
+// The checked-out HEAD of this workspace.
+func (r *WorkspaceGit) Head() *GitRef {
+ q := r.query.Select("head")
+
+ return &GitRef{
+ query: q,
+ }
+}
+
+// A unique identifier for this WorkspaceGit.
+func (r *WorkspaceGit) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *WorkspaceGit) XXX_GraphQLType() string {
+ return "WorkspaceGit"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *WorkspaceGit) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *WorkspaceGit) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *WorkspaceGit) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *WorkspaceGit) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = WorkspaceGit{query: selectNode(dag.query, id, "WorkspaceGit")}
+ return nil
+}
+
+// Uncommitted changes in this workspace, using the same rules as GitRepository.uncommitted.
+func (r *WorkspaceGit) Uncommitted() *Changeset {
+ q := r.query.Select("uncommitted")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// AsNode returns this WorkspaceGit as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *WorkspaceGit) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A planned workspace migration.
+type WorkspaceMigration struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *WorkspaceMigration) WithGraphQLQuery(q *querybuilder.Selection) *WorkspaceMigration {
+ return &WorkspaceMigration{
+ query: q,
+ }
+}
+
+// Filesystem changes for the full migration plan.
+func (r *WorkspaceMigration) Changes() *Changeset {
+ q := r.query.Select("changes")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// A unique identifier for this WorkspaceMigration.
+func (r *WorkspaceMigration) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *WorkspaceMigration) XXX_GraphQLType() string {
+ return "WorkspaceMigration"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *WorkspaceMigration) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *WorkspaceMigration) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *WorkspaceMigration) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *WorkspaceMigration) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = WorkspaceMigration{query: selectNode(dag.query, id, "WorkspaceMigration")}
+ return nil
+}
+
+// Logical migration steps, each identified by a stable code.
+func (r *WorkspaceMigration) Steps(ctx context.Context) ([]WorkspaceMigrationStep, error) {
+ q := r.query.Select("steps")
+
+ q = q.Select("id")
+
+ type steps struct {
+ Id ID
+ }
+
+ convert := func(fields []steps) []WorkspaceMigrationStep {
+ out := []WorkspaceMigrationStep{}
+
+ for i := range fields {
+ val := WorkspaceMigrationStep{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "WorkspaceMigrationStep")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []steps
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// AsNode returns this WorkspaceMigration as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *WorkspaceMigration) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A single logical part of a workspace migration.
+type WorkspaceMigrationStep struct {
+ query *querybuilder.Selection
+
+ code *string
+ description *string
+ id *ID
+}
+
+func (r *WorkspaceMigrationStep) WithGraphQLQuery(q *querybuilder.Selection) *WorkspaceMigrationStep {
+ return &WorkspaceMigrationStep{
+ query: q,
+ }
+}
+
+// Filesystem changes for this step.
+func (r *WorkspaceMigrationStep) Changes() *Changeset {
+ q := r.query.Select("changes")
+
+ return &Changeset{
+ query: q,
+ }
+}
+
+// Stable code identifying this logical migration step.
+func (r *WorkspaceMigrationStep) Code(ctx context.Context) (string, error) {
+ if r.code != nil {
+ return *r.code, nil
+ }
+ q := r.query.Select("code")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// Generic summary of this step's purpose and impact.
+func (r *WorkspaceMigrationStep) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this WorkspaceMigrationStep.
+func (r *WorkspaceMigrationStep) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *WorkspaceMigrationStep) XXX_GraphQLType() string {
+ return "WorkspaceMigrationStep"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *WorkspaceMigrationStep) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *WorkspaceMigrationStep) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *WorkspaceMigrationStep) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *WorkspaceMigrationStep) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = WorkspaceMigrationStep{query: selectNode(dag.query, id, "WorkspaceMigrationStep")}
+ return nil
+}
+
+// Non-fatal warnings raised while planning this step.
+func (r *WorkspaceMigrationStep) Warnings(ctx context.Context) ([]string, error) {
+ q := r.query.Select("warnings")
+
+ var response []string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this WorkspaceMigrationStep as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *WorkspaceMigrationStep) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A module entry in the workspace configuration.
+type WorkspaceModule struct {
+ query *querybuilder.Selection
+
+ entrypoint *bool
+ id *ID
+ name *string
+ source *string
+}
+
+func (r *WorkspaceModule) WithGraphQLQuery(q *querybuilder.Selection) *WorkspaceModule {
+ return &WorkspaceModule{
+ query: q,
+ }
+}
+
+// Whether the module is the workspace entrypoint (functions aliased to Query root).
+func (r *WorkspaceModule) Entrypoint(ctx context.Context) (bool, error) {
+ if r.entrypoint != nil {
+ return *r.entrypoint, nil
+ }
+ q := r.query.Select("entrypoint")
+
+ var response bool
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this WorkspaceModule.
+func (r *WorkspaceModule) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *WorkspaceModule) XXX_GraphQLType() string {
+ return "WorkspaceModule"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *WorkspaceModule) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *WorkspaceModule) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *WorkspaceModule) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *WorkspaceModule) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = WorkspaceModule{query: selectNode(dag.query, id, "WorkspaceModule")}
+ return nil
+}
+
+// The module name.
+func (r *WorkspaceModule) Name(ctx context.Context) (string, error) {
+ if r.name != nil {
+ return *r.name, nil
+ }
+ q := r.query.Select("name")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// List constructor-backed settings for this module.
+func (r *WorkspaceModule) Settings(ctx context.Context) ([]WorkspaceModuleSetting, error) {
+ q := r.query.Select("settings")
+
+ q = q.Select("id")
+
+ type settings struct {
+ Id ID
+ }
+
+ convert := func(fields []settings) []WorkspaceModuleSetting {
+ out := []WorkspaceModuleSetting{}
+
+ for i := range fields {
+ val := WorkspaceModuleSetting{id: &fields[i].Id}
+ val.query = selectNode(q.Root(), fields[i].Id, "WorkspaceModuleSetting")
+ out = append(out, val)
+ }
+
+ return out
+ }
+ var response []settings
+
+ q = q.Bind(&response)
+
+ err := q.Execute(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ return convert(response), nil
+}
+
+// The module source path.
+func (r *WorkspaceModule) Source(ctx context.Context) (string, error) {
+ if r.source != nil {
+ return *r.source, nil
+ }
+ q := r.query.Select("source")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this WorkspaceModule as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *WorkspaceModule) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// A constructor-backed module setting.
+type WorkspaceModuleSetting struct {
+ query *querybuilder.Selection
+
+ description *string
+ id *ID
+ key *string
+ value *string
+}
+
+func (r *WorkspaceModuleSetting) WithGraphQLQuery(q *querybuilder.Selection) *WorkspaceModuleSetting {
+ return &WorkspaceModuleSetting{
+ query: q,
+ }
+}
+
+// The constructor argument description.
+func (r *WorkspaceModuleSetting) Description(ctx context.Context) (string, error) {
+ if r.description != nil {
+ return *r.description, nil
+ }
+ q := r.query.Select("description")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// A unique identifier for this WorkspaceModuleSetting.
+func (r *WorkspaceModuleSetting) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *WorkspaceModuleSetting) XXX_GraphQLType() string {
+ return "WorkspaceModuleSetting"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *WorkspaceModuleSetting) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *WorkspaceModuleSetting) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *WorkspaceModuleSetting) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *WorkspaceModuleSetting) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = WorkspaceModuleSetting{query: selectNode(dag.query, id, "WorkspaceModuleSetting")}
+ return nil
+}
+
+// The setting key.
+func (r *WorkspaceModuleSetting) Key(ctx context.Context) (string, error) {
+ if r.key != nil {
+ return *r.key, nil
+ }
+ q := r.query.Select("key")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// The configured value after applying the selected workspace environment, or empty when unset.
+func (r *WorkspaceModuleSetting) Value(ctx context.Context) (string, error) {
+ if r.value != nil {
+ return *r.value, nil
+ }
+ q := r.query.Select("value")
+
+ var response string
+
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// AsNode returns this WorkspaceModuleSetting as a Node.
+// This is a local type conversion — no GraphQL call.
+func (r *WorkspaceModuleSetting) AsNode() Node {
+ return &NodeClient{
+ query: r.query,
+ }
+}
+
+// An object that can be exported to the host.
+//
+// Calling export writes the object to a path on the host filesystem and returns the path that was written.
+type Exportable interface {
+ DaggerObject
+
+ Export(ctx context.Context, path string) (string, error)
+
+ ID(ctx context.Context) (ID, error)
+
+ // Concrete loads and returns the underlying concrete type of this
+ // interface, which can then be used with a type switch.
+ Concrete(ctx context.Context) (Node, error)
+}
+
+// ExportableClient is the query-builder for the Exportable interface.
+type ExportableClient struct {
+ query *querybuilder.Selection
+
+ export *string
+ id *ID
+}
+
+func (r *ExportableClient) WithGraphQLQuery(q *querybuilder.Selection) *ExportableClient {
+ return &ExportableClient{
+ query: q,
+ }
+}
+
+func (r *ExportableClient) Export(ctx context.Context, path string) (string, error) {
+ if r.export != nil {
+ return *r.export, nil
+ }
+ q := r.query.Select("export")
+ q = q.Arg("path", path)
+
+ var response string
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+func (r *ExportableClient) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *ExportableClient) XXX_GraphQLType() string {
+ return "Exportable"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *ExportableClient) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *ExportableClient) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *ExportableClient) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *ExportableClient) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = ExportableClient{query: selectNode(dag.query, id, "Exportable")}
+ return nil
+}
+
+// Concrete loads and returns the underlying concrete type of this
+// interface, which can then be used with a type switch.
+func (r *ExportableClient) Concrete(ctx context.Context) (Node, error) {
+ // Query __typename to determine the concrete type.
+ var typeName string
+ q := r.query.Select("__typename")
+ q = q.Bind(&typeName)
+ if err := q.Execute(ctx); err != nil {
+ return nil, err
+ }
+ // Get the ID to load the concrete object.
+ id, err := r.ID(ctx)
+ if err != nil {
+ return nil, err
+ }
+ switch typeName {
+ case "Changeset":
+ return &Changeset{query: selectNode(r.query.Root(), id, "Changeset")}, nil
+ case "Container":
+ return &Container{query: selectNode(r.query.Root(), id, "Container")}, nil
+ case "Directory":
+ return &Directory{query: selectNode(r.query.Root(), id, "Directory")}, nil
+ case "File":
+ return &File{query: selectNode(r.query.Root(), id, "File")}, nil
+ default:
+ return nil, fmt.Errorf("unknown Exportable implementation: %s", typeName)
+ }
+}
+
+// An object with a globally unique ID.
+type Node interface {
+ DaggerObject
+
+ ID(ctx context.Context) (ID, error)
+}
+
+// NodeClient is the query-builder for the Node interface.
+type NodeClient struct {
+ query *querybuilder.Selection
+
+ id *ID
+}
+
+func (r *NodeClient) WithGraphQLQuery(q *querybuilder.Selection) *NodeClient {
+ return &NodeClient{
+ query: q,
+ }
+}
+
+func (r *NodeClient) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *NodeClient) XXX_GraphQLType() string {
+ return "Node"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *NodeClient) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *NodeClient) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *NodeClient) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *NodeClient) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = NodeClient{query: selectNode(dag.query, id, "Node")}
+ return nil
+}
+
+// An object that can be force-evaluated.
+//
+// Calling sync ensures that the object's entire dependency DAG has been evaluated, returning the object's ID once complete.
+type Syncer interface {
+ DaggerObject
+
+ ID(ctx context.Context) (ID, error)
+
+ Sync(ctx context.Context) (Syncer, error)
+
+ // Concrete loads and returns the underlying concrete type of this
+ // interface, which can then be used with a type switch.
+ Concrete(ctx context.Context) (Node, error)
+}
+
+// SyncerClient is the query-builder for the Syncer interface.
+type SyncerClient struct {
+ query *querybuilder.Selection
+
+ id *ID
+ sync *ID
+}
+
+func (r *SyncerClient) WithGraphQLQuery(q *querybuilder.Selection) *SyncerClient {
+ return &SyncerClient{
+ query: q,
+ }
+}
+
+func (r *SyncerClient) ID(ctx context.Context) (ID, error) {
+ if r.id != nil {
+ return *r.id, nil
+ }
+ q := r.query.Select("id")
+
+ var response ID
+ q = q.Bind(&response)
+ return response, q.Execute(ctx)
+}
+
+// XXX_GraphQLType is an internal function. It returns the native GraphQL type name
+func (r *SyncerClient) XXX_GraphQLType() string {
+ return "Syncer"
+}
+
+// XXX_GraphQLIDType is an internal function. It returns the native GraphQL type name for the ID of this object
+func (r *SyncerClient) XXX_GraphQLIDType() string {
+ return "ID"
+}
+
+// XXX_GraphQLID is an internal function. It returns the underlying type ID
+func (r *SyncerClient) XXX_GraphQLID(ctx context.Context) (string, error) {
+ id, err := r.ID(ctx)
+ if err != nil {
+ return "", err
+ }
+ return string(id), nil
+}
+
+func (r *SyncerClient) MarshalJSON() ([]byte, error) {
+ id, err := r.ID(marshalCtx)
+ if err != nil {
+ return nil, err
+ }
+ return json.Marshal(id)
+}
+func (r *SyncerClient) UnmarshalJSON(bs []byte) error {
+ var id string
+ err := json.Unmarshal(bs, &id)
+ if err != nil {
+ return err
+ }
+ *r = SyncerClient{query: selectNode(dag.query, id, "Syncer")}
+ return nil
+}
+
+func (r *SyncerClient) Sync(ctx context.Context) (Syncer, error) {
+ q := r.query.Select("sync")
+
+ var id ID
+ if err := q.Bind(&id).Execute(ctx); err != nil {
+ return nil, err
+ }
+ return &SyncerClient{
+ query: selectNode(q.Root(), id, "Syncer"),
+ }, nil
+}
+
+// Concrete loads and returns the underlying concrete type of this
+// interface, which can then be used with a type switch.
+func (r *SyncerClient) Concrete(ctx context.Context) (Node, error) {
+ // Query __typename to determine the concrete type.
+ var typeName string
+ q := r.query.Select("__typename")
+ q = q.Bind(&typeName)
+ if err := q.Execute(ctx); err != nil {
+ return nil, err
+ }
+ // Get the ID to load the concrete object.
+ id, err := r.ID(ctx)
+ if err != nil {
+ return nil, err
+ }
+ switch typeName {
+ case "Changeset":
+ return &Changeset{query: selectNode(r.query.Root(), id, "Changeset")}, nil
+ case "Container":
+ return &Container{query: selectNode(r.query.Root(), id, "Container")}, nil
+ case "Directory":
+ return &Directory{query: selectNode(r.query.Root(), id, "Directory")}, nil
+ case "File":
+ return &File{query: selectNode(r.query.Root(), id, "File")}, nil
+ case "LLM":
+ return &LLM{query: selectNode(r.query.Root(), id, "LLM")}, nil
+ case "Module":
+ return &Module{query: selectNode(r.query.Root(), id, "Module")}, nil
+ case "ModuleSource":
+ return &ModuleSource{query: selectNode(r.query.Root(), id, "ModuleSource")}, nil
+ case "Service":
+ return &Service{query: selectNode(r.query.Root(), id, "Service")}, nil
+ case "Terminal":
+ return &Terminal{query: selectNode(r.query.Root(), id, "Terminal")}, nil
+ default:
+ return nil, fmt.Errorf("unknown Syncer implementation: %s", typeName)
+ }
+}
+
+// Sharing mode of the cache volume.
+type CacheSharingMode string
+
+func (CacheSharingMode) IsEnum() {}
+
+func (v CacheSharingMode) Name() string {
+ switch v {
+ case CacheSharingModeShared:
+ return "SHARED"
+ case CacheSharingModePrivate:
+ return "PRIVATE"
+ case CacheSharingModeLocked:
+ return "LOCKED"
+ default:
+ return ""
+ }
+}
+
+func (v CacheSharingMode) Value() string {
+ return string(v)
+}
+
+func (v *CacheSharingMode) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *CacheSharingMode) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "LOCKED":
+ *v = CacheSharingModeLocked
+ case "PRIVATE":
+ *v = CacheSharingModePrivate
+ case "SHARED":
+ *v = CacheSharingModeShared
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // Shares the cache volume amongst many build pipelines
+ CacheSharingModeShared CacheSharingMode = "SHARED"
+
+ // Keeps a cache volume for a single build pipeline
+ CacheSharingModePrivate CacheSharingMode = "PRIVATE"
+
+ // Shares the cache volume amongst many build pipelines, but will serialize the writes
+ CacheSharingModeLocked CacheSharingMode = "LOCKED"
+)
+
+// Strategy to use when merging changesets with conflicting changes.
+type ChangesetMergeConflict string
+
+func (ChangesetMergeConflict) IsEnum() {}
+
+func (v ChangesetMergeConflict) Name() string {
+ switch v {
+ case ChangesetMergeConflictFailEarly:
+ return "FAIL_EARLY"
+ case ChangesetMergeConflictFail:
+ return "FAIL"
+ case ChangesetMergeConflictLeaveConflictMarkers:
+ return "LEAVE_CONFLICT_MARKERS"
+ case ChangesetMergeConflictPreferOurs:
+ return "PREFER_OURS"
+ case ChangesetMergeConflictPreferTheirs:
+ return "PREFER_THEIRS"
+ default:
+ return ""
+ }
+}
+
+func (v ChangesetMergeConflict) Value() string {
+ return string(v)
+}
+
+func (v *ChangesetMergeConflict) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ChangesetMergeConflict) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "FAIL":
+ *v = ChangesetMergeConflictFail
+ case "FAIL_EARLY":
+ *v = ChangesetMergeConflictFailEarly
+ case "LEAVE_CONFLICT_MARKERS":
+ *v = ChangesetMergeConflictLeaveConflictMarkers
+ case "PREFER_OURS":
+ *v = ChangesetMergeConflictPreferOurs
+ case "PREFER_THEIRS":
+ *v = ChangesetMergeConflictPreferTheirs
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // Fail before attempting merge if file-level conflicts are detected
+ ChangesetMergeConflictFailEarly ChangesetMergeConflict = "FAIL_EARLY"
+
+ // Attempt the merge and fail if git merge fails due to conflicts
+ ChangesetMergeConflictFail ChangesetMergeConflict = "FAIL"
+
+ // Let git create conflict markers in files. For modify/delete conflicts, keeps the modified version. Fails on binary conflicts.
+ ChangesetMergeConflictLeaveConflictMarkers ChangesetMergeConflict = "LEAVE_CONFLICT_MARKERS"
+
+ // The conflict is resolved by applying the version of the calling changeset
+ ChangesetMergeConflictPreferOurs ChangesetMergeConflict = "PREFER_OURS"
+
+ // The conflict is resolved by applying the version of the other changeset
+ ChangesetMergeConflictPreferTheirs ChangesetMergeConflict = "PREFER_THEIRS"
+)
+
+// Strategy to use when merging multiple changesets with git octopus merge.
+type ChangesetsMergeConflict string
+
+func (ChangesetsMergeConflict) IsEnum() {}
+
+func (v ChangesetsMergeConflict) Name() string {
+ switch v {
+ case ChangesetsMergeConflictFailEarly:
+ return "FAIL_EARLY"
+ case ChangesetsMergeConflictFail:
+ return "FAIL"
+ default:
+ return ""
+ }
+}
+
+func (v ChangesetsMergeConflict) Value() string {
+ return string(v)
+}
+
+func (v *ChangesetsMergeConflict) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ChangesetsMergeConflict) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "FAIL":
+ *v = ChangesetsMergeConflictFail
+ case "FAIL_EARLY":
+ *v = ChangesetsMergeConflictFailEarly
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // Fail before attempting merge if file-level conflicts are detected between any changesets
+ ChangesetsMergeConflictFailEarly ChangesetsMergeConflict = "FAIL_EARLY"
+
+ // Attempt the octopus merge and fail if git merge fails due to conflicts
+ ChangesetsMergeConflictFail ChangesetsMergeConflict = "FAIL"
+)
+
+// The type of change for a diff stat entry.
+type DiffStatKind string
+
+func (DiffStatKind) IsEnum() {}
+
+func (v DiffStatKind) Name() string {
+ switch v {
+ case DiffStatKindAdded:
+ return "ADDED"
+ case DiffStatKindModified:
+ return "MODIFIED"
+ case DiffStatKindRemoved:
+ return "REMOVED"
+ case DiffStatKindRenamed:
+ return "RENAMED"
+ default:
+ return ""
+ }
+}
+
+func (v DiffStatKind) Value() string {
+ return string(v)
+}
+
+func (v *DiffStatKind) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *DiffStatKind) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "ADDED":
+ *v = DiffStatKindAdded
+ case "MODIFIED":
+ *v = DiffStatKindModified
+ case "REMOVED":
+ *v = DiffStatKindRemoved
+ case "RENAMED":
+ *v = DiffStatKindRenamed
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // A file or directory was added.
+ DiffStatKindAdded DiffStatKind = "ADDED"
+
+ // A file was modified.
+ DiffStatKindModified DiffStatKind = "MODIFIED"
+
+ // A file or directory was removed.
+ DiffStatKindRemoved DiffStatKind = "REMOVED"
+
+ // A file was renamed.
+ DiffStatKindRenamed DiffStatKind = "RENAMED"
+)
+
+// File type.
+type ExistsType string
+
+func (ExistsType) IsEnum() {}
+
+func (v ExistsType) Name() string {
+ switch v {
+ case ExistsTypeRegularType:
+ return "REGULAR_TYPE"
+ case ExistsTypeDirectoryType:
+ return "DIRECTORY_TYPE"
+ case ExistsTypeSymlinkType:
+ return "SYMLINK_TYPE"
+ default:
+ return ""
+ }
+}
+
+func (v ExistsType) Value() string {
+ return string(v)
+}
+
+func (v *ExistsType) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ExistsType) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "DIRECTORY_TYPE":
+ *v = ExistsTypeDirectoryType
+ case "REGULAR_TYPE":
+ *v = ExistsTypeRegularType
+ case "SYMLINK_TYPE":
+ *v = ExistsTypeSymlinkType
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // Tests path is a regular file
+ ExistsTypeRegularType ExistsType = "REGULAR_TYPE"
+
+ // Tests path is a directory
+ ExistsTypeDirectoryType ExistsType = "DIRECTORY_TYPE"
+
+ // Tests path is a symlink
+ ExistsTypeSymlinkType ExistsType = "SYMLINK_TYPE"
+)
+
+// File type.
+type FileType string
+
+func (FileType) IsEnum() {}
+
+func (v FileType) Name() string {
+ switch v {
+ case FileTypeUnknown:
+ return "UNKNOWN"
+ case FileTypeRegular:
+ return "REGULAR"
+ case FileTypeDirectory:
+ return "DIRECTORY"
+ case FileTypeSymlink:
+ return "SYMLINK"
+ default:
+ return ""
+ }
+}
+
+func (v FileType) Value() string {
+ return string(v)
+}
+
+func (v *FileType) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *FileType) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "DIRECTORY":
+ *v = FileTypeDirectory
+ case "DIRECTORY_TYPE":
+ *v = FileTypeDirectoryType
+ case "REGULAR":
+ *v = FileTypeRegular
+ case "REGULAR_TYPE":
+ *v = FileTypeRegularType
+ case "SYMLINK":
+ *v = FileTypeSymlink
+ case "SYMLINK_TYPE":
+ *v = FileTypeSymlinkType
+ case "UNKNOWN":
+ *v = FileTypeUnknown
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // unknown file type
+ FileTypeUnknown FileType = "UNKNOWN"
+
+ // regular file type
+ FileTypeRegular FileType = "REGULAR"
+ // regular file type
+ FileTypeRegularType FileType = FileTypeRegular
+
+ // directory file type
+ FileTypeDirectory FileType = "DIRECTORY"
+ // directory file type
+ FileTypeDirectoryType FileType = FileTypeDirectory
+
+ // symlink file type
+ FileTypeSymlink FileType = "SYMLINK"
+ // symlink file type
+ FileTypeSymlinkType FileType = FileTypeSymlink
+)
+
+// The behavior configured for function result caching.
+type FunctionCachePolicy string
+
+func (FunctionCachePolicy) IsEnum() {}
+
+func (v FunctionCachePolicy) Name() string {
+ switch v {
+ case FunctionCachePolicyDefault:
+ return "Default"
+ case FunctionCachePolicyPerSession:
+ return "PerSession"
+ case FunctionCachePolicyNever:
+ return "Never"
+ default:
+ return ""
+ }
+}
+
+func (v FunctionCachePolicy) Value() string {
+ return string(v)
+}
+
+func (v *FunctionCachePolicy) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *FunctionCachePolicy) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "Default":
+ *v = FunctionCachePolicyDefault
+ case "Never":
+ *v = FunctionCachePolicyNever
+ case "PerSession":
+ *v = FunctionCachePolicyPerSession
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ FunctionCachePolicyDefault FunctionCachePolicy = "Default"
+
+ FunctionCachePolicyPerSession FunctionCachePolicy = "PerSession"
+
+ FunctionCachePolicyNever FunctionCachePolicy = "Never"
+)
+
+// Compression algorithm to use for image layers.
+type ImageLayerCompression string
+
+func (ImageLayerCompression) IsEnum() {}
+
+func (v ImageLayerCompression) Name() string {
+ switch v {
+ case ImageLayerCompressionGzip:
+ return "Gzip"
+ case ImageLayerCompressionZstd:
+ return "Zstd"
+ case ImageLayerCompressionEstarGz:
+ return "EStarGZ"
+ case ImageLayerCompressionUncompressed:
+ return "Uncompressed"
+ default:
+ return ""
+ }
+}
+
+func (v ImageLayerCompression) Value() string {
+ return string(v)
+}
+
+func (v *ImageLayerCompression) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ImageLayerCompression) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "EStarGZ":
+ *v = ImageLayerCompressionEstarGz
+ case "ESTARGZ":
+ *v = ImageLayerCompressionEstargz
+ case "Gzip":
+ *v = ImageLayerCompressionGzip
+ case "Uncompressed":
+ *v = ImageLayerCompressionUncompressed
+ case "Zstd":
+ *v = ImageLayerCompressionZstd
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ ImageLayerCompressionGzip ImageLayerCompression = "Gzip"
+
+ ImageLayerCompressionZstd ImageLayerCompression = "Zstd"
+
+ ImageLayerCompressionEstarGz ImageLayerCompression = "EStarGZ"
+ ImageLayerCompressionEstargz ImageLayerCompression = ImageLayerCompressionEstarGz
+
+ ImageLayerCompressionUncompressed ImageLayerCompression = "Uncompressed"
+)
+
+// Mediatypes to use in published or exported image metadata.
+type ImageMediaTypes string
+
+func (ImageMediaTypes) IsEnum() {}
+
+func (v ImageMediaTypes) Name() string {
+ switch v {
+ case ImageMediaTypesOcimediaTypes:
+ return "OCIMediaTypes"
+ case ImageMediaTypesDockerMediaTypes:
+ return "DockerMediaTypes"
+ default:
+ return ""
+ }
+}
+
+func (v ImageMediaTypes) Value() string {
+ return string(v)
+}
+
+func (v *ImageMediaTypes) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ImageMediaTypes) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "DOCKER":
+ *v = ImageMediaTypesDocker
+ case "DockerMediaTypes":
+ *v = ImageMediaTypesDockerMediaTypes
+ case "OCI":
+ *v = ImageMediaTypesOci
+ case "OCIMediaTypes":
+ *v = ImageMediaTypesOcimediaTypes
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ ImageMediaTypesOcimediaTypes ImageMediaTypes = "OCIMediaTypes"
+ ImageMediaTypesOci ImageMediaTypes = ImageMediaTypesOcimediaTypes
+
+ ImageMediaTypesDockerMediaTypes ImageMediaTypes = "DockerMediaTypes"
+ ImageMediaTypesDocker ImageMediaTypes = ImageMediaTypesDockerMediaTypes
+)
+
+// Experimental features of a module
+type ModuleSourceExperimentalFeature string
+
+func (ModuleSourceExperimentalFeature) IsEnum() {}
+
+func (v ModuleSourceExperimentalFeature) Name() string {
+ switch v {
+ case ModuleSourceExperimentalFeatureSelfCalls:
+ return "SELF_CALLS"
+ default:
+ return ""
+ }
+}
+
+func (v ModuleSourceExperimentalFeature) Value() string {
+ return string(v)
+}
+
+func (v *ModuleSourceExperimentalFeature) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ModuleSourceExperimentalFeature) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "SELF_CALLS":
+ *v = ModuleSourceExperimentalFeatureSelfCalls
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // Self calls
+ ModuleSourceExperimentalFeatureSelfCalls ModuleSourceExperimentalFeature = "SELF_CALLS"
+)
+
+// The kind of module source.
+type ModuleSourceKind string
+
+func (ModuleSourceKind) IsEnum() {}
+
+func (v ModuleSourceKind) Name() string {
+ switch v {
+ case ModuleSourceKindLocalSource:
+ return "LOCAL_SOURCE"
+ case ModuleSourceKindGitSource:
+ return "GIT_SOURCE"
+ case ModuleSourceKindDirSource:
+ return "DIR_SOURCE"
+ default:
+ return ""
+ }
+}
+
+func (v ModuleSourceKind) Value() string {
+ return string(v)
+}
+
+func (v *ModuleSourceKind) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ModuleSourceKind) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "DIR":
+ *v = ModuleSourceKindDir
+ case "DIR_SOURCE":
+ *v = ModuleSourceKindDirSource
+ case "GIT":
+ *v = ModuleSourceKindGit
+ case "GIT_SOURCE":
+ *v = ModuleSourceKindGitSource
+ case "LOCAL":
+ *v = ModuleSourceKindLocal
+ case "LOCAL_SOURCE":
+ *v = ModuleSourceKindLocalSource
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ ModuleSourceKindLocalSource ModuleSourceKind = "LOCAL_SOURCE"
+ ModuleSourceKindLocal ModuleSourceKind = ModuleSourceKindLocalSource
+
+ ModuleSourceKindGitSource ModuleSourceKind = "GIT_SOURCE"
+ ModuleSourceKindGit ModuleSourceKind = ModuleSourceKindGitSource
+
+ ModuleSourceKindDirSource ModuleSourceKind = "DIR_SOURCE"
+ ModuleSourceKindDir ModuleSourceKind = ModuleSourceKindDirSource
+)
+
+// Transport layer network protocol associated to a port.
+type NetworkProtocol string
+
+func (NetworkProtocol) IsEnum() {}
+
+func (v NetworkProtocol) Name() string {
+ switch v {
+ case NetworkProtocolTcp:
+ return "TCP"
+ case NetworkProtocolUdp:
+ return "UDP"
+ default:
+ return ""
+ }
+}
+
+func (v NetworkProtocol) Value() string {
+ return string(v)
+}
+
+func (v *NetworkProtocol) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *NetworkProtocol) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "TCP":
+ *v = NetworkProtocolTcp
+ case "UDP":
+ *v = NetworkProtocolUdp
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ NetworkProtocolTcp NetworkProtocol = "TCP"
+
+ NetworkProtocolUdp NetworkProtocol = "UDP"
+)
+
+// Transport protocol to use for registry operations.
+type RegistryProtocol string
+
+func (RegistryProtocol) IsEnum() {}
+
+func (v RegistryProtocol) Name() string {
+ switch v {
+ case RegistryProtocolHttps:
+ return "HTTPS"
+ case RegistryProtocolHttp:
+ return "HTTP"
+ default:
+ return ""
+ }
+}
+
+func (v RegistryProtocol) Value() string {
+ return string(v)
+}
+
+func (v *RegistryProtocol) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *RegistryProtocol) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "HTTP":
+ *v = RegistryProtocolHttp
+ case "HTTPS":
+ *v = RegistryProtocolHttps
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ RegistryProtocolHttps RegistryProtocol = "HTTPS"
+
+ RegistryProtocolHttp RegistryProtocol = "HTTP"
+)
+
+// Expected return type of an execution
+type ReturnType string
+
+func (ReturnType) IsEnum() {}
+
+func (v ReturnType) Name() string {
+ switch v {
+ case ReturnTypeSuccess:
+ return "SUCCESS"
+ case ReturnTypeFailure:
+ return "FAILURE"
+ case ReturnTypeAny:
+ return "ANY"
+ default:
+ return ""
+ }
+}
+
+func (v ReturnType) Value() string {
+ return string(v)
+}
+
+func (v *ReturnType) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *ReturnType) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "ANY":
+ *v = ReturnTypeAny
+ case "FAILURE":
+ *v = ReturnTypeFailure
+ case "SUCCESS":
+ *v = ReturnTypeSuccess
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // A successful execution (exit code 0)
+ ReturnTypeSuccess ReturnType = "SUCCESS"
+
+ // A failed execution (exit codes 1-127 and 192-255)
+ ReturnTypeFailure ReturnType = "FAILURE"
+
+ // Any execution (exit codes 0-127 and 192-255)
+ ReturnTypeAny ReturnType = "ANY"
+)
+
+// Distinguishes the different kinds of TypeDefs.
+type TypeDefKind string
+
+func (TypeDefKind) IsEnum() {}
+
+func (v TypeDefKind) Name() string {
+ switch v {
+ case TypeDefKindStringKind:
+ return "STRING_KIND"
+ case TypeDefKindIntegerKind:
+ return "INTEGER_KIND"
+ case TypeDefKindFloatKind:
+ return "FLOAT_KIND"
+ case TypeDefKindBooleanKind:
+ return "BOOLEAN_KIND"
+ case TypeDefKindScalarKind:
+ return "SCALAR_KIND"
+ case TypeDefKindListKind:
+ return "LIST_KIND"
+ case TypeDefKindObjectKind:
+ return "OBJECT_KIND"
+ case TypeDefKindInterfaceKind:
+ return "INTERFACE_KIND"
+ case TypeDefKindInputKind:
+ return "INPUT_KIND"
+ case TypeDefKindVoidKind:
+ return "VOID_KIND"
+ case TypeDefKindEnumKind:
+ return "ENUM_KIND"
+ default:
+ return ""
+ }
+}
+
+func (v TypeDefKind) Value() string {
+ return string(v)
+}
+
+func (v *TypeDefKind) MarshalJSON() ([]byte, error) {
+ if *v == "" {
+ return []byte(`""`), nil
+ }
+ name := v.Name()
+ if name == "" {
+ return nil, fmt.Errorf("invalid enum value %q", *v)
+ }
+ return json.Marshal(name)
+}
+
+func (v *TypeDefKind) UnmarshalJSON(dt []byte) error {
+ var s string
+ if err := json.Unmarshal(dt, &s); err != nil {
+ return err
+ }
+ switch s {
+ case "":
+ *v = ""
+ case "BOOLEAN":
+ *v = TypeDefKindBoolean
+ case "BOOLEAN_KIND":
+ *v = TypeDefKindBooleanKind
+ case "ENUM":
+ *v = TypeDefKindEnum
+ case "ENUM_KIND":
+ *v = TypeDefKindEnumKind
+ case "FLOAT":
+ *v = TypeDefKindFloat
+ case "FLOAT_KIND":
+ *v = TypeDefKindFloatKind
+ case "INPUT":
+ *v = TypeDefKindInput
+ case "INPUT_KIND":
+ *v = TypeDefKindInputKind
+ case "INTEGER":
+ *v = TypeDefKindInteger
+ case "INTEGER_KIND":
+ *v = TypeDefKindIntegerKind
+ case "INTERFACE":
+ *v = TypeDefKindInterface
+ case "INTERFACE_KIND":
+ *v = TypeDefKindInterfaceKind
+ case "LIST":
+ *v = TypeDefKindList
+ case "LIST_KIND":
+ *v = TypeDefKindListKind
+ case "OBJECT":
+ *v = TypeDefKindObject
+ case "OBJECT_KIND":
+ *v = TypeDefKindObjectKind
+ case "SCALAR":
+ *v = TypeDefKindScalar
+ case "SCALAR_KIND":
+ *v = TypeDefKindScalarKind
+ case "STRING":
+ *v = TypeDefKindString
+ case "STRING_KIND":
+ *v = TypeDefKindStringKind
+ case "VOID":
+ *v = TypeDefKindVoid
+ case "VOID_KIND":
+ *v = TypeDefKindVoidKind
+ default:
+ return fmt.Errorf("invalid enum value %q", s)
+ }
+ return nil
+}
+
+const (
+ // A string value.
+ TypeDefKindStringKind TypeDefKind = "STRING_KIND"
+ // A string value.
+ TypeDefKindString TypeDefKind = TypeDefKindStringKind
+
+ // An integer value.
+ TypeDefKindIntegerKind TypeDefKind = "INTEGER_KIND"
+ // An integer value.
+ TypeDefKindInteger TypeDefKind = TypeDefKindIntegerKind
+
+ // A float value.
+ TypeDefKindFloatKind TypeDefKind = "FLOAT_KIND"
+ // A float value.
+ TypeDefKindFloat TypeDefKind = TypeDefKindFloatKind
+
+ // A boolean value.
+ TypeDefKindBooleanKind TypeDefKind = "BOOLEAN_KIND"
+ // A boolean value.
+ TypeDefKindBoolean TypeDefKind = TypeDefKindBooleanKind
+
+ // A scalar value of any basic kind.
+ TypeDefKindScalarKind TypeDefKind = "SCALAR_KIND"
+ // A scalar value of any basic kind.
+ TypeDefKindScalar TypeDefKind = TypeDefKindScalarKind
+
+ // Always paired with a ListTypeDef.
+ //
+ // A list of values all having the same type.
+ TypeDefKindListKind TypeDefKind = "LIST_KIND"
+ // Always paired with a ListTypeDef.
+ //
+ // A list of values all having the same type.
+ TypeDefKindList TypeDefKind = TypeDefKindListKind
+
+ // Always paired with an ObjectTypeDef.
+ //
+ // A named type defined in the GraphQL schema, with fields and functions.
+ TypeDefKindObjectKind TypeDefKind = "OBJECT_KIND"
+ // Always paired with an ObjectTypeDef.
+ //
+ // A named type defined in the GraphQL schema, with fields and functions.
+ TypeDefKindObject TypeDefKind = TypeDefKindObjectKind
+
+ // Always paired with an InterfaceTypeDef.
+ //
+ // A named type of functions that can be matched+implemented by other objects+interfaces.
+ TypeDefKindInterfaceKind TypeDefKind = "INTERFACE_KIND"
+ // Always paired with an InterfaceTypeDef.
+ //
+ // A named type of functions that can be matched+implemented by other objects+interfaces.
+ TypeDefKindInterface TypeDefKind = TypeDefKindInterfaceKind
+
+ // A graphql input type, used only when representing the core API via TypeDefs.
+ TypeDefKindInputKind TypeDefKind = "INPUT_KIND"
+ // A graphql input type, used only when representing the core API via TypeDefs.
+ TypeDefKindInput TypeDefKind = TypeDefKindInputKind
+
+ // A special kind used to signify that no value is returned.
+ //
+ // This is used for functions that have no return value. The outer TypeDef specifying this Kind is always Optional, as the Void is never actually represented.
+ TypeDefKindVoidKind TypeDefKind = "VOID_KIND"
+ // A special kind used to signify that no value is returned.
+ //
+ // This is used for functions that have no return value. The outer TypeDef specifying this Kind is always Optional, as the Void is never actually represented.
+ TypeDefKindVoid TypeDefKind = TypeDefKindVoidKind
+
+ // A GraphQL enum type and its values
+ //
+ // Always paired with an EnumTypeDef.
+ TypeDefKindEnumKind TypeDefKind = "ENUM_KIND"
+ // A GraphQL enum type and its values
+ //
+ // Always paired with an EnumTypeDef.
+ TypeDefKindEnum TypeDefKind = TypeDefKindEnumKind
+)
+
+type Client struct {
+ *Query
+ client graphql.Client
+}
+
+var dag *Client
+
+func init() {
+ gqlClient, q := getClientParams()
+ dag = &Client{
+ Query: &Query{
+ query: q.Client(gqlClient),
+ },
+ client: gqlClient,
+ }
+}
+
+func Connect() *Client {
+ return dag
+}
+
+// GraphQLClient returns the underlying graphql.Client
+func (c *Client) GraphQLClient() graphql.Client {
+ return c.client
+}
+
+// QueryBuilder returns the underlying query builder.
+func (c *Client) QueryBuilder() *querybuilder.Selection {
+ return c.Query.query
+}
+
+func getClientParams() (graphql.Client, *querybuilder.Selection) {
+ portStr, ok := os.LookupEnv("DAGGER_SESSION_PORT")
+ if !ok {
+ panic("DAGGER_SESSION_PORT is not set")
+ }
+ port, err := strconv.Atoi(portStr)
+ if err != nil {
+ panic(fmt.Errorf("DAGGER_SESSION_PORT %q is invalid: %w", portStr, err))
+ }
+
+ sessionToken := os.Getenv("DAGGER_SESSION_TOKEN")
+ if sessionToken == "" {
+ panic("DAGGER_SESSION_TOKEN is not set")
+ }
+
+ host := fmt.Sprintf("127.0.0.1:%d", port)
+
+ dialTransport := &http.Transport{
+ DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
+ return net.Dial("tcp", host)
+ },
+ }
+ httpClient := &http.Client{
+ Transport: roundTripperFunc(func(r *http.Request) (*http.Response, error) {
+ r.SetBasicAuth(sessionToken, "")
+
+ // detect $TRACEPARENT set by 'dagger run'
+ r = r.WithContext(fallbackSpanContext(r.Context()))
+
+ // propagate span context via headers (i.e. for Dagger-in-Dagger)
+ telemetry.Propagator.Inject(r.Context(), propagation.HeaderCarrier(r.Header))
+
+ return dialTransport.RoundTrip(r)
+ }),
+ }
+ gqlClient := errorWrappedClient{graphql.NewClient(fmt.Sprintf("http://%s/query", host), httpClient)}
+
+ return gqlClient, querybuilder.Query()
+}
+
+func fallbackSpanContext(ctx context.Context) context.Context {
+ if trace.SpanContextFromContext(ctx).IsValid() {
+ return ctx
+ }
+ return telemetry.Propagator.Extract(ctx, telemetry.NewEnvCarrier(true))
+}
+
+// TODO: pollutes namespace, move to non internal package in dagger.io/dagger
+type roundTripperFunc func(*http.Request) (*http.Response, error)
+
+func (fn roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) {
+ return fn(req)
+}
+
+type errorWrappedClient struct {
+ graphql.Client
+}
+
+func (c errorWrappedClient) MakeRequest(ctx context.Context, req *graphql.Request, resp *graphql.Response) error {
+ err := c.Client.MakeRequest(ctx, req, resp)
+ if err != nil {
+ if e := getCustomError(err); e != nil {
+ return e
+ }
+ return err
+ }
+ return nil
+}
+
+// selectNode returns a query selection for node(id:) scoped to the
+// given type via an inline fragment.
+func selectNode(q *querybuilder.Selection, id any, typeName string) *querybuilder.Selection {
+ return q.Select("node").Arg("id", id).InlineFragment(typeName)
+}
+
+// Loadable is the constraint for types that can be loaded from an ID.
+// Every generated object and interface client type satisfies this.
+type Loadable[T any] interface {
+ Node
+ WithGraphQLQuery(*querybuilder.Selection) T
+}
+
+// Ref returns a lazy reference to a node by its ID without making a
+// network call. The returned value can be used to chain further queries.
+func Ref[T Loadable[T]](c *Client, id ID) T {
+ var zero T
+ return zero.WithGraphQLQuery(selectNode(c.query, id, zero.XXX_GraphQLType()))
+}
+
+// Load loads a node by its ID with type safety. It verifies that the
+// node exists and matches the expected type before returning.
+//
+// The type parameter can be a concrete type or an interface. The
+// __typename check is done through the inline fragment so that
+// interface loads succeed when the concrete type (e.g. "Impl")
+// implements the expected interface (e.g. "CustomIface").
+func Load[T Loadable[T]](ctx context.Context, c *Client, id ID) (T, error) {
+ var zero T
+ expectedType := zero.XXX_GraphQLType()
+
+ // Query __typename through the inline fragment. For concrete types
+ // this is equivalent to a direct check. For interfaces, the fragment
+ // only matches if the concrete type implements the interface — an
+ // empty result means the ID doesn't satisfy the expected type.
+ q := selectNode(c.query, id, expectedType)
+ var typeName string
+ if err := q.Select("__typename").Bind(&typeName).Execute(ctx); err != nil {
+ return zero, fmt.Errorf("load %s: %w", expectedType, err)
+ }
+ if typeName == "" {
+ return zero, fmt.Errorf("load %s: node not found or does not implement %s", expectedType, expectedType)
+ }
+
+ return zero.WithGraphQLQuery(selectNode(c.query, id, expectedType)), nil
+}
diff --git a/runtime/main.go b/runtime/main.go
new file mode 100644
index 0000000..57ca826
--- /dev/null
+++ b/runtime/main.go
@@ -0,0 +1,198 @@
+// Runtime module for the Java SDK.
+//
+// This runtime only builds and packages a module's already-vendored, committed
+// sources. Code generation (vendoring the SDK as source and producing the
+// entrypoint) is owned by the Java SDK's `generate` step and runs at `dagger
+// generate` time, not here. New-style modules set codegen.automaticGitignore=false,
+// which commits the generated files and makes the engine skip codegen at module
+// load, so this runtime never regenerates them.
+
+package main
+
+import (
+ "context"
+ "fmt"
+ "path/filepath"
+ "strings"
+
+ _ "embed"
+
+ "java-sdk-runtime/internal/dagger"
+)
+
+const (
+ ModSourceDirPath = "/src"
+ ModDirPath = "/opt/module"
+)
+
+type JavaSdkRuntime struct {
+ // Deprecated: unused by the build/package-only runtime. Retained because the
+ // committed dagger.gen.go dispatch and the engine still construct the runtime
+ // with it; it is regenerated away when the runtime is wired into the engine.
+ SDKSourceDir *dagger.Directory
+ // If true, -e flag will be added to the maven command to display execution error messages
+ MavenErrors bool
+ // If true, -X flag will be added to the maven command to enable full debug logging
+ MavenDebugLogging bool
+
+ moduleConfig moduleConfig
+}
+
+type moduleConfig struct {
+ subPath string
+}
+
+func (c *moduleConfig) modulePath() string {
+ return filepath.Join(ModSourceDirPath, c.subPath)
+}
+
+func New(
+ // Deprecated: unused by the build/package-only runtime; accepted for
+ // compatibility with the committed dagger.gen.go and the engine, which may
+ // still pass the SDK source directory.
+ // +optional
+ sdkSourceDir *dagger.Directory,
+) (*JavaSdkRuntime, error) {
+ return &JavaSdkRuntime{
+ SDKSourceDir: sdkSourceDir,
+ MavenErrors: false,
+ }, nil
+}
+
+func (m *JavaSdkRuntime) WithConfig(
+ // +default=false
+ mavenErrors bool,
+ // +default=false
+ mavenDebugLogging bool,
+) *JavaSdkRuntime {
+ m.MavenErrors = mavenErrors
+ m.MavenDebugLogging = mavenDebugLogging
+ return m
+}
+
+// Codegen is intentionally a no-op for this build/package-only runtime: code
+// generation is owned by the Java SDK's `generate` step (`dagger generate`), and
+// new-style modules (codegen.automaticGitignore=false) commit the generated
+// files, so the engine skips codegen at module load. Returning the module source
+// unchanged keeps the SDK contract satisfied without generating anything. This
+// method is removed/regenerated when the runtime is wired into the engine.
+func (m *JavaSdkRuntime) Codegen(
+ ctx context.Context,
+ modSource *dagger.ModuleSource,
+ introspectionJSON *dagger.File,
+) (*dagger.GeneratedCode, error) {
+ return dag.GeneratedCode(modSource.ContextDirectory()), nil
+}
+
+// ModuleRuntime builds and packages the module from its committed sources and
+// returns a container that runs the resulting jar. The module is self-contained:
+// the Java SDK is vendored as source under sdk/ and the entrypoint is committed
+// under src/generated/java, so a plain `mvn package` (dagger.proc defaults to
+// "none") compiles them together and only fetches third-party dependencies. No
+// codegen, introspection, templating, or version rewriting happens here.
+func (m *JavaSdkRuntime) ModuleRuntime(
+ ctx context.Context,
+ modSource *dagger.ModuleSource,
+ introspectionJSON *dagger.File,
+) (*dagger.Container, error) {
+ if err := m.setModuleConfig(ctx, modSource); err != nil {
+ return nil, err
+ }
+
+ mvnCtr, err := m.mvnContainer(ctx)
+ if err != nil {
+ return nil, err
+ }
+ mvnCtr = mvnCtr.
+ WithMountedCache("/root/.m2", dag.CacheVolume("sdk-java-maven-m2"), dagger.ContainerWithMountedCacheOpts{Sharing: dagger.CacheSharingModeLocked}).
+ WithDirectory(ModSourceDirPath, modSource.ContextDirectory()).
+ WithWorkdir(m.moduleConfig.modulePath()).
+ WithExec(m.mavenCommand("mvn", "clean", "package", "-DskipTests"))
+
+ jar, err := m.finalJar(ctx, mvnCtr)
+ if err != nil {
+ return nil, err
+ }
+
+ javaCtr, err := m.jreContainer(ctx)
+ if err != nil {
+ return nil, err
+ }
+ return javaCtr.
+ WithFile(filepath.Join(ModDirPath, "module.jar"), jar).
+ WithWorkdir(ModDirPath).
+ WithEntrypoint([]string{"java", "-jar", filepath.Join(ModDirPath, "module.jar")}), nil
+}
+
+// finalJar returns the packaged jar built from the user module. Rather than
+// shelling out to maven (a fresh JVM per query) to compute the
+// -.jar name, it reads the already-built target directory
+// and picks the packaged jar, skipping shade's "original-" backup of the
+// pre-shaded artifact.
+func (m *JavaSdkRuntime) finalJar(
+ ctx context.Context,
+ ctr *dagger.Container,
+) (*dagger.File, error) {
+ targetPath := filepath.Join(m.moduleConfig.modulePath(), "target")
+ entries, err := ctr.Directory(targetPath).Entries(ctx)
+ if err != nil {
+ return nil, err
+ }
+ for _, name := range entries {
+ if strings.HasSuffix(name, ".jar") && !strings.HasPrefix(name, "original-") {
+ return ctr.File(filepath.Join(targetPath, name)), nil
+ }
+ }
+ return nil, fmt.Errorf("no packaged jar found in %s", targetPath)
+}
+
+func (m *JavaSdkRuntime) mvnContainer(ctx context.Context) (*dagger.Container, error) {
+ return disableSVEOnArm64(ctx, m.MavenImage())
+}
+
+func (m *JavaSdkRuntime) jreContainer(ctx context.Context) (*dagger.Container, error) {
+ return disableSVEOnArm64(ctx, m.JavaImage())
+}
+
+func disableSVEOnArm64(ctx context.Context, ctr *dagger.Container) (*dagger.Container, error) {
+ if platform, err := ctr.Platform(ctx); err != nil {
+ return nil, err
+ } else if strings.Contains(string(platform), "arm64") {
+ return ctr.WithEnvVariable("_JAVA_OPTIONS", "-XX:UseSVE=0"), nil
+ }
+ return ctr, nil
+}
+
+func (m *JavaSdkRuntime) setModuleConfig(ctx context.Context, modSource *dagger.ModuleSource) error {
+ subPath, err := modSource.SourceSubpath(ctx)
+ if err != nil {
+ return err
+ }
+ m.moduleConfig = moduleConfig{subPath: subPath}
+ return nil
+}
+
+func (m *JavaSdkRuntime) mavenCommand(args ...string) []string {
+ if m.MavenErrors {
+ args = append(args, "-e")
+ }
+ if m.MavenDebugLogging {
+ args = append(args, "-X")
+ }
+ args = append(args, "--threads", "1C", "--no-transfer-progress")
+ return args
+}
+
+//go:embed images/maven/Dockerfile
+var mavenImage string
+
+func (m *JavaSdkRuntime) MavenImage() *dagger.Container {
+ return dag.Directory().WithNewFile("Dockerfile", mavenImage).DockerBuild()
+}
+
+//go:embed images/java/Dockerfile
+var javaImage string
+
+func (m *JavaSdkRuntime) JavaImage() *dagger.Container {
+ return dag.Directory().WithNewFile("Dockerfile", javaImage).DockerBuild()
+}
]