mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-18 13:03:28 +02:00
Compare commits
7 Commits
dagger-cor
...
feat/dagge
Author | SHA1 | Date | |
---|---|---|---|
08c9c741df
|
|||
04934e8293
|
|||
13b7805e7e | |||
4381af0295 | |||
5f9b3a19c0 | |||
f9e7af931d | |||
ecca036bc6 |
4
Makefile.toml
Normal file
4
Makefile.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[tasks.codegen]
|
||||||
|
command = "cargo"
|
||||||
|
args = ["run", "-p", "ci", "--", "codegen"]
|
||||||
|
workspace = false
|
@@ -1,5 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use clap::ArgMatches;
|
||||||
use dagger_sdk::{Container, HostDirectoryOpts, Query};
|
use dagger_sdk::{Container, HostDirectoryOpts, Query};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -10,6 +11,7 @@ async fn main() -> eyre::Result<()> {
|
|||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.subcommand(clap::Command::new("pr"))
|
.subcommand(clap::Command::new("pr"))
|
||||||
.subcommand(clap::Command::new("release"))
|
.subcommand(clap::Command::new("release"))
|
||||||
|
.subcommand(clap::Command::new("codegen"))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let client = dagger_sdk::connect().await?;
|
let client = dagger_sdk::connect().await?;
|
||||||
@@ -20,6 +22,7 @@ async fn main() -> eyre::Result<()> {
|
|||||||
return validate_pr(client, base).await;
|
return validate_pr(client, base).await;
|
||||||
}
|
}
|
||||||
Some(("release", subm)) => return release(client, subm).await,
|
Some(("release", subm)) => return release(client, subm).await,
|
||||||
|
Some(("codegen", subm)) => return run_codegen(client, subm).await,
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
panic!("invalid subcommand selected!")
|
panic!("invalid subcommand selected!")
|
||||||
}
|
}
|
||||||
@@ -29,6 +32,41 @@ async fn main() -> eyre::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn run_codegen(client: Arc<Query>, _subm: &ArgMatches) -> eyre::Result<()> {
|
||||||
|
let docker_cli = client
|
||||||
|
.container()
|
||||||
|
.from("docker:cli")
|
||||||
|
.file("/usr/local/bin/docker");
|
||||||
|
let socket = client.host().unix_socket("/var/run/docker.sock");
|
||||||
|
|
||||||
|
let container = get_dependencies(client).await?;
|
||||||
|
|
||||||
|
let generated_image = container
|
||||||
|
.with_exec(vec!["mkdir", "-p", "/mnt/output"])
|
||||||
|
.with_mounted_file("/usr/bin/docker", docker_cli.id().await?)
|
||||||
|
.with_unix_socket("/var/run/docker.sock", socket.id().await?)
|
||||||
|
.with_exec(vec![
|
||||||
|
"cargo",
|
||||||
|
"run",
|
||||||
|
"--",
|
||||||
|
"generate",
|
||||||
|
"--output",
|
||||||
|
"crates/dagger-sdk/gen.rs",
|
||||||
|
])
|
||||||
|
.with_exec(vec!["cargo", "fmt", "--all"])
|
||||||
|
.with_exec(vec!["cargo", "fix", "--workspace", "--allow-dirty"])
|
||||||
|
.with_exec(vec!["mv", "crates/dagger-sdk/gen.rs", "/mnt/output/gen.rs"]);
|
||||||
|
|
||||||
|
let _ = generated_image.exit_code().await?;
|
||||||
|
|
||||||
|
generated_image
|
||||||
|
.file("/mnt/output/gen.rs")
|
||||||
|
.export("crates/dagger-sdk/src/gen.rs")
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
|
async fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
|
||||||
let src_dir = client.host().directory_opts(
|
let src_dir = client.host().directory_opts(
|
||||||
".",
|
".",
|
||||||
@@ -87,14 +125,14 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let cache_cargo_index_dir = client.cache_volume("cargo_index");
|
let cache_cargo_index_dir = client.cache_volume("cargo_index");
|
||||||
let cache_cargo_deps = client.cache_volume("cargo_deps");
|
let _cache_cargo_deps = client.cache_volume("cargo_deps");
|
||||||
let cache_cargo_bin = client.cache_volume("cargo_bin_cache");
|
let cache_cargo_bin = client.cache_volume("cargo_bin_cache");
|
||||||
|
|
||||||
let minio_url = "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz";
|
let minio_url = "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz";
|
||||||
|
|
||||||
let base_image = client
|
let base_image = client
|
||||||
.container()
|
.container()
|
||||||
.from("rust:latest")
|
.from("rustlang/rust:nightly")
|
||||||
.with_workdir("app")
|
.with_workdir("app")
|
||||||
.with_exec(vec!["apt-get", "update"])
|
.with_exec(vec!["apt-get", "update"])
|
||||||
.with_exec(vec!["apt-get", "install", "--yes", "libpq-dev", "wget"])
|
.with_exec(vec!["apt-get", "install", "--yes", "libpq-dev", "wget"])
|
||||||
@@ -110,7 +148,7 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
|||||||
"/usr/local/bin/sccache",
|
"/usr/local/bin/sccache",
|
||||||
])
|
])
|
||||||
.with_exec(vec!["chmod", "+x", "/usr/local/bin/sccache"])
|
.with_exec(vec!["chmod", "+x", "/usr/local/bin/sccache"])
|
||||||
.with_env_variable("RUSTC_WRAPPER", "/usr/local/bin/sccache")
|
//.with_env_variable("RUSTC_WRAPPER", "/usr/local/bin/sccache")
|
||||||
.with_env_variable(
|
.with_env_variable(
|
||||||
"AWS_ACCESS_KEY_ID",
|
"AWS_ACCESS_KEY_ID",
|
||||||
std::env::var("AWS_ACCESS_KEY_ID").unwrap_or("".into()),
|
std::env::var("AWS_ACCESS_KEY_ID").unwrap_or("".into()),
|
||||||
@@ -152,8 +190,7 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
|||||||
"--recipe-path",
|
"--recipe-path",
|
||||||
"recipe.json",
|
"recipe.json",
|
||||||
])
|
])
|
||||||
.with_mounted_cache("/app/", cache_cargo_deps.id().await?)
|
.with_directory("/app/", src_dir.id().await?)
|
||||||
.with_mounted_directory("/app/", src_dir.id().await?)
|
|
||||||
.with_exec(vec!["cargo", "build", "--all", "--release"]);
|
.with_exec(vec!["cargo", "build", "--all", "--release"]);
|
||||||
|
|
||||||
return Ok(builder_start);
|
return Ok(builder_start);
|
||||||
@@ -165,8 +202,21 @@ async fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
|
|||||||
src_dir
|
src_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn validate_pr(_client: Arc<Query>, container: Container) -> eyre::Result<()> {
|
async fn validate_pr(client: Arc<Query>, container: Container) -> eyre::Result<()> {
|
||||||
//let container = container.with_exec(vec!["cargo", "test", "--all"], None);
|
let exit = container.exit_code().await?;
|
||||||
|
if exit != 0 {
|
||||||
|
eyre::bail!("container failed with non-zero exit code");
|
||||||
|
}
|
||||||
|
let docker_cli = client
|
||||||
|
.container()
|
||||||
|
.from("docker:cli")
|
||||||
|
.file("/usr/local/bin/docker");
|
||||||
|
let socket = client.host().unix_socket("/var/run/docker.sock");
|
||||||
|
|
||||||
|
let container = container
|
||||||
|
.with_mounted_file("/usr/bin/docker", docker_cli.id().await?)
|
||||||
|
.with_unix_socket("/var/run/docker.sock", socket.id().await?)
|
||||||
|
.with_exec(vec!["cargo", "test", "--all"]);
|
||||||
|
|
||||||
let exit = container.exit_code().await?;
|
let exit = container.exit_code().await?;
|
||||||
if exit != 0 {
|
if exit != 0 {
|
||||||
|
@@ -153,6 +153,7 @@ impl From<&TypeRef> for Scalar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn get_type_from_name<'t>(types: &'t [FullType], name: &'t str) -> Option<&'t FullType> {
|
pub fn get_type_from_name<'t>(types: &'t [FullType], name: &'t str) -> Option<&'t FullType> {
|
||||||
types
|
types
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -258,6 +259,7 @@ pub fn input_values_has_optionals(input_values: &[&InputValue]) -> bool {
|
|||||||
> 0
|
> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn input_values_is_empty(input_values: &[InputValue]) -> bool {
|
pub fn input_values_is_empty(input_values: &[InputValue]) -> bool {
|
||||||
input_values.len() > 0
|
input_values.len() > 0
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#![deny(warnings)]
|
||||||
|
|
||||||
mod functions;
|
mod functions;
|
||||||
mod generator;
|
mod generator;
|
||||||
pub mod rust;
|
pub mod rust;
|
||||||
|
@@ -86,7 +86,7 @@ pub fn render_optional_field_args(
|
|||||||
}
|
}
|
||||||
quote! {
|
quote! {
|
||||||
$(a.description.pipe(|d| format_struct_comment(d)))
|
$(a.description.pipe(|d| format_struct_comment(d)))
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub $(format_struct_name(&a.name)): Option<$(type_)>,
|
pub $(format_struct_name(&a.name)): Option<$(type_)>,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{copy, Read, Write},
|
io::{copy, Write},
|
||||||
os::unix::prelude::PermissionsExt,
|
os::unix::prelude::PermissionsExt,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
@@ -27,6 +27,7 @@ impl Platform {
|
|||||||
let normalize_arch = match arch.as_str() {
|
let normalize_arch = match arch.as_str() {
|
||||||
"x86_64" => "amd64",
|
"x86_64" => "amd64",
|
||||||
"aarch" => "arm64",
|
"aarch" => "arm64",
|
||||||
|
"aarch64" => "arm64",
|
||||||
arch => arch,
|
arch => arch,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,6 +139,10 @@ impl Downloader {
|
|||||||
if let Ok(entry) = file {
|
if let Ok(entry) = file {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path != cli_bin_path {
|
if path != cli_bin_path {
|
||||||
|
println!(
|
||||||
|
"deleting client: path: {:?} vs cli_bin_path: {:?}",
|
||||||
|
path, cli_bin_path
|
||||||
|
);
|
||||||
std::fs::remove_file(path)?;
|
std::fs::remove_file(path)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,8 +205,6 @@ impl Downloader {
|
|||||||
hasher.update(&bytes);
|
hasher.update(&bytes);
|
||||||
let res = hasher.finalize();
|
let res = hasher.finalize();
|
||||||
|
|
||||||
println!("{}", hex::encode(&res));
|
|
||||||
|
|
||||||
if archive_url.ends_with(".zip") {
|
if archive_url.ends_with(".zip") {
|
||||||
// TODO: Nothing for now
|
// TODO: Nothing for now
|
||||||
todo!()
|
todo!()
|
||||||
@@ -220,8 +223,6 @@ impl Downloader {
|
|||||||
let mut entry = entry?;
|
let mut entry = entry?;
|
||||||
let path = entry.path()?;
|
let path = entry.path()?;
|
||||||
|
|
||||||
println!("path: {:?}", path);
|
|
||||||
|
|
||||||
if path.ends_with("dagger") {
|
if path.ends_with("dagger") {
|
||||||
copy(&mut entry, output)?;
|
copy(&mut entry, output)?;
|
||||||
|
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::DAGGER_ENGINE_VERSION;
|
||||||
use crate::{
|
use crate::{
|
||||||
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
|
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
|
||||||
};
|
};
|
||||||
@@ -10,7 +11,9 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
||||||
let cli = Downloader::new("0.3.13".into())?.get_cli().await?;
|
let cli = Downloader::new(DAGGER_ENGINE_VERSION.into())?
|
||||||
|
.get_cli()
|
||||||
|
.await?;
|
||||||
|
|
||||||
let cli_session = CliSession::new();
|
let cli_session = CliSession::new();
|
||||||
|
|
||||||
@@ -25,28 +28,3 @@ impl Engine {
|
|||||||
self.from_cli(cfg).await
|
self.from_cli(cfg).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::{config::Config, connect_params::ConnectParams};
|
|
||||||
|
|
||||||
use super::Engine;
|
|
||||||
|
|
||||||
// TODO: these tests potentially have a race condition
|
|
||||||
#[tokio::test]
|
|
||||||
async fn engine_can_start() {
|
|
||||||
let engine = Engine::new();
|
|
||||||
let params = engine
|
|
||||||
.start(&Config::new(None, None, None, None))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_ne!(
|
|
||||||
params.0,
|
|
||||||
ConnectParams {
|
|
||||||
port: 123,
|
|
||||||
session_token: "123".into()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -241,6 +241,7 @@ pub struct SchemaTypes {
|
|||||||
pub full_type: FullType,
|
pub full_type: FullType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SchemaDirectivesArgs {
|
pub struct SchemaDirectivesArgs {
|
||||||
@@ -257,6 +258,7 @@ pub struct SchemaDirectives {
|
|||||||
pub args: Option<Vec<Option<SchemaDirectivesArgs>>>,
|
pub args: Option<Vec<Option<SchemaDirectivesArgs>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Schema {
|
pub struct Schema {
|
||||||
|
@@ -1,3 +1,7 @@
|
|||||||
|
#![deny(warnings)]
|
||||||
|
|
||||||
|
pub const DAGGER_ENGINE_VERSION: &'static str = "0.4.0";
|
||||||
|
|
||||||
pub mod cli_session;
|
pub mod cli_session;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod connect_params;
|
pub mod connect_params;
|
||||||
|
@@ -12,13 +12,3 @@ pub async fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
|||||||
|
|
||||||
Ok(schema)
|
Ok(schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::get_schema;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn can_get_schema() {
|
|
||||||
let _ = get_schema().await.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -27,7 +27,7 @@ cargo add dagger-sdk
|
|||||||
```rust
|
```rust
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> eyre::Result<()> {
|
async fn main() -> eyre::Result<()> {
|
||||||
let client = dagger_sdk::connect()?;
|
let client = dagger_sdk::connect().await?;
|
||||||
|
|
||||||
let version = client
|
let version = client
|
||||||
.container()
|
.container()
|
||||||
@@ -46,9 +46,3 @@ And run it like a normal application:
|
|||||||
```bash
|
```bash
|
||||||
cargo run
|
cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disclaimer
|
|
||||||
|
|
||||||
You are free to use something else than `tokio`, I haven't tested it with
|
|
||||||
anything else, but it should work with any other runtime. We don't rely on it
|
|
||||||
specifically. That might change in the future though.
|
|
||||||
|
@@ -25,6 +25,11 @@ pub struct BuildArg {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub value: String,
|
pub value: String,
|
||||||
}
|
}
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||||
|
pub struct PipelineLabel {
|
||||||
|
pub value: String,
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CacheVolume {
|
pub struct CacheVolume {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Arc<Child>,
|
||||||
@@ -50,134 +55,144 @@ pub struct Container {
|
|||||||
pub struct ContainerBuildOpts<'a> {
|
pub struct ContainerBuildOpts<'a> {
|
||||||
/// Path to the Dockerfile to use.
|
/// Path to the Dockerfile to use.
|
||||||
/// Default: './Dockerfile'.
|
/// Default: './Dockerfile'.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub dockerfile: Option<&'a str>,
|
pub dockerfile: Option<&'a str>,
|
||||||
/// Additional build arguments.
|
/// Additional build arguments.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub build_args: Option<Vec<BuildArg>>,
|
pub build_args: Option<Vec<BuildArg>>,
|
||||||
/// Target build stage to build.
|
/// Target build stage to build.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub target: Option<&'a str>,
|
pub target: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerEndpointOpts<'a> {
|
pub struct ContainerEndpointOpts<'a> {
|
||||||
/// The exposed port number for the endpoint
|
/// The exposed port number for the endpoint
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub port: Option<isize>,
|
pub port: Option<isize>,
|
||||||
/// Return a URL with the given scheme, eg. http for http://
|
/// Return a URL with the given scheme, eg. http for http://
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub scheme: Option<&'a str>,
|
pub scheme: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerExecOpts<'a> {
|
pub struct ContainerExecOpts<'a> {
|
||||||
/// Command to run instead of the container's default command (e.g., ["run", "main.go"]).
|
/// Command to run instead of the container's default command (e.g., ["run", "main.go"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub args: Option<Vec<&'a str>>,
|
pub args: Option<Vec<&'a str>>,
|
||||||
/// Content to write to the command's standard input before closing (e.g., "Hello world").
|
/// Content to write to the command's standard input before closing (e.g., "Hello world").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub stdin: Option<&'a str>,
|
pub stdin: Option<&'a str>,
|
||||||
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub redirect_stdout: Option<&'a str>,
|
pub redirect_stdout: Option<&'a str>,
|
||||||
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
|
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub redirect_stderr: Option<&'a str>,
|
pub redirect_stderr: Option<&'a str>,
|
||||||
/// Provide dagger access to the executed command.
|
/// Provide dagger access to the executed command.
|
||||||
/// Do not use this option unless you trust the command being executed.
|
/// 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.
|
/// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub experimental_privileged_nesting: Option<bool>,
|
pub experimental_privileged_nesting: Option<bool>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerExportOpts {
|
pub struct ContainerExportOpts {
|
||||||
/// Identifiers for other platform specific containers.
|
/// Identifiers for other platform specific containers.
|
||||||
/// Used for multi-platform image.
|
/// Used for multi-platform image.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub platform_variants: Option<Vec<ContainerId>>,
|
pub platform_variants: Option<Vec<ContainerId>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerPipelineOpts<'a> {
|
pub struct ContainerPipelineOpts<'a> {
|
||||||
#[builder(setter(into, strip_option))]
|
/// Pipeline description.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
|
/// Pipeline labels.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
|
pub labels: Option<Vec<PipelineLabel>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerPublishOpts {
|
pub struct ContainerPublishOpts {
|
||||||
/// Identifiers for other platform specific containers.
|
/// Identifiers for other platform specific containers.
|
||||||
/// Used for multi-platform image.
|
/// Used for multi-platform image.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub platform_variants: Option<Vec<ContainerId>>,
|
pub platform_variants: Option<Vec<ContainerId>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithDefaultArgsOpts<'a> {
|
pub struct ContainerWithDefaultArgsOpts<'a> {
|
||||||
/// Arguments to prepend to future executions (e.g., ["-v", "--no-cache"]).
|
/// Arguments to prepend to future executions (e.g., ["-v", "--no-cache"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub args: Option<Vec<&'a str>>,
|
pub args: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithDirectoryOpts<'a> {
|
pub struct ContainerWithDirectoryOpts<'a> {
|
||||||
/// Patterns to exclude in the written directory (e.g., ["node_modules/**", ".gitignore", ".git/"]).
|
/// Patterns to exclude in the written directory (e.g., ["node_modules/**", ".gitignore", ".git/"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub exclude: Option<Vec<&'a str>>,
|
pub exclude: Option<Vec<&'a str>>,
|
||||||
/// Patterns to include in the written directory (e.g., ["*.go", "go.mod", "go.sum"]).
|
/// Patterns to include in the written directory (e.g., ["*.go", "go.mod", "go.sum"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub include: Option<Vec<&'a str>>,
|
pub include: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithExecOpts<'a> {
|
pub struct ContainerWithExecOpts<'a> {
|
||||||
/// Content to write to the command's standard input before closing (e.g., "Hello world").
|
/// Content to write to the command's standard input before closing (e.g., "Hello world").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub stdin: Option<&'a str>,
|
pub stdin: Option<&'a str>,
|
||||||
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub redirect_stdout: Option<&'a str>,
|
pub redirect_stdout: Option<&'a str>,
|
||||||
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
|
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub redirect_stderr: Option<&'a str>,
|
pub redirect_stderr: Option<&'a str>,
|
||||||
/// Provides dagger access to the executed command.
|
/// Provides dagger access to the executed command.
|
||||||
/// Do not use this option unless you trust the command being executed.
|
/// 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.
|
/// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub experimental_privileged_nesting: Option<bool>,
|
pub experimental_privileged_nesting: Option<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.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
|
pub insecure_root_capabilities: Option<bool>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithExposedPortOpts<'a> {
|
pub struct ContainerWithExposedPortOpts<'a> {
|
||||||
/// Transport layer network protocol
|
/// Transport layer network protocol
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub protocol: Option<NetworkProtocol>,
|
pub protocol: Option<NetworkProtocol>,
|
||||||
/// Optional port description
|
/// Optional port description
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithFileOpts {
|
pub struct ContainerWithFileOpts {
|
||||||
/// Permission given to the copied file (e.g., 0600).
|
/// Permission given to the copied file (e.g., 0600).
|
||||||
/// Default: 0644.
|
/// Default: 0644.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithMountedCacheOpts {
|
pub struct ContainerWithMountedCacheOpts {
|
||||||
/// Identifier of the directory to use as the cache volume's root.
|
/// Identifier of the directory to use as the cache volume's root.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub source: Option<DirectoryId>,
|
pub source: Option<DirectoryId>,
|
||||||
/// Sharing mode of the cache volume.
|
/// Sharing mode of the cache volume.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub sharing: Option<CacheSharingMode>,
|
pub sharing: Option<CacheSharingMode>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithNewFileOpts<'a> {
|
pub struct ContainerWithNewFileOpts<'a> {
|
||||||
/// Content of the file to write (e.g., "Hello world!").
|
/// Content of the file to write (e.g., "Hello world!").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub contents: Option<&'a str>,
|
pub contents: Option<&'a str>,
|
||||||
/// Permission given to the written file (e.g., 0600).
|
/// Permission given to the written file (e.g., 0600).
|
||||||
/// Default: 0644.
|
/// Default: 0644.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithoutExposedPortOpts {
|
pub struct ContainerWithoutExposedPortOpts {
|
||||||
/// Port protocol to unexpose
|
/// Port protocol to unexpose
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub protocol: Option<NetworkProtocol>,
|
pub protocol: Option<NetworkProtocol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +267,7 @@ impl Container {
|
|||||||
/// Retrieves an endpoint that clients can use to reach this container.
|
/// 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 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.
|
/// If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -265,6 +281,7 @@ impl Container {
|
|||||||
/// Retrieves an endpoint that clients can use to reach this container.
|
/// 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 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.
|
/// If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -358,7 +375,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// 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.
|
/// Errors if no command has been executed.
|
||||||
pub async fn exit_code(&self) -> eyre::Result<isize> {
|
pub async fn exit_code(&self) -> eyre::Result<isize> {
|
||||||
let query = self.selection.select("exitCode");
|
let query = self.selection.select("exitCode");
|
||||||
|
|
||||||
@@ -404,7 +421,8 @@ impl Container {
|
|||||||
|
|
||||||
query.execute(&graphql_client(&self.conn)).await
|
query.execute(&graphql_client(&self.conn)).await
|
||||||
}
|
}
|
||||||
/// Retrieves the list of exposed ports
|
/// Retrieves the list of exposed ports.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
pub fn exposed_ports(&self) -> Vec<Port> {
|
pub fn exposed_ports(&self) -> Vec<Port> {
|
||||||
let query = self.selection.select("exposedPorts");
|
let query = self.selection.select("exposedPorts");
|
||||||
|
|
||||||
@@ -460,6 +478,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Retrieves a hostname which can be used by clients to reach this container.
|
/// Retrieves a hostname which can be used by clients to reach this container.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
pub async fn hostname(&self) -> eyre::Result<String> {
|
pub async fn hostname(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("hostname");
|
let query = self.selection.select("hostname");
|
||||||
|
|
||||||
@@ -505,6 +524,7 @@ impl Container {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
/// * `name` - Pipeline name.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub fn pipeline(&self, name: impl Into<String>) -> Container {
|
pub fn pipeline(&self, name: impl Into<String>) -> Container {
|
||||||
let mut query = self.selection.select("pipeline");
|
let mut query = self.selection.select("pipeline");
|
||||||
@@ -522,6 +542,7 @@ impl Container {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
/// * `name` - Pipeline name.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub fn pipeline_opts<'a>(
|
pub fn pipeline_opts<'a>(
|
||||||
&self,
|
&self,
|
||||||
@@ -534,6 +555,9 @@ impl Container {
|
|||||||
if let Some(description) = opts.description {
|
if let Some(description) = opts.description {
|
||||||
query = query.arg("description", description);
|
query = query.arg("description", description);
|
||||||
}
|
}
|
||||||
|
if let Some(labels) = opts.labels {
|
||||||
|
query = query.arg("labels", labels);
|
||||||
|
}
|
||||||
|
|
||||||
return Container {
|
return Container {
|
||||||
proc: self.proc.clone(),
|
proc: self.proc.clone(),
|
||||||
@@ -600,14 +624,14 @@ 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.
|
/// Errors if no command has been executed.
|
||||||
pub async fn stderr(&self) -> eyre::Result<String> {
|
pub async fn stderr(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("stderr");
|
let query = self.selection.select("stderr");
|
||||||
|
|
||||||
query.execute(&graphql_client(&self.conn)).await
|
query.execute(&graphql_client(&self.conn)).await
|
||||||
}
|
}
|
||||||
/// The output stream of the last executed command.
|
/// The output stream of the last executed command.
|
||||||
/// Null if no command has been executed.
|
/// Errors if no command has been executed.
|
||||||
pub async fn stdout(&self) -> eyre::Result<String> {
|
pub async fn stdout(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("stdout");
|
let query = self.selection.select("stdout");
|
||||||
|
|
||||||
@@ -796,6 +820,9 @@ impl Container {
|
|||||||
experimental_privileged_nesting,
|
experimental_privileged_nesting,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if let Some(insecure_root_capabilities) = opts.insecure_root_capabilities {
|
||||||
|
query = query.arg("insecureRootCapabilities", insecure_root_capabilities);
|
||||||
|
}
|
||||||
|
|
||||||
return Container {
|
return Container {
|
||||||
proc: self.proc.clone(),
|
proc: self.proc.clone(),
|
||||||
@@ -807,6 +834,7 @@ impl Container {
|
|||||||
/// Exposed ports serve two purposes:
|
/// Exposed ports serve two purposes:
|
||||||
/// - For health checks and introspection, when running services
|
/// - For health checks and introspection, when running services
|
||||||
/// - For setting the EXPOSE OCI field when publishing the container
|
/// - For setting the EXPOSE OCI field when publishing the container
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -828,6 +856,7 @@ impl Container {
|
|||||||
/// Exposed ports serve two purposes:
|
/// Exposed ports serve two purposes:
|
||||||
/// - For health checks and introspection, when running services
|
/// - For health checks and introspection, when running services
|
||||||
/// - For setting the EXPOSE OCI field when publishing the container
|
/// - For setting the EXPOSE OCI field when publishing the container
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -1159,6 +1188,7 @@ impl Container {
|
|||||||
/// Establish a runtime dependency on a service. The service will be started automatically when needed and detached when it is no longer needed.
|
/// Establish a runtime dependency on a service. The service will be started automatically when needed and detached when it is no longer needed.
|
||||||
/// The service will be reachable from the container via the provided hostname alias.
|
/// 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.
|
/// The service dependency will also convey to any files or directories produced by the container.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -1247,6 +1277,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Unexpose a previously exposed port.
|
/// Unexpose a previously exposed port.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -1265,6 +1296,7 @@ impl Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Unexpose a previously exposed port.
|
/// Unexpose a previously exposed port.
|
||||||
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
@@ -1371,57 +1403,61 @@ pub struct Directory {
|
|||||||
pub struct DirectoryDockerBuildOpts<'a> {
|
pub struct DirectoryDockerBuildOpts<'a> {
|
||||||
/// Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
|
/// Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
|
||||||
/// Defaults: './Dockerfile'.
|
/// Defaults: './Dockerfile'.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub dockerfile: Option<&'a str>,
|
pub dockerfile: Option<&'a str>,
|
||||||
/// The platform to build.
|
/// The platform to build.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub platform: Option<Platform>,
|
pub platform: Option<Platform>,
|
||||||
/// Build arguments to use in the build.
|
/// Build arguments to use in the build.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub build_args: Option<Vec<BuildArg>>,
|
pub build_args: Option<Vec<BuildArg>>,
|
||||||
/// Target build stage to build.
|
/// Target build stage to build.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub target: Option<&'a str>,
|
pub target: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryEntriesOpts<'a> {
|
pub struct DirectoryEntriesOpts<'a> {
|
||||||
/// Location of the directory to look at (e.g., "/src").
|
/// Location of the directory to look at (e.g., "/src").
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub path: Option<&'a str>,
|
pub path: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryPipelineOpts<'a> {
|
pub struct DirectoryPipelineOpts<'a> {
|
||||||
#[builder(setter(into, strip_option))]
|
/// Pipeline description.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
|
/// Pipeline labels.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
|
pub labels: Option<Vec<PipelineLabel>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithDirectoryOpts<'a> {
|
pub struct DirectoryWithDirectoryOpts<'a> {
|
||||||
/// Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
/// Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub exclude: Option<Vec<&'a str>>,
|
pub exclude: Option<Vec<&'a str>>,
|
||||||
/// Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
/// Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub include: Option<Vec<&'a str>>,
|
pub include: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithFileOpts {
|
pub struct DirectoryWithFileOpts {
|
||||||
/// Permission given to the copied file (e.g., 0600).
|
/// Permission given to the copied file (e.g., 0600).
|
||||||
/// Default: 0644.
|
/// Default: 0644.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithNewDirectoryOpts {
|
pub struct DirectoryWithNewDirectoryOpts {
|
||||||
/// Permission granted to the created directory (e.g., 0777).
|
/// Permission granted to the created directory (e.g., 0777).
|
||||||
/// Default: 0755.
|
/// Default: 0755.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithNewFileOpts {
|
pub struct DirectoryWithNewFileOpts {
|
||||||
/// Permission given to the copied file (e.g., 0600).
|
/// Permission given to the copied file (e.g., 0600).
|
||||||
/// Default: 0644.
|
/// Default: 0644.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1574,10 +1610,11 @@ impl Directory {
|
|||||||
conn: self.conn.clone(),
|
conn: self.conn.clone(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Creates a named sub-pipeline.
|
/// Creates a named sub-pipeline
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
/// * `name` - Pipeline name.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub fn pipeline(&self, name: impl Into<String>) -> Directory {
|
pub fn pipeline(&self, name: impl Into<String>) -> Directory {
|
||||||
let mut query = self.selection.select("pipeline");
|
let mut query = self.selection.select("pipeline");
|
||||||
@@ -1591,10 +1628,11 @@ impl Directory {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a named sub-pipeline.
|
/// Creates a named sub-pipeline
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
/// * `name` - Pipeline name.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub fn pipeline_opts<'a>(
|
pub fn pipeline_opts<'a>(
|
||||||
&self,
|
&self,
|
||||||
@@ -1607,6 +1645,9 @@ impl Directory {
|
|||||||
if let Some(description) = opts.description {
|
if let Some(description) = opts.description {
|
||||||
query = query.arg("description", description);
|
query = query.arg("description", description);
|
||||||
}
|
}
|
||||||
|
if let Some(labels) = opts.labels {
|
||||||
|
query = query.arg("labels", labels);
|
||||||
|
}
|
||||||
|
|
||||||
return Directory {
|
return Directory {
|
||||||
proc: self.proc.clone(),
|
proc: self.proc.clone(),
|
||||||
@@ -1948,9 +1989,9 @@ pub struct GitRef {
|
|||||||
|
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct GitRefTreeOpts<'a> {
|
pub struct GitRefTreeOpts<'a> {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub ssh_known_hosts: Option<&'a str>,
|
pub ssh_known_hosts: Option<&'a str>,
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub ssh_auth_socket: Option<SocketId>,
|
pub ssh_auth_socket: Option<SocketId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2077,19 +2118,19 @@ pub struct Host {
|
|||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct HostDirectoryOpts<'a> {
|
pub struct HostDirectoryOpts<'a> {
|
||||||
/// Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
/// Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub exclude: Option<Vec<&'a str>>,
|
pub exclude: Option<Vec<&'a str>>,
|
||||||
/// Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
/// Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub include: Option<Vec<&'a str>>,
|
pub include: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct HostWorkdirOpts<'a> {
|
pub struct HostWorkdirOpts<'a> {
|
||||||
/// Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
/// Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub exclude: Option<Vec<&'a str>>,
|
pub exclude: Option<Vec<&'a str>>,
|
||||||
/// Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
/// Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub include: Option<Vec<&'a str>>,
|
pub include: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2343,39 +2384,43 @@ pub struct Query {
|
|||||||
|
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryContainerOpts {
|
pub struct QueryContainerOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub id: Option<ContainerId>,
|
pub id: Option<ContainerId>,
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub platform: Option<Platform>,
|
pub platform: Option<Platform>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryDirectoryOpts {
|
pub struct QueryDirectoryOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub id: Option<DirectoryId>,
|
pub id: Option<DirectoryId>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryGitOpts {
|
pub struct QueryGitOpts {
|
||||||
/// Set to true to keep .git directory.
|
/// Set to true to keep .git directory.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub keep_git_dir: Option<bool>,
|
pub keep_git_dir: Option<bool>,
|
||||||
/// A service which must be started before the repo is fetched.
|
/// A service which must be started before the repo is fetched.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub experimental_service_host: Option<ContainerId>,
|
pub experimental_service_host: Option<ContainerId>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryHttpOpts {
|
pub struct QueryHttpOpts {
|
||||||
/// A service which must be started before the URL is fetched.
|
/// A service which must be started before the URL is fetched.
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub experimental_service_host: Option<ContainerId>,
|
pub experimental_service_host: Option<ContainerId>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryPipelineOpts<'a> {
|
pub struct QueryPipelineOpts<'a> {
|
||||||
#[builder(setter(into, strip_option))]
|
/// Pipeline description.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
|
/// Pipeline labels.
|
||||||
|
#[builder(setter(into, strip_option), default)]
|
||||||
|
pub labels: Option<Vec<PipelineLabel>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QuerySocketOpts {
|
pub struct QuerySocketOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option), default)]
|
||||||
pub id: Option<SocketId>,
|
pub id: Option<SocketId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2582,10 +2627,11 @@ impl Query {
|
|||||||
conn: self.conn.clone(),
|
conn: self.conn.clone(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Creates a named sub-pipeline
|
/// Creates a named sub-pipeline.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
/// * `name` - Pipeline name.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub fn pipeline(&self, name: impl Into<String>) -> Query {
|
pub fn pipeline(&self, name: impl Into<String>) -> Query {
|
||||||
let mut query = self.selection.select("pipeline");
|
let mut query = self.selection.select("pipeline");
|
||||||
@@ -2599,10 +2645,11 @@ impl Query {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a named sub-pipeline
|
/// Creates a named sub-pipeline.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
/// * `name` - Pipeline name.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub fn pipeline_opts<'a>(&self, name: impl Into<String>, opts: QueryPipelineOpts<'a>) -> Query {
|
pub fn pipeline_opts<'a>(&self, name: impl Into<String>, opts: QueryPipelineOpts<'a>) -> Query {
|
||||||
let mut query = self.selection.select("pipeline");
|
let mut query = self.selection.select("pipeline");
|
||||||
@@ -2611,6 +2658,9 @@ impl Query {
|
|||||||
if let Some(description) = opts.description {
|
if let Some(description) = opts.description {
|
||||||
query = query.arg("description", description);
|
query = query.arg("description", description);
|
||||||
}
|
}
|
||||||
|
if let Some(labels) = opts.labels {
|
||||||
|
query = query.arg("labels", labels);
|
||||||
|
}
|
||||||
|
|
||||||
return Query {
|
return Query {
|
||||||
proc: self.proc.clone(),
|
proc: self.proc.clone(),
|
||||||
@@ -2714,9 +2764,9 @@ impl Socket {
|
|||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||||
pub enum CacheSharingMode {
|
pub enum CacheSharingMode {
|
||||||
|
LOCKED,
|
||||||
SHARED,
|
SHARED,
|
||||||
PRIVATE,
|
PRIVATE,
|
||||||
LOCKED,
|
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||||
pub enum NetworkProtocol {
|
pub enum NetworkProtocol {
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
#![deny(warnings)]
|
||||||
|
|
||||||
mod client;
|
mod client;
|
||||||
mod gen;
|
mod gen;
|
||||||
mod querybuilder;
|
mod querybuilder;
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_example_container() {
|
async fn test_example_container() {
|
||||||
@@ -19,3 +20,99 @@ async fn test_example_container() {
|
|||||||
|
|
||||||
assert_eq!(out, "3.16.2\n".to_string())
|
assert_eq!(out, "3.16.2\n".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_directory() {
|
||||||
|
let c = connect().await.unwrap();
|
||||||
|
|
||||||
|
let contents = c
|
||||||
|
.directory()
|
||||||
|
.with_new_file("/hello.txt", "world")
|
||||||
|
.file("/hello.txt")
|
||||||
|
.contents()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!("world", contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_git() {
|
||||||
|
let c = connect().await.unwrap();
|
||||||
|
|
||||||
|
let tree = c.git("github.com/dagger/dagger").branch("main").tree();
|
||||||
|
|
||||||
|
let _ = tree
|
||||||
|
.entries()
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.find(|f| f.as_str() == "README.md")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let readme_file = tree.file("README.md");
|
||||||
|
|
||||||
|
let readme = readme_file.contents().await.unwrap();
|
||||||
|
assert_eq!(true, readme.find("Dagger").is_some());
|
||||||
|
|
||||||
|
let readme_id = readme_file.id().await.unwrap();
|
||||||
|
let other_readme = c.file(readme_id).contents().await.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(readme, other_readme);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_container() {
|
||||||
|
let client = connect().await.unwrap();
|
||||||
|
|
||||||
|
let alpine = client.container().from("alpine:3.16.2");
|
||||||
|
|
||||||
|
let contents = alpine
|
||||||
|
.fs()
|
||||||
|
.file("/etc/alpine-release")
|
||||||
|
.contents()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(contents, "3.16.2\n".to_string());
|
||||||
|
|
||||||
|
let out = alpine
|
||||||
|
.exec_opts(
|
||||||
|
ContainerExecOptsBuilder::default()
|
||||||
|
.args(vec!["cat", "/etc/alpine-release"])
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.stdout()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(out, "3.16.2\n".to_string());
|
||||||
|
|
||||||
|
let id = alpine.id().await.unwrap();
|
||||||
|
let contents = client
|
||||||
|
.container_opts(dagger_sdk::QueryContainerOpts {
|
||||||
|
id: Some(id),
|
||||||
|
platform: None,
|
||||||
|
})
|
||||||
|
.fs()
|
||||||
|
.file("/etc/alpine-release")
|
||||||
|
.contents()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(contents, "3.16.2\n".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_err_message() {
|
||||||
|
let client = connect().await.unwrap();
|
||||||
|
|
||||||
|
let alpine = client.container().from("fake.invalid:latest").id().await;
|
||||||
|
assert_eq!(alpine.is_err(), true);
|
||||||
|
let err = alpine.expect_err("Tests expect err");
|
||||||
|
|
||||||
|
let error_msg = r#"
|
||||||
|
GQLClient Error: Look at json field for more details
|
||||||
|
Message: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
|
||||||
|
"#;
|
||||||
|
|
||||||
|
assert_eq!(err.to_string().as_str(), error_msg);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user