mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-25 16:32:42 +01:00
fix optional types for real
This commit is contained in:
parent
f4581ba4cd
commit
26069a82a6
@ -6,14 +6,33 @@ use crate::predicates::{
|
|||||||
is_custom_scalar_type_ref, is_list_type, is_required_type_ref, is_scalar_type_ref,
|
is_custom_scalar_type_ref, is_list_type, is_required_type_ref, is_scalar_type_ref,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//fn optional(t: rust::Tokens) -> impl FormatInto<Rust> {
|
||||||
|
// quote_fn! {"Option<$[const](t)>"}
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//fn required(t: rust::Tokens) -> impl FormatInto<Rust> {
|
||||||
|
// quote_fn! {"$[const](t)"}
|
||||||
|
//}
|
||||||
|
|
||||||
pub fn render_type_ref(inner: &TypeRef) -> eyre::Result<rust::Tokens> {
|
pub fn render_type_ref(inner: &TypeRef) -> eyre::Result<rust::Tokens> {
|
||||||
let extract_of_type = |t: &TypeRef| -> Option<TypeRef> {
|
let extract_of_type = |t: &TypeRef| -> Option<TypeRef> {
|
||||||
return t.clone().of_type.map(|t| *t);
|
return t.clone().of_type.map(|t| *t);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let (optional, inner) = if !is_required_type_ref(inner) {
|
||||||
|
(true, inner.clone())
|
||||||
|
} else {
|
||||||
|
(false, extract_of_type(inner).unwrap())
|
||||||
|
};
|
||||||
|
|
||||||
if is_list_type(&inner) {
|
if is_list_type(&inner) {
|
||||||
if let Some(inner_of_type) = extract_of_type(inner) {
|
if let Some(inner_of_type) = extract_of_type(&inner) {
|
||||||
let inner_field = render_type_ref(&inner_of_type)?;
|
let inner_field = render_type_ref(&inner_of_type)?;
|
||||||
|
if optional {
|
||||||
|
return Ok(quote! {
|
||||||
|
Option<Vec<$inner_field>>
|
||||||
|
});
|
||||||
|
}
|
||||||
return Ok(quote! {
|
return Ok(quote! {
|
||||||
Vec<$inner_field>
|
Vec<$inner_field>
|
||||||
});
|
});
|
||||||
@ -21,8 +40,13 @@ pub fn render_type_ref(inner: &TypeRef) -> eyre::Result<rust::Tokens> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if is_custom_scalar_type_ref(&inner) {
|
if is_custom_scalar_type_ref(&inner) {
|
||||||
if let Some(inner_of_type) = extract_of_type(inner) {
|
if let Some(inner_of_type) = extract_of_type(&inner) {
|
||||||
let inner_field = render_type_ref(&inner_of_type)?;
|
let inner_field = render_type_ref(&inner_of_type)?;
|
||||||
|
if optional {
|
||||||
|
return Ok(quote! {
|
||||||
|
Option<$inner_field>
|
||||||
|
});
|
||||||
|
}
|
||||||
return Ok(quote! {
|
return Ok(quote! {
|
||||||
$inner_field
|
$inner_field
|
||||||
});
|
});
|
||||||
@ -44,25 +68,34 @@ pub fn render_type_ref(inner: &TypeRef) -> eyre::Result<rust::Tokens> {
|
|||||||
_ => eyre::bail!("missing type in the end of chain"),
|
_ => eyre::bail!("missing type in the end of chain"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if optional {
|
||||||
|
return Ok(quote! {
|
||||||
|
Option<$name>
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(quote! {
|
return Ok(quote! {
|
||||||
$name
|
$name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_required_type_ref(inner) {
|
if let Some(inner_type) = inner.of_type.as_ref() {
|
||||||
if let Some(inner_of_type) = extract_of_type(inner) {
|
let inner_field = render_type_ref(&inner_type)?;
|
||||||
let inner_field = render_type_ref(&inner_of_type)?;
|
if optional {
|
||||||
return Ok(quote! {
|
return Ok(quote! {
|
||||||
Option<$inner_field>
|
Option<$inner_field>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(inner_type) = inner.of_type.as_ref() {
|
return Ok(inner_field);
|
||||||
return render_type_ref(&inner_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = inner.name.as_ref() {
|
if let Some(name) = inner.name.as_ref() {
|
||||||
|
if optional {
|
||||||
|
return Ok(quote! {
|
||||||
|
Option<$name>
|
||||||
|
});
|
||||||
|
}
|
||||||
return Ok(quote! {
|
return Ok(quote! {
|
||||||
$name
|
$name
|
||||||
});
|
});
|
||||||
|
@ -2,28 +2,28 @@ use dagger_core::{Boolean, Input, Int, Scalar};
|
|||||||
|
|
||||||
// code generated by dagger. DO NOT EDIT.
|
// code generated by dagger. DO NOT EDIT.
|
||||||
|
|
||||||
/// A unique identifier for a secret.
|
/// A content-addressed socket identifier.
|
||||||
pub struct SecretID(Scalar);
|
pub struct SocketID(Scalar);
|
||||||
|
|
||||||
/// The platform config OS and architecture in a Container.
|
|
||||||
/// The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64).
|
|
||||||
pub struct Platform(Scalar);
|
|
||||||
|
|
||||||
/// A file identifier.
|
|
||||||
pub struct FileID(Scalar);
|
|
||||||
|
|
||||||
/// A content-addressed directory identifier.
|
|
||||||
pub struct DirectoryID(Scalar);
|
|
||||||
|
|
||||||
/// A unique container identifier. Null designates an empty container (scratch).
|
/// A unique container identifier. Null designates an empty container (scratch).
|
||||||
pub struct ContainerID(Scalar);
|
pub struct ContainerID(Scalar);
|
||||||
|
|
||||||
/// A content-addressed socket identifier.
|
/// A content-addressed directory identifier.
|
||||||
pub struct SocketID(Scalar);
|
pub struct DirectoryID(Scalar);
|
||||||
|
|
||||||
|
/// A file identifier.
|
||||||
|
pub struct FileID(Scalar);
|
||||||
|
|
||||||
|
/// A unique identifier for a secret.
|
||||||
|
pub struct SecretID(Scalar);
|
||||||
|
|
||||||
/// A global cache volume identifier.
|
/// A global cache volume identifier.
|
||||||
pub struct CacheID(Scalar);
|
pub struct CacheID(Scalar);
|
||||||
|
|
||||||
|
/// The platform config OS and architecture in a Container.
|
||||||
|
/// The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64).
|
||||||
|
pub struct Platform(Scalar);
|
||||||
|
|
||||||
///
|
///
|
||||||
pub struct BuildArg {
|
pub struct BuildArg {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@ -33,12 +33,29 @@ pub struct BuildArg {
|
|||||||
|
|
||||||
impl Input for BuildArg {}
|
impl Input for BuildArg {}
|
||||||
|
|
||||||
|
/// A reference to a secret value, which can be handled more safely than the value itself.
|
||||||
|
pub struct Secret {}
|
||||||
|
|
||||||
|
impl Secret {
|
||||||
|
/// The identifier for this secret.
|
||||||
|
pub fn id(&self) -> SecretID {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The value of this secret.
|
||||||
|
pub fn plaintext(&self) -> String {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for Secret {}
|
||||||
|
|
||||||
/// A set of scripts and/or extensions
|
/// A set of scripts and/or extensions
|
||||||
pub struct Project {}
|
pub struct Project {}
|
||||||
|
|
||||||
impl Project {
|
impl Project {
|
||||||
/// extensions in this project
|
/// extensions in this project
|
||||||
pub fn extensions(&self) -> Vec<Project> {
|
pub fn extensions(&self) -> Option<Vec<Project>> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,61 +75,289 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// schema provided by the project
|
/// schema provided by the project
|
||||||
pub fn schema(&self) -> String {
|
pub fn schema(&self) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// sdk used to generate code for and/or execute this project
|
/// sdk used to generate code for and/or execute this project
|
||||||
pub fn sdk(&self) -> String {
|
pub fn sdk(&self) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input for Project {}
|
impl Input for Project {}
|
||||||
|
|
||||||
/// A simple key value object that represents a label.
|
/// A file.
|
||||||
pub struct Label {}
|
pub struct File {}
|
||||||
|
|
||||||
impl Label {
|
impl File {
|
||||||
/// The label name.
|
/// Retrieves the contents of the file.
|
||||||
|
pub fn contents(&self) -> String {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes the file to a file path on the host.
|
||||||
|
pub fn export(&self, path: String) -> Boolean {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves the content-addressed identifier of the file.
|
||||||
|
pub fn id(&self) -> FileID {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves a secret referencing the contents of this file.
|
||||||
|
pub fn secret(&self) -> Secret {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the size of the file, in bytes.
|
||||||
|
pub fn size(&self) -> Int {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch.
|
||||||
|
pub fn with_timestamps(&self, timestamp: Int) -> File {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for File {}
|
||||||
|
|
||||||
|
/// A simple key value object that represents an environment variable.
|
||||||
|
pub struct EnvVariable {}
|
||||||
|
|
||||||
|
impl EnvVariable {
|
||||||
|
/// The environment variable name.
|
||||||
pub fn name(&self) -> String {
|
pub fn name(&self) -> String {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The label value.
|
/// The environment variable value.
|
||||||
pub fn value(&self) -> String {
|
pub fn value(&self) -> String {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input for Label {}
|
impl Input for EnvVariable {}
|
||||||
|
|
||||||
/// Information about the host execution environment.
|
/// A directory.
|
||||||
pub struct Host {}
|
pub struct Directory {}
|
||||||
|
|
||||||
impl Host {
|
impl Directory {
|
||||||
/// Accesses a directory on the host.
|
/// Gets the difference between this directory and an another directory.
|
||||||
pub fn directory(&self, path: String, exclude: Vec<String>, include: Vec<String>) -> Directory {
|
pub fn diff(&self, other: DirectoryID) -> Directory {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accesses an environment variable on the host.
|
/// Retrieves a directory at the given path.
|
||||||
pub fn env_variable(&self, name: String) -> HostVariable {
|
pub fn directory(&self, path: String) -> Directory {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accesses a Unix socket on the host.
|
/// Builds a new Docker container from this directory.
|
||||||
pub fn unix_socket(&self, path: String) -> Socket {
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `dockerfile` - Path to the Dockerfile to use.
|
||||||
|
/// Defaults to './Dockerfile'.
|
||||||
|
/// * `platform` - The platform to build.
|
||||||
|
/// * `buildArgs` - Additional build arguments.
|
||||||
|
/// * `target` - Target build stage to build.
|
||||||
|
pub fn docker_build(
|
||||||
|
&self,
|
||||||
|
dockerfile: Option<String>,
|
||||||
|
platform: Option<Platform>,
|
||||||
|
build_args: Option<Vec<BuildArg>>,
|
||||||
|
target: Option<String>,
|
||||||
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the current working directory on the host.
|
/// Returns a list of files and directories at the given path.
|
||||||
pub fn workdir(&self, exclude: Vec<String>, include: Vec<String>) -> Directory {
|
pub fn entries(&self, path: Option<String>) -> Vec<String> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Writes the contents of the directory to a path on the host.
|
||||||
|
pub fn export(&self, path: String) -> Boolean {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves a file at the given path.
|
||||||
|
pub fn file(&self, path: String) -> File {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The content-addressed identifier of the directory.
|
||||||
|
pub fn id(&self) -> DirectoryID {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// load a project's metadata
|
||||||
|
pub fn load_project(&self, config_path: String) -> Project {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a named sub-pipeline.
|
||||||
|
pub fn pipeline(&self, name: String, description: Option<String>) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory plus a directory written at the given path.
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `exclude` - Exclude artifacts that match the given pattern.
|
||||||
|
/// (e.g. ["node_modules/", ".git*"]).
|
||||||
|
/// * `include` - Include only artifacts that match the given pattern.
|
||||||
|
/// (e.g. ["app/", "package.*"]).
|
||||||
|
pub fn with_directory(
|
||||||
|
&self,
|
||||||
|
path: String,
|
||||||
|
directory: DirectoryID,
|
||||||
|
exclude: Option<Vec<String>>,
|
||||||
|
include: Option<Vec<String>>,
|
||||||
|
) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory plus the contents of the given file copied to the given path.
|
||||||
|
pub fn with_file(&self, path: String, source: FileID, permissions: Option<Int>) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory plus a new directory created at the given path.
|
||||||
|
pub fn with_new_directory(&self, path: String, permissions: Option<Int>) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory plus a new file written at the given path.
|
||||||
|
pub fn with_new_file(
|
||||||
|
&self,
|
||||||
|
path: String,
|
||||||
|
contents: String,
|
||||||
|
permissions: Option<Int>,
|
||||||
|
) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch.
|
||||||
|
pub fn with_timestamps(&self, timestamp: Int) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory with the directory at the given path removed.
|
||||||
|
pub fn without_directory(&self, path: String) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves this directory with the file at the given path removed.
|
||||||
|
pub fn without_file(&self, path: String) -> Directory {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input for Host {}
|
impl Input for Directory {}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub struct Query {}
|
||||||
|
|
||||||
|
impl Query {
|
||||||
|
/// Constructs a cache volume for a given cache key.
|
||||||
|
/// # Arguments
|
||||||
|
///
|
||||||
|
/// * `key` - A string identifier to target this cache volume (e.g. "myapp-cache").
|
||||||
|
pub fn cache_volume(&self, key: String) -> CacheVolume {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loads a container from ID.
|
||||||
|
/// Null ID returns an empty container (scratch).
|
||||||
|
/// Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host.
|
||||||
|
pub fn container(&self, id: Option<ContainerID>, platform: Option<Platform>) -> Container {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The default platform of the builder.
|
||||||
|
pub fn default_platform(&self) -> Platform {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Load a directory by ID. No argument produces an empty directory.
|
||||||
|
pub fn directory(&self, id: Option<DirectoryID>) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loads a file by ID.
|
||||||
|
pub fn file(&self, id: FileID) -> Option<File> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Queries a git repository.
|
||||||
|
pub fn git(&self, url: String, keep_git_dir: Option<Boolean>) -> GitRepository {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Queries the host environment.
|
||||||
|
pub fn host(&self) -> Host {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a file containing an http remote url content.
|
||||||
|
pub fn http(&self, url: String) -> File {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a named sub-pipeline
|
||||||
|
pub fn pipeline(&self, name: String, description: Option<String>) -> Query {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Look up a project by name
|
||||||
|
pub fn project(&self, name: String) -> Project {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loads a secret from its ID.
|
||||||
|
pub fn secret(&self, id: SecretID) -> Secret {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Loads a socket by its ID.
|
||||||
|
pub fn socket(&self, id: Option<SocketID>) -> Socket {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for Query {}
|
||||||
|
|
||||||
|
/// An environment variable on the host environment.
|
||||||
|
pub struct HostVariable {}
|
||||||
|
|
||||||
|
impl HostVariable {
|
||||||
|
/// A secret referencing the value of this variable.
|
||||||
|
pub fn secret(&self) -> Secret {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The value of this variable.
|
||||||
|
pub fn value(&self) -> String {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for HostVariable {}
|
||||||
|
|
||||||
|
/// A directory whose contents persist across runs.
|
||||||
|
pub struct CacheVolume {}
|
||||||
|
|
||||||
|
impl CacheVolume {
|
||||||
|
///
|
||||||
|
pub fn id(&self) -> CacheID {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for CacheVolume {}
|
||||||
|
|
||||||
/// An OCI-compatible container, also known as a docker container.
|
/// An OCI-compatible container, also known as a docker container.
|
||||||
pub struct Container {}
|
pub struct Container {}
|
||||||
@ -129,15 +374,15 @@ impl Container {
|
|||||||
pub fn build(
|
pub fn build(
|
||||||
&self,
|
&self,
|
||||||
context: DirectoryID,
|
context: DirectoryID,
|
||||||
dockerfile: String,
|
dockerfile: Option<String>,
|
||||||
build_args: Vec<BuildArg>,
|
build_args: Option<Vec<BuildArg>>,
|
||||||
target: String,
|
target: Option<String>,
|
||||||
) -> Container {
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves default arguments for future commands.
|
/// Retrieves default arguments for future commands.
|
||||||
pub fn default_args(&self) -> Vec<String> {
|
pub fn default_args(&self) -> Option<Vec<String>> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,12 +392,12 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves entrypoint to be prepended to the arguments of all commands.
|
/// Retrieves entrypoint to be prepended to the arguments of all commands.
|
||||||
pub fn entrypoint(&self) -> Vec<String> {
|
pub fn entrypoint(&self) -> Option<Vec<String>> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the value of the specified environment variable.
|
/// Retrieves the value of the specified environment variable.
|
||||||
pub fn env_variable(&self, name: String) -> String {
|
pub fn env_variable(&self, name: String) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,18 +418,18 @@ impl Container {
|
|||||||
/// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
|
/// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
|
||||||
pub fn exec(
|
pub fn exec(
|
||||||
&self,
|
&self,
|
||||||
args: Vec<String>,
|
args: Option<Vec<String>>,
|
||||||
stdin: String,
|
stdin: Option<String>,
|
||||||
redirect_stdout: String,
|
redirect_stdout: Option<String>,
|
||||||
redirect_stderr: String,
|
redirect_stderr: Option<String>,
|
||||||
experimental_privileged_nesting: Boolean,
|
experimental_privileged_nesting: Option<Boolean>,
|
||||||
) -> Container {
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exit code of the last executed command. Zero means success.
|
/// Exit code of the last executed command. Zero means success.
|
||||||
/// Null if no command has been executed.
|
/// Null if no command has been executed.
|
||||||
pub fn exit_code(&self) -> Int {
|
pub fn exit_code(&self) -> Option<Int> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +441,7 @@ impl Container {
|
|||||||
/// Path can be relative to the engine's workdir or absolute.
|
/// Path can be relative to the engine's workdir or absolute.
|
||||||
/// * `platformVariants` - Identifiers for other platform specific containers.
|
/// * `platformVariants` - Identifiers for other platform specific containers.
|
||||||
/// Used for multi-platform image.
|
/// Used for multi-platform image.
|
||||||
pub fn export(&self, path: String, platform_variants: Vec<ContainerID>) -> Boolean {
|
pub fn export(&self, path: String, platform_variants: Option<Vec<ContainerID>>) -> Boolean {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +470,7 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the value of the specified label.
|
/// Retrieves the value of the specified label.
|
||||||
pub fn label(&self, name: String) -> String {
|
pub fn label(&self, name: String) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +485,7 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a named sub-pipeline
|
/// Creates a named sub-pipeline
|
||||||
pub fn pipeline(&self, name: String, description: String) -> Container {
|
pub fn pipeline(&self, name: String, description: Option<String>) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +501,7 @@ impl Container {
|
|||||||
/// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
|
/// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
|
||||||
/// * `platformVariants` - Identifiers for other platform specific containers.
|
/// * `platformVariants` - Identifiers for other platform specific containers.
|
||||||
/// Used for multi-platform image.
|
/// Used for multi-platform image.
|
||||||
pub fn publish(&self, address: String, platform_variants: Vec<ContainerID>) -> String {
|
pub fn publish(&self, address: String, platform_variants: Option<Vec<ContainerID>>) -> String {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,23 +512,23 @@ impl Container {
|
|||||||
|
|
||||||
/// The error stream of the last executed command.
|
/// The error stream of the last executed command.
|
||||||
/// Null if no command has been executed.
|
/// Null if no command has been executed.
|
||||||
pub fn stderr(&self) -> String {
|
pub fn stderr(&self) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The output stream of the last executed command.
|
/// The output stream of the last executed command.
|
||||||
/// Null if no command has been executed.
|
/// Null if no command has been executed.
|
||||||
pub fn stdout(&self) -> String {
|
pub fn stdout(&self) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the user to be set for all commands.
|
/// Retrieves the user to be set for all commands.
|
||||||
pub fn user(&self) -> String {
|
pub fn user(&self) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configures default arguments for future commands.
|
/// Configures default arguments for future commands.
|
||||||
pub fn with_default_args(&self, args: Vec<String>) -> Container {
|
pub fn with_default_args(&self, args: Option<Vec<String>>) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,8 +537,8 @@ impl Container {
|
|||||||
&self,
|
&self,
|
||||||
path: String,
|
path: String,
|
||||||
directory: DirectoryID,
|
directory: DirectoryID,
|
||||||
exclude: Vec<String>,
|
exclude: Option<Vec<String>>,
|
||||||
include: Vec<String>,
|
include: Option<Vec<String>>,
|
||||||
) -> Container {
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -321,10 +566,10 @@ impl Container {
|
|||||||
pub fn with_exec(
|
pub fn with_exec(
|
||||||
&self,
|
&self,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
stdin: String,
|
stdin: Option<String>,
|
||||||
redirect_stdout: String,
|
redirect_stdout: Option<String>,
|
||||||
redirect_stderr: String,
|
redirect_stderr: Option<String>,
|
||||||
experimental_privileged_nesting: Boolean,
|
experimental_privileged_nesting: Option<Boolean>,
|
||||||
) -> Container {
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -335,7 +580,7 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves this container plus the contents of the given file copied to the given path.
|
/// Retrieves this container plus the contents of the given file copied to the given path.
|
||||||
pub fn with_file(&self, path: String, source: FileID, permissions: Int) -> Container {
|
pub fn with_file(&self, path: String, source: FileID, permissions: Option<Int>) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +594,7 @@ impl Container {
|
|||||||
&self,
|
&self,
|
||||||
path: String,
|
path: String,
|
||||||
cache: CacheID,
|
cache: CacheID,
|
||||||
source: DirectoryID,
|
source: Option<DirectoryID>,
|
||||||
) -> Container {
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -375,7 +620,12 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves this container plus a new file written at the given path.
|
/// Retrieves this container plus a new file written at the given path.
|
||||||
pub fn with_new_file(&self, path: String, contents: String, permissions: Int) -> Container {
|
pub fn with_new_file(
|
||||||
|
&self,
|
||||||
|
path: String,
|
||||||
|
contents: Option<String>,
|
||||||
|
permissions: Option<Int>,
|
||||||
|
) -> Container {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,121 +675,94 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the working directory for all commands.
|
/// Retrieves the working directory for all commands.
|
||||||
pub fn workdir(&self) -> String {
|
pub fn workdir(&self) -> Option<String> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input for Container {}
|
impl Input for Container {}
|
||||||
|
|
||||||
|
/// A git ref (tag, branch or commit).
|
||||||
|
pub struct GitRef {}
|
||||||
|
|
||||||
|
impl GitRef {
|
||||||
|
/// The digest of the current value of this ref.
|
||||||
|
pub fn digest(&self) -> String {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The filesystem tree at this ref.
|
||||||
|
pub fn tree(
|
||||||
|
&self,
|
||||||
|
ssh_known_hosts: Option<String>,
|
||||||
|
ssh_auth_socket: Option<SocketID>,
|
||||||
|
) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for GitRef {}
|
||||||
|
|
||||||
|
/// A simple key value object that represents a label.
|
||||||
|
pub struct Label {}
|
||||||
|
|
||||||
|
impl Label {
|
||||||
|
/// The label name.
|
||||||
|
pub fn name(&self) -> String {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The label value.
|
||||||
|
pub fn value(&self) -> String {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for Label {}
|
||||||
|
|
||||||
|
/// Information about the host execution environment.
|
||||||
|
pub struct Host {}
|
||||||
|
|
||||||
|
impl Host {
|
||||||
|
/// Accesses a directory on the host.
|
||||||
|
pub fn directory(
|
||||||
|
&self,
|
||||||
|
path: String,
|
||||||
|
exclude: Option<Vec<String>>,
|
||||||
|
include: Option<Vec<String>>,
|
||||||
|
) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Accesses an environment variable on the host.
|
||||||
|
pub fn env_variable(&self, name: String) -> Option<HostVariable> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Accesses a Unix socket on the host.
|
||||||
|
pub fn unix_socket(&self, path: String) -> Socket {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieves the current working directory on the host.
|
||||||
|
pub fn workdir(&self, exclude: Option<Vec<String>>, include: Option<Vec<String>>) -> Directory {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Input for Host {}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub struct Query {}
|
pub struct Socket {}
|
||||||
|
|
||||||
impl Query {
|
impl Socket {
|
||||||
/// Constructs a cache volume for a given cache key.
|
/// The content-addressed identifier of the socket.
|
||||||
/// # Arguments
|
pub fn id(&self) -> SocketID {
|
||||||
///
|
|
||||||
/// * `key` - A string identifier to target this cache volume (e.g. "myapp-cache").
|
|
||||||
pub fn cache_volume(&self, key: String) -> CacheVolume {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Loads a container from ID.
|
|
||||||
/// Null ID returns an empty container (scratch).
|
|
||||||
/// Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host.
|
|
||||||
pub fn container(&self, id: ContainerID, platform: Platform) -> Container {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The default platform of the builder.
|
|
||||||
pub fn default_platform(&self) -> Platform {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Load a directory by ID. No argument produces an empty directory.
|
|
||||||
pub fn directory(&self, id: DirectoryID) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Loads a file by ID.
|
|
||||||
pub fn file(&self, id: FileID) -> File {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Queries a git repository.
|
|
||||||
pub fn git(&self, url: String, keep_git_dir: Boolean) -> GitRepository {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Queries the host environment.
|
|
||||||
pub fn host(&self) -> Host {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a file containing an http remote url content.
|
|
||||||
pub fn http(&self, url: String) -> File {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a named sub-pipeline
|
|
||||||
pub fn pipeline(&self, name: String, description: String) -> Query {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Look up a project by name
|
|
||||||
pub fn project(&self, name: String) -> Project {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Loads a secret from its ID.
|
|
||||||
pub fn secret(&self, id: SecretID) -> Secret {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Loads a socket by its ID.
|
|
||||||
pub fn socket(&self, id: SocketID) -> Socket {
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Input for Query {}
|
impl Input for Socket {}
|
||||||
|
|
||||||
/// A file.
|
|
||||||
pub struct File {}
|
|
||||||
|
|
||||||
impl File {
|
|
||||||
/// Retrieves the contents of the file.
|
|
||||||
pub fn contents(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Writes the file to a file path on the host.
|
|
||||||
pub fn export(&self, path: String) -> Boolean {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves the content-addressed identifier of the file.
|
|
||||||
pub fn id(&self) -> FileID {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves a secret referencing the contents of this file.
|
|
||||||
pub fn secret(&self) -> Secret {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the size of the file, in bytes.
|
|
||||||
pub fn size(&self) -> Int {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch.
|
|
||||||
pub fn with_timestamps(&self, timestamp: Int) -> File {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for File {}
|
|
||||||
|
|
||||||
/// A git repository.
|
/// A git repository.
|
||||||
pub struct GitRepository {}
|
pub struct GitRepository {}
|
||||||
@ -572,207 +795,3 @@ impl GitRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Input for GitRepository {}
|
impl Input for GitRepository {}
|
||||||
|
|
||||||
/// A directory whose contents persist across runs.
|
|
||||||
pub struct CacheVolume {}
|
|
||||||
|
|
||||||
impl CacheVolume {
|
|
||||||
///
|
|
||||||
pub fn id(&self) -> CacheID {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for CacheVolume {}
|
|
||||||
|
|
||||||
/// An environment variable on the host environment.
|
|
||||||
pub struct HostVariable {}
|
|
||||||
|
|
||||||
impl HostVariable {
|
|
||||||
/// A secret referencing the value of this variable.
|
|
||||||
pub fn secret(&self) -> Secret {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The value of this variable.
|
|
||||||
pub fn value(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for HostVariable {}
|
|
||||||
|
|
||||||
/// A reference to a secret value, which can be handled more safely than the value itself.
|
|
||||||
pub struct Secret {}
|
|
||||||
|
|
||||||
impl Secret {
|
|
||||||
/// The identifier for this secret.
|
|
||||||
pub fn id(&self) -> SecretID {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The value of this secret.
|
|
||||||
pub fn plaintext(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for Secret {}
|
|
||||||
|
|
||||||
/// A simple key value object that represents an environment variable.
|
|
||||||
pub struct EnvVariable {}
|
|
||||||
|
|
||||||
impl EnvVariable {
|
|
||||||
/// The environment variable name.
|
|
||||||
pub fn name(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The environment variable value.
|
|
||||||
pub fn value(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for EnvVariable {}
|
|
||||||
|
|
||||||
/// A directory.
|
|
||||||
pub struct Directory {}
|
|
||||||
|
|
||||||
impl Directory {
|
|
||||||
/// Gets the difference between this directory and an another directory.
|
|
||||||
pub fn diff(&self, other: DirectoryID) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves a directory at the given path.
|
|
||||||
pub fn directory(&self, path: String) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Builds a new Docker container from this directory.
|
|
||||||
/// # Arguments
|
|
||||||
///
|
|
||||||
/// * `dockerfile` - Path to the Dockerfile to use.
|
|
||||||
/// Defaults to './Dockerfile'.
|
|
||||||
/// * `platform` - The platform to build.
|
|
||||||
/// * `buildArgs` - Additional build arguments.
|
|
||||||
/// * `target` - Target build stage to build.
|
|
||||||
pub fn docker_build(
|
|
||||||
&self,
|
|
||||||
dockerfile: String,
|
|
||||||
platform: Platform,
|
|
||||||
build_args: Vec<BuildArg>,
|
|
||||||
target: String,
|
|
||||||
) -> Container {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a list of files and directories at the given path.
|
|
||||||
pub fn entries(&self, path: String) -> Vec<String> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Writes the contents of the directory to a path on the host.
|
|
||||||
pub fn export(&self, path: String) -> Boolean {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves a file at the given path.
|
|
||||||
pub fn file(&self, path: String) -> File {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The content-addressed identifier of the directory.
|
|
||||||
pub fn id(&self) -> DirectoryID {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// load a project's metadata
|
|
||||||
pub fn load_project(&self, config_path: String) -> Project {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a named sub-pipeline.
|
|
||||||
pub fn pipeline(&self, name: String, description: String) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory plus a directory written at the given path.
|
|
||||||
/// # Arguments
|
|
||||||
///
|
|
||||||
/// * `exclude` - Exclude artifacts that match the given pattern.
|
|
||||||
/// (e.g. ["node_modules/", ".git*"]).
|
|
||||||
/// * `include` - Include only artifacts that match the given pattern.
|
|
||||||
/// (e.g. ["app/", "package.*"]).
|
|
||||||
pub fn with_directory(
|
|
||||||
&self,
|
|
||||||
path: String,
|
|
||||||
directory: DirectoryID,
|
|
||||||
exclude: Vec<String>,
|
|
||||||
include: Vec<String>,
|
|
||||||
) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory plus the contents of the given file copied to the given path.
|
|
||||||
pub fn with_file(&self, path: String, source: FileID, permissions: Int) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory plus a new directory created at the given path.
|
|
||||||
pub fn with_new_directory(&self, path: String, permissions: Int) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory plus a new file written at the given path.
|
|
||||||
pub fn with_new_file(&self, path: String, contents: String, permissions: Int) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch.
|
|
||||||
pub fn with_timestamps(&self, timestamp: Int) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory with the directory at the given path removed.
|
|
||||||
pub fn without_directory(&self, path: String) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves this directory with the file at the given path removed.
|
|
||||||
pub fn without_file(&self, path: String) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for Directory {}
|
|
||||||
|
|
||||||
/// A git ref (tag, branch or commit).
|
|
||||||
pub struct GitRef {}
|
|
||||||
|
|
||||||
impl GitRef {
|
|
||||||
/// The digest of the current value of this ref.
|
|
||||||
pub fn digest(&self) -> String {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The filesystem tree at this ref.
|
|
||||||
pub fn tree(&self, ssh_known_hosts: String, ssh_auth_socket: SocketID) -> Directory {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for GitRef {}
|
|
||||||
|
|
||||||
///
|
|
||||||
pub struct Socket {}
|
|
||||||
|
|
||||||
impl Socket {
|
|
||||||
/// The content-addressed identifier of the socket.
|
|
||||||
pub fn id(&self) -> SocketID {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Input for Socket {}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user