mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
14 Commits
dagger-cod
...
dagger-sdk
Author | SHA1 | Date | |
---|---|---|---|
f390eac29f
|
|||
e642778d90
|
|||
7133bfae95 | |||
41b20b6268 | |||
13b7805e7e | |||
4381af0295 | |||
5f9b3a19c0 | |||
f9e7af931d | |||
ecca036bc6 | |||
6a9a560cdc
|
|||
e578b0e371 | |||
3e8ca8d86e | |||
88b055cb47
|
|||
e331ca0035
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -260,7 +260,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-core"
|
||||
version = "0.2.6"
|
||||
version = "0.2.8"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"dirs",
|
||||
@@ -309,7 +309,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.13"
|
||||
version = "0.2.16"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core",
|
||||
|
@@ -20,7 +20,7 @@ members = [
|
||||
|
||||
[dependencies]
|
||||
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
|
||||
dagger-core = { path = "crates/dagger-core", version = "^0.2.3" }
|
||||
dagger-core = { path = "crates/dagger-core", version = "^0.2.8" }
|
||||
|
||||
clap = "4.1.6"
|
||||
dirs = "4.0.0"
|
||||
|
43
Makefile.toml
Normal file
43
Makefile.toml
Normal file
@@ -0,0 +1,43 @@
|
||||
[tasks.codegen]
|
||||
command = "cargo"
|
||||
args = ["run", "-p", "ci", "--", "codegen"]
|
||||
workspace = false
|
||||
|
||||
[tasks.build]
|
||||
command = "cargo"
|
||||
args = ["run", "-p", "ci", "--", "ci"]
|
||||
dependencies = ["codegen"]
|
||||
workspace = false
|
||||
|
||||
[tasks.fmt]
|
||||
command = "cargo"
|
||||
args = ["fmt", "--all"]
|
||||
workspace = false
|
||||
|
||||
[tasks.fix]
|
||||
command = "cargo"
|
||||
args = ["fix", "--workspace", "--allow-dirty"]
|
||||
dependencies = ["fmt"]
|
||||
workspace = false
|
||||
|
||||
[tasks.release_crate]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"smart-release",
|
||||
"--allow-fully-generated-changelogs",
|
||||
"--update-crates-index",
|
||||
"dagger-sdk",
|
||||
]
|
||||
dependencies = ["codegen", "fix"]
|
||||
workspace = false
|
||||
|
||||
[tasks.release_crate_commit]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"smart-release",
|
||||
"-e",
|
||||
"--allow-fully-generated-changelogs",
|
||||
"--update-crates-index",
|
||||
"dagger-sdk",
|
||||
]
|
||||
workspace = false
|
@@ -8,6 +8,6 @@ edition = "2021"
|
||||
[dependencies]
|
||||
clap = "4.1.6"
|
||||
color-eyre = "0.6.2"
|
||||
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.13" }
|
||||
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.16" }
|
||||
eyre = "0.6.8"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
@@ -1,5 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use clap::ArgMatches;
|
||||
use dagger_sdk::{Container, HostDirectoryOpts, Query};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -10,6 +11,7 @@ async fn main() -> eyre::Result<()> {
|
||||
.subcommand_required(true)
|
||||
.subcommand(clap::Command::new("pr"))
|
||||
.subcommand(clap::Command::new("release"))
|
||||
.subcommand(clap::Command::new("codegen"))
|
||||
.get_matches();
|
||||
|
||||
let client = dagger_sdk::connect().await?;
|
||||
@@ -20,6 +22,7 @@ async fn main() -> eyre::Result<()> {
|
||||
return validate_pr(client, base).await;
|
||||
}
|
||||
Some(("release", subm)) => return release(client, subm).await,
|
||||
Some(("codegen", subm)) => return run_codegen(client, subm).await,
|
||||
Some(_) => {
|
||||
panic!("invalid subcommand selected!")
|
||||
}
|
||||
@@ -29,6 +32,42 @@ 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!["cargo", "fmt", "--all"])
|
||||
.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> {
|
||||
let src_dir = client.host().directory_opts(
|
||||
".",
|
||||
@@ -87,14 +126,14 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
);
|
||||
|
||||
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 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
|
||||
.container()
|
||||
.from("rust:latest")
|
||||
.from("rustlang/rust:nightly")
|
||||
.with_workdir("app")
|
||||
.with_exec(vec!["apt-get", "update"])
|
||||
.with_exec(vec!["apt-get", "install", "--yes", "libpq-dev", "wget"])
|
||||
@@ -110,7 +149,7 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
"/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(
|
||||
"AWS_ACCESS_KEY_ID",
|
||||
std::env::var("AWS_ACCESS_KEY_ID").unwrap_or("".into()),
|
||||
@@ -152,8 +191,7 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
"--recipe-path",
|
||||
"recipe.json",
|
||||
])
|
||||
.with_mounted_cache("/app/", cache_cargo_deps.id().await?)
|
||||
.with_mounted_directory("/app/", src_dir.id().await?)
|
||||
.with_directory("/app/", src_dir.id().await?)
|
||||
.with_exec(vec!["cargo", "build", "--all", "--release"]);
|
||||
|
||||
return Ok(builder_start);
|
||||
@@ -165,8 +203,21 @@ async fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
src_dir
|
||||
}
|
||||
|
||||
async fn validate_pr(_client: Arc<Query>, container: Container) -> eyre::Result<()> {
|
||||
//let container = container.with_exec(vec!["cargo", "test", "--all"], None);
|
||||
async fn validate_pr(client: Arc<Query>, container: Container) -> eyre::Result<()> {
|
||||
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?;
|
||||
if exit != 0 {
|
||||
|
@@ -11,7 +11,7 @@ publish = true
|
||||
|
||||
[dependencies]
|
||||
convert_case = "0.6.0"
|
||||
dagger-core = { path = "../dagger-core", version = "^0.2.6" }
|
||||
dagger-core = { path = "../dagger-core", version = "^0.2.8" }
|
||||
|
||||
eyre = "0.6.8"
|
||||
genco = "0.17.3"
|
||||
|
@@ -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> {
|
||||
types
|
||||
.into_iter()
|
||||
@@ -258,6 +259,7 @@ pub fn input_values_has_optionals(input_values: &[&InputValue]) -> bool {
|
||||
> 0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn input_values_is_empty(input_values: &[InputValue]) -> bool {
|
||||
input_values.len() > 0
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
mod functions;
|
||||
mod generator;
|
||||
pub mod rust;
|
||||
|
@@ -26,9 +26,10 @@ fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
|
||||
|
||||
pub fn render_enum(t: &FullType) -> eyre::Result<rust::Tokens> {
|
||||
let serialize = rust::import("serde", "Serialize");
|
||||
let deserialize = rust::import("serde", "Deserialize");
|
||||
|
||||
Ok(quote! {
|
||||
#[derive($serialize, Clone, PartialEq, Debug)]
|
||||
#[derive($serialize, $deserialize, Clone, PartialEq, Debug)]
|
||||
pub enum $(t.name.as_ref()) {
|
||||
$(render_enum_values(t))
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ pub fn render_optional_field_args(
|
||||
}
|
||||
quote! {
|
||||
$(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_)>,
|
||||
}
|
||||
});
|
||||
|
@@ -5,8 +5,72 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v0.2.8 (2023-03-10)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-41b20b6268db9d8defe333694e4d3ec019d7c923/> bump version
|
||||
- <csr-id-5f9b3a19c0ab6988bc335b020052074f3f101305/> set internal warnings as errors
|
||||
- <csr-id-f9e7af931d94fbedacf74f5da9a2f71b1992324b/> introduce tests again
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-ecca036bc644fee93fbcb69bf6da9f29169e473e/> fix builder pattern to actually work with default values
|
||||
In previous versions the builder pattern required all values to be set.
|
||||
This has not been fixed, so that default values are allowed.
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 4 commits contributed to the release over the course of 13 calendar days.
|
||||
- 13 days passed between releases.
|
||||
- 4 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- bump version ([`41b20b6`](https://github.com/kjuulh/dagger-rs/commit/41b20b6268db9d8defe333694e4d3ec019d7c923))
|
||||
- set internal warnings as errors ([`5f9b3a1`](https://github.com/kjuulh/dagger-rs/commit/5f9b3a19c0ab6988bc335b020052074f3f101305))
|
||||
- introduce tests again ([`f9e7af9`](https://github.com/kjuulh/dagger-rs/commit/f9e7af931d94fbedacf74f5da9a2f71b1992324b))
|
||||
- fix builder pattern to actually work with default values ([`ecca036`](https://github.com/kjuulh/dagger-rs/commit/ecca036bc644fee93fbcb69bf6da9f29169e473e))
|
||||
</details>
|
||||
|
||||
## v0.2.7 (2023-02-24)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f/> update to dagger-v0.3.13
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 2 commits contributed to the release.
|
||||
- 4 days passed between releases.
|
||||
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-core v0.2.7, dagger-sdk v0.2.15 ([`6a9a560`](https://github.com/kjuulh/dagger-rs/commit/6a9a560cdca097abf23371d44599a2f1b726ae7f))
|
||||
- update to dagger-v0.3.13 ([`3e8ca8d`](https://github.com/kjuulh/dagger-rs/commit/3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f))
|
||||
</details>
|
||||
|
||||
## v0.2.6 (2023-02-20)
|
||||
|
||||
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
|
||||
|
||||
### Chore
|
||||
|
||||
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
|
||||
@@ -19,7 +83,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 2 commits contributed to the release.
|
||||
- 3 commits contributed to the release.
|
||||
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
@@ -30,6 +94,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 ([`7179f8b`](https://github.com/kjuulh/dagger-rs/commit/7179f8b598ef04e62925e39d3f55740253c01686))
|
||||
- ran clippy ([`1f77d90`](https://github.com/kjuulh/dagger-rs/commit/1f77d90c0f0ac832a181b2322350ea395612986c))
|
||||
- cli session keep session alive ([`8dfecf9`](https://github.com/kjuulh/dagger-rs/commit/8dfecf976c5537cc2c03881de2b2fd2b2508683a))
|
||||
</details>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-core"
|
||||
version = "0.2.6"
|
||||
version = "0.2.8"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
|
@@ -1,9 +1,4 @@
|
||||
use std::{
|
||||
fs::canonicalize,
|
||||
path::PathBuf,
|
||||
process::Stdio,
|
||||
sync::Arc,
|
||||
};
|
||||
use std::{fs::canonicalize, path::PathBuf, process::Stdio, sync::Arc};
|
||||
|
||||
use tokio::io::AsyncBufReadExt;
|
||||
|
||||
@@ -105,7 +100,9 @@ impl InnerCliSession {
|
||||
}
|
||||
});
|
||||
|
||||
let conn = receiver.recv().await.ok_or(eyre::anyhow!("could not receive ok signal from dagger-engine"))?;
|
||||
let conn = receiver.recv().await.ok_or(eyre::anyhow!(
|
||||
"could not receive ok signal from dagger-engine"
|
||||
))?;
|
||||
|
||||
Ok((conn, proc))
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{copy, Read, Write},
|
||||
io::{copy, Write},
|
||||
os::unix::prelude::PermissionsExt,
|
||||
path::PathBuf,
|
||||
};
|
||||
@@ -27,6 +27,7 @@ impl Platform {
|
||||
let normalize_arch = match arch.as_str() {
|
||||
"x86_64" => "amd64",
|
||||
"aarch" => "arm64",
|
||||
"aarch64" => "arm64",
|
||||
arch => arch,
|
||||
};
|
||||
|
||||
@@ -129,7 +130,8 @@ impl Downloader {
|
||||
|
||||
if !cli_bin_path.exists() {
|
||||
cli_bin_path = self
|
||||
.download(cli_bin_path).await
|
||||
.download(cli_bin_path)
|
||||
.await
|
||||
.context("failed to download CLI from archive")?;
|
||||
}
|
||||
|
||||
@@ -137,6 +139,10 @@ impl Downloader {
|
||||
if let Ok(entry) = file {
|
||||
let path = entry.path();
|
||||
if path != cli_bin_path {
|
||||
println!(
|
||||
"deleting client: path: {:?} vs cli_bin_path: {:?}",
|
||||
path, cli_bin_path
|
||||
);
|
||||
std::fs::remove_file(path)?;
|
||||
}
|
||||
}
|
||||
@@ -199,8 +205,6 @@ impl Downloader {
|
||||
hasher.update(&bytes);
|
||||
let res = hasher.finalize();
|
||||
|
||||
println!("{}", hex::encode(&res));
|
||||
|
||||
if archive_url.ends_with(".zip") {
|
||||
// TODO: Nothing for now
|
||||
todo!()
|
||||
@@ -219,8 +223,6 @@ impl Downloader {
|
||||
let mut entry = entry?;
|
||||
let path = entry.path()?;
|
||||
|
||||
println!("path: {:?}", path);
|
||||
|
||||
if path.ends_with("dagger") {
|
||||
copy(&mut entry, output)?;
|
||||
|
||||
@@ -238,7 +240,11 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn download() {
|
||||
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().await.unwrap();
|
||||
let cli_path = Downloader::new("0.3.10".into())
|
||||
.unwrap()
|
||||
.get_cli()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
Some("dagger-0.3.10"),
|
||||
|
@@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
use crate::DAGGER_ENGINE_VERSION;
|
||||
use crate::{
|
||||
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
|
||||
};
|
||||
@@ -12,37 +11,20 @@ impl Engine {
|
||||
}
|
||||
|
||||
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
||||
let cli = Downloader::new("0.3.12".into())?.get_cli().await?;
|
||||
let cli = Downloader::new(DAGGER_ENGINE_VERSION.into())?
|
||||
.get_cli()
|
||||
.await?;
|
||||
|
||||
let cli_session = CliSession::new();
|
||||
|
||||
Ok(cli_session.connect(cfg, &cli).await?)
|
||||
}
|
||||
|
||||
pub async fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
||||
pub async fn start(
|
||||
&self,
|
||||
cfg: &Config,
|
||||
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
||||
// TODO: Add from existing session as well
|
||||
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,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SchemaDirectivesArgs {
|
||||
@@ -257,6 +258,7 @@ pub struct SchemaDirectives {
|
||||
pub args: Option<Vec<Option<SchemaDirectivesArgs>>>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
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 config;
|
||||
pub mod connect_params;
|
||||
|
@@ -12,13 +12,3 @@ pub async fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
||||
|
||||
Ok(schema)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::get_schema;
|
||||
|
||||
#[tokio::test]
|
||||
async fn can_get_schema() {
|
||||
let _ = get_schema().await.unwrap();
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,115 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to
|
||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v0.2.16 (2023-03-10)
|
||||
|
||||
### Chore
|
||||
|
||||
- <csr-id-e642778d9028726dfb07217814e15ad1dd3b83f2/> fix tasks
|
||||
|
||||
### Documentation
|
||||
|
||||
- <csr-id-13b7805e7e6fcf47e0a1318adcc25b4ab773a3c9/> fix missing await in connect
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-7133bfae9508bc5977548e373c49342a1248d6e4/> with dagger-engine v.0.4.0
|
||||
- <csr-id-4381af029521c2cbac9325278d261db79a994657/> add tests to sdk
|
||||
- <csr-id-5f9b3a19c0ab6988bc335b020052074f3f101305/> set internal warnings as errors
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-ecca036bc644fee93fbcb69bf6da9f29169e473e/> fix builder pattern to actually work with default values
|
||||
In previous versions the builder pattern required all values to be set.
|
||||
This has not been fixed, so that default values are allowed.
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 6 commits contributed to the release over the course of 13 calendar days.
|
||||
- 13 days passed between releases.
|
||||
- 6 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- fix tasks ([`e642778`](https://github.com/kjuulh/dagger-rs/commit/e642778d9028726dfb07217814e15ad1dd3b83f2))
|
||||
- with dagger-engine v.0.4.0 ([`7133bfa`](https://github.com/kjuulh/dagger-rs/commit/7133bfae9508bc5977548e373c49342a1248d6e4))
|
||||
- fix missing await in connect ([`13b7805`](https://github.com/kjuulh/dagger-rs/commit/13b7805e7e6fcf47e0a1318adcc25b4ab773a3c9))
|
||||
- add tests to sdk ([`4381af0`](https://github.com/kjuulh/dagger-rs/commit/4381af029521c2cbac9325278d261db79a994657))
|
||||
- set internal warnings as errors ([`5f9b3a1`](https://github.com/kjuulh/dagger-rs/commit/5f9b3a19c0ab6988bc335b020052074f3f101305))
|
||||
- fix builder pattern to actually work with default values ([`ecca036`](https://github.com/kjuulh/dagger-rs/commit/ecca036bc644fee93fbcb69bf6da9f29169e473e))
|
||||
</details>
|
||||
|
||||
## v0.2.15 (2023-02-24)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f/> update to dagger-v0.3.13
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-e578b0e371e13bc30ada793b7cd6ebe75ba83a07/> set deserialize on enums as well
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 3 commits contributed to the release.
|
||||
- 2 days passed between releases.
|
||||
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-core v0.2.7, dagger-sdk v0.2.15 ([`6a9a560`](https://github.com/kjuulh/dagger-rs/commit/6a9a560cdca097abf23371d44599a2f1b726ae7f))
|
||||
- set deserialize on enums as well ([`e578b0e`](https://github.com/kjuulh/dagger-rs/commit/e578b0e371e13bc30ada793b7cd6ebe75ba83a07))
|
||||
- update to dagger-v0.3.13 ([`3e8ca8d`](https://github.com/kjuulh/dagger-rs/commit/3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f))
|
||||
</details>
|
||||
|
||||
## v0.2.14 (2023-02-22)
|
||||
|
||||
<csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/>
|
||||
|
||||
### Chore
|
||||
|
||||
- <csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/> fix whitespace
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 2 commits contributed to the release.
|
||||
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-sdk v0.2.14 ([`88b055c`](https://github.com/kjuulh/dagger-rs/commit/88b055cb47d3d474e2c37d8fa8259df5faad9da5))
|
||||
- fix whitespace ([`e331ca0`](https://github.com/kjuulh/dagger-rs/commit/e331ca003546f4ebe00f33b65c3b45c6b0586514))
|
||||
</details>
|
||||
|
||||
## v0.2.13 (2023-02-22)
|
||||
|
||||
<csr-id-7c3654d276bb5f66e692a210cb60cdf46b19e226/>
|
||||
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
|
||||
|
||||
### Chore
|
||||
|
||||
- <csr-id-7c3654d276bb5f66e692a210cb60cdf46b19e226/> ran clippy
|
||||
@@ -25,7 +132,7 @@ and this project adheres to
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 6 commits contributed to the release over the course of 2 calendar days.
|
||||
- 7 commits contributed to the release over the course of 2 calendar days.
|
||||
- 2 days passed between releases.
|
||||
- 4 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
@@ -37,6 +144,7 @@ and this project adheres to
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-codegen v0.2.8, dagger-sdk v0.2.13 ([`456f483`](https://github.com/kjuulh/dagger-rs/commit/456f48389b5514d7f743a600a7732fb02dd87418))
|
||||
- ran clippy ([`7c3654d`](https://github.com/kjuulh/dagger-rs/commit/7c3654d276bb5f66e692a210cb60cdf46b19e226))
|
||||
- with clone ([`266ad32`](https://github.com/kjuulh/dagger-rs/commit/266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c))
|
||||
- Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 ([`7179f8b`](https://github.com/kjuulh/dagger-rs/commit/7179f8b598ef04e62925e39d3f55740253c01686))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.13"
|
||||
version = "0.2.16"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -11,7 +11,7 @@ publish = true
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dagger-core = { path = "../dagger-core", version = "^0.2.6" }
|
||||
dagger-core = { path = "../dagger-core", version = "^0.2.8" }
|
||||
|
||||
base64 = "0.21.0"
|
||||
eyre = "0.6.8"
|
||||
|
@@ -27,7 +27,7 @@ cargo add dagger-sdk
|
||||
```rust
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let version = client
|
||||
.container()
|
||||
@@ -46,9 +46,3 @@ And run it like a normal application:
|
||||
```bash
|
||||
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.
|
||||
|
@@ -35,7 +35,8 @@ async fn main() -> eyre::Result<()> {
|
||||
.container()
|
||||
.from("nginx")
|
||||
.with_directory("/usr/share/nginx/html", build_dir.id().await?)
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
|
||||
.await?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -13,7 +13,8 @@ async fn main() -> eyre::Result<()> {
|
||||
let ref_ = client
|
||||
.container()
|
||||
.build(context_dir.id().await?)
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
|
||||
.await?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -6,7 +6,8 @@ async fn main() -> eyre::Result<()> {
|
||||
.container()
|
||||
.from("golang:1.19")
|
||||
.with_exec(vec!["go", "version"])
|
||||
.stdout().await?;
|
||||
.stdout()
|
||||
.await?;
|
||||
|
||||
println!("Hello from Dagger and {}", version.trim());
|
||||
|
||||
|
@@ -39,7 +39,8 @@ async fn main() -> eyre::Result<()> {
|
||||
"/usr/share/nginx/html",
|
||||
client.host().directory(output).id().await?,
|
||||
)
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
|
||||
.await?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -23,7 +23,8 @@ async fn main() -> eyre::Result<()> {
|
||||
|
||||
let out = runner
|
||||
.with_exec(vec!["npm", "test", "--", "--watchAll=false"])
|
||||
.stderr().await?;
|
||||
.stderr()
|
||||
.await?;
|
||||
|
||||
println!("{}", out);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
mod client;
|
||||
mod gen;
|
||||
mod querybuilder;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_example_container() {
|
||||
@@ -19,3 +20,99 @@ async fn test_example_container() {
|
||||
|
||||
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