diff --git a/crates/dagger-codegen/src/handlers/fields.rs b/crates/dagger-codegen/src/handlers/fields.rs index 33dc6e6..83f5758 100644 --- a/crates/dagger-codegen/src/handlers/fields.rs +++ b/crates/dagger-codegen/src/handlers/fields.rs @@ -47,8 +47,6 @@ pub fn render_fields( proc: self.proc.clone(), selection: query, } - - todo!() } }); diff --git a/crates/dagger-sdk/src/gen.rs b/crates/dagger-sdk/src/gen.rs index 14caa4b..39290a9 100644 --- a/crates/dagger-sdk/src/gen.rs +++ b/crates/dagger-sdk/src/gen.rs @@ -1,12 +1,9 @@ +use crate::querybuilder::Selection; +use dagger_core::{Boolean, Int, Scalar}; +use dagger_core::connect_params::ConnectParams; use std::process::Child; use std::sync::Arc; -use dagger_core::connect_params::ConnectParams; -use dagger_core::{Boolean, Input, Int, Scalar}; - -use crate::client::graphql_client; -use crate::querybuilder::Selection; - // code generated by dagger. DO NOT EDIT. /// A global cache volume identifier. @@ -31,26 +28,292 @@ pub struct SecretID(Scalar); /// A content-addressed socket identifier. pub struct SocketID(Scalar); -/// +/// pub struct BuildArg { pub name: String, pub value: String, } -impl Input for BuildArg {} /// A directory whose contents persist across runs. -pub struct CacheVolume {} +pub struct CacheVolume { + pub conn: ConnectParams, + pub proc: Arc, + pub selection: Selection, +} impl CacheVolume { - /// - pub fn id(&self) -> CacheID { - todo!() + pub fn id( + &self, + ) -> CacheID { + let query = self.selection.select("id"); + + CacheID { + conn: self.conn.clone(), + proc: self.proc.clone(), + selection: query, + } } } -impl Input for CacheVolume {} +/// Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs. +pub struct BuildArgs { + /// * `context` - Directory context used by the Dockerfile. + pub context: DirectoryID, + /// * `dockerfile` - Path to the Dockerfile to use. + /// Defaults to './Dockerfile'. + pub dockerfile: Option, + /// * `buildArgs` - Additional build arguments. + pub build_args: Option>, + /// * `target` - Target build stage to build. + pub target: Option, +} + + +/// Retrieves a directory at the given path. Mounts are included. +pub struct DirectoryArgs { + pub path: String, +} + + +/// Retrieves the value of the specified environment variable. +pub struct EnvVariableArgs { + pub name: String, +} + + +/// Retrieves this container after executing the specified command inside it. +pub struct ExecArgs { + /// * `args` - Command to run instead of the container's default command. + pub args: Option>, + /// * `stdin` - Content to write to the command's standard input before closing. + pub stdin: Option, + /// * `redirectStdout` - Redirect the command's standard output to a file in the container. + pub redirect_stdout: Option, + /// * `redirectStderr` - Redirect the command's standard error to a file in the container. + pub redirect_stderr: Option, + /// * `experimentalPrivilegedNesting` - Provide dagger access to the executed command. + /// Do not use this option unless you trust the command being executed. + /// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM. + pub experimental_privileged_nesting: Option, +} + + +/// Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants. +/// Return true on success. +pub struct ExportArgs { + /// * `path` - Host's destination path. + /// Path can be relative to the engine's workdir or absolute. + pub path: String, + /// * `platformVariants` - Identifiers for other platform specific containers. + /// Used for multi-platform image. + pub platform_variants: Option>, +} + + +/// Retrieves a file at the given path. Mounts are included. +pub struct FileArgs { + pub path: String, +} + + +/// Initializes this container from the base image published at the given address. +pub struct FromArgs { + /// * `address` - Image's address from its registry. + /// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main). + pub address: String, +} + + +/// Retrieves the value of the specified label. +pub struct LabelArgs { + pub name: String, +} + + +/// Creates a named sub-pipeline +pub struct PipelineArgs { + pub name: String, + pub description: Option, +} + + +/// Publishes this container as a new image to the specified address, for the platformVariants, returning a fully qualified ref. +pub struct PublishArgs { + /// * `address` - Registry's address to publish the image to. + /// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main). + pub address: String, + /// * `platformVariants` - Identifiers for other platform specific containers. + /// Used for multi-platform image. + pub platform_variants: Option>, +} + + +/// Configures default arguments for future commands. +pub struct WithDefaultArgsArgs { + pub args: Option>, +} + + +/// Retrieves this container plus a directory written at the given path. +pub struct WithDirectoryArgs { + pub path: String, + pub directory: DirectoryID, + pub exclude: Option>, + pub include: Option>, +} + + +/// Retrieves this container but with a different command entrypoint. +pub struct WithEntrypointArgs { + pub args: Vec, +} + + +/// Retrieves this container plus the given environment variable. +pub struct WithEnvVariableArgs { + pub name: String, + pub value: String, +} + + +/// Retrieves this container after executing the specified command inside it. +pub struct WithExecArgs { + /// * `args` - Command to run instead of the container's default command. + pub args: Vec, + /// * `stdin` - Content to write to the command's standard input before closing. + pub stdin: Option, + /// * `redirectStdout` - Redirect the command's standard output to a file in the container. + pub redirect_stdout: Option, + /// * `redirectStderr` - Redirect the command's standard error to a file in the container. + pub redirect_stderr: Option, + /// * `experimentalPrivilegedNesting` - Provide dagger access to the executed command. + /// Do not use this option unless you trust the command being executed. + /// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM. + pub experimental_privileged_nesting: Option, +} + + +/// Initializes this container from this DirectoryID. +pub struct WithFsArgs { + pub id: DirectoryID, +} + + +/// Retrieves this container plus the contents of the given file copied to the given path. +pub struct WithFileArgs { + pub path: String, + pub source: FileID, + pub permissions: Option, +} + + +/// Retrieves this container plus the given label. +pub struct WithLabelArgs { + pub name: String, + pub value: String, +} + + +/// Retrieves this container plus a cache volume mounted at the given path. +pub struct WithMountedCacheArgs { + pub path: String, + pub cache: CacheID, + pub source: Option, +} + + +/// Retrieves this container plus a directory mounted at the given path. +pub struct WithMountedDirectoryArgs { + pub path: String, + pub source: DirectoryID, +} + + +/// Retrieves this container plus a file mounted at the given path. +pub struct WithMountedFileArgs { + pub path: String, + pub source: FileID, +} + + +/// Retrieves this container plus a secret mounted into a file at the given path. +pub struct WithMountedSecretArgs { + pub path: String, + pub source: SecretID, +} + + +/// Retrieves this container plus a temporary directory mounted at the given path. +pub struct WithMountedTempArgs { + pub path: String, +} + + +/// Retrieves this container plus a new file written at the given path. +pub struct WithNewFileArgs { + pub path: String, + pub contents: Option, + pub permissions: Option, +} + + +/// Initializes this container from this DirectoryID. +pub struct WithRootfsArgs { + pub id: DirectoryID, +} + + +/// Retrieves this container plus an env variable containing the given secret. +pub struct WithSecretVariableArgs { + pub name: String, + pub secret: SecretID, +} + + +/// Retrieves this container plus a socket forwarded to the given Unix socket path. +pub struct WithUnixSocketArgs { + pub path: String, + pub source: SocketID, +} + + +/// Retrieves this containers with a different command user. +pub struct WithUserArgs { + pub name: String, +} + + +/// Retrieves this container with a different working directory. +pub struct WithWorkdirArgs { + pub path: String, +} + + +/// Retrieves this container minus the given environment variable. +pub struct WithoutEnvVariableArgs { + pub name: String, +} + + +/// Retrieves this container minus the given environment label. +pub struct WithoutLabelArgs { + pub name: String, +} + + +/// Retrieves this container after unmounting everything at the given path. +pub struct WithoutMountArgs { + pub path: String, +} + + +/// Retrieves this container with a previously added Unix socket removed. +pub struct WithoutUnixSocketArgs { + pub path: String, +} + /// An OCI-compatible container, also known as a docker container. pub struct Container { @@ -60,69 +323,12 @@ pub struct Container { } impl Container { - /// Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs. - /// # Arguments - /// - /// * `context` - Directory context used by the Dockerfile. - /// * `dockerfile` - Path to the Dockerfile to use. - /// Defaults to './Dockerfile'. - /// * `buildArgs` - Additional build arguments. - /// * `target` - Target build stage to build. pub fn build( &self, - _context: DirectoryID, - _dockerfile: Option, - _build_args: Option>, - _target: Option, + args: &BuildArgs ) -> Container { - todo!() - } - - /// Retrieves default arguments for future commands. - pub fn default_args(&self) -> Option> { - todo!() - } - - /// Retrieves a directory at the given path. Mounts are included. - pub fn directory(&self, _path: String) -> Directory { - todo!() - } - - /// Retrieves entrypoint to be prepended to the arguments of all commands. - pub fn entrypoint(&self) -> Option> { - todo!() - } - - /// Retrieves the value of the specified environment variable. - pub fn env_variable(&self, _name: String) -> Option { - todo!() - } - - /// Retrieves the list of environment variables passed to commands. - pub fn env_variables(&self) -> Vec { - todo!() - } - - /// Retrieves this container after executing the specified command inside it. - /// # Arguments - /// - /// * `args` - Command to run instead of the container's default command. - /// * `stdin` - Content to write to the command's standard input before closing. - /// * `redirectStdout` - Redirect the command's standard output to a file in the container. - /// * `redirectStderr` - Redirect the command's standard error to a file in the container. - /// * `experimentalPrivilegedNesting` - Provide dagger access to the executed command. - /// Do not use this option unless you trust the command being executed. - /// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM. - pub fn exec( - &self, - args: Option>, - _stdin: Option, - _redirect_stdout: Option, - _redirect_stderr: Option, - _experimental_privileged_nesting: Option, - ) -> Container { - let query = self.selection.select("exec"); - let query = query.arg("args", args).unwrap(); + let query = self.selection.select("build"); + query.args(args); Container { conn: self.conn.clone(), @@ -131,616 +337,1540 @@ impl Container { } } - /// Exit code of the last executed command. Zero means success. - /// Null if no command has been executed. - pub fn exit_code(&self) -> Option { - todo!() - } + pub fn default_args( + &self, + ) -> Option> { + let query = self.selection.select("defaultArgs"); - /// Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants. - /// Return true on success. - /// # Arguments - /// - /// * `path` - Host's destination path. - /// Path can be relative to the engine's workdir or absolute. - /// * `platformVariants` - Identifiers for other platform specific containers. - /// Used for multi-platform image. - pub fn export(&self, _path: String, _platform_variants: Option>) -> Boolean { - todo!() - } - - /// Retrieves a file at the given path. Mounts are included. - pub fn file(&self, _path: String) -> File { - todo!() - } - - /// Initializes this container from the base image published at the given address. - /// # Arguments - /// - /// * `address` - Image's address from its registry. - /// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main). - pub fn from(&self, address: String) -> Container { - let query = self.selection.select("from"); - let query = query.arg("address", address).unwrap(); - - Container { + Option> { conn: self.conn.clone(), proc: self.proc.clone(), selection: query, } } - /// Retrieves this container's root filesystem. Mounts are not included. - pub fn fs(&self) -> Directory { - todo!() - } - - /// A unique identifier for this container. - pub fn id(&self) -> ContainerID { - todo!() - } - - /// Retrieves the value of the specified label. - pub fn label(&self, _name: String) -> Option { - todo!() - } - - /// Retrieves the list of labels passed to container. - pub fn labels(&self) -> Vec