mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
6 Commits
dagger-sdk
...
dagger-sdk
Author | SHA1 | Date | |
---|---|---|---|
82de43aa91
|
|||
f40ba9b403 | |||
75bc17e57d | |||
45d6462037
|
|||
04990247ba
|
|||
978ede68ae |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -5,6 +5,31 @@ 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.10 (2023-02-20)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-75bc17e57db222492c6ffd2dfe80208d2bda75c9/> Fix async panic on blocking #19
|
||||
Replaced internal threads with tokio spawn functions
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 1 commit 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**
|
||||
- Fix async panic on blocking #19 ([`75bc17e`](https://github.com/kjuulh/dagger-rs/commit/75bc17e57db222492c6ffd2dfe80208d2bda75c9))
|
||||
</details>
|
||||
|
||||
## v0.2.9 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
73
Cargo.lock
generated
73
Cargo.lock
generated
@@ -114,8 +114,9 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"dagger-sdk 0.2.6",
|
||||
"dagger-sdk 0.2.8",
|
||||
"eyre",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -245,10 +246,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-codegen"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"dagger-core 0.2.2",
|
||||
"dagger-core 0.2.3",
|
||||
"eyre",
|
||||
"genco",
|
||||
"itertools",
|
||||
@@ -257,28 +258,6 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dagger-core"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"flate2",
|
||||
"genco",
|
||||
"graphql-introspection-query",
|
||||
"graphql_client",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"platform-info",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tar",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dagger-core"
|
||||
version = "0.2.2"
|
||||
@@ -304,13 +283,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dagger-rs"
|
||||
version = "0.2.9"
|
||||
name = "dagger-core"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"dagger-codegen",
|
||||
"dagger-core 0.2.2",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"flate2",
|
||||
@@ -326,16 +302,43 @@ dependencies = [
|
||||
"sha2",
|
||||
"tar",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dagger-rs"
|
||||
version = "0.2.10"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"dagger-codegen",
|
||||
"dagger-core 0.2.3",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"flate2",
|
||||
"genco",
|
||||
"graphql-introspection-query",
|
||||
"graphql_client",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"platform-info",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tar",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.6"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "654625e954f59d70eb897bb681936c3e8b69c5f6e528f85c0b307554883db63f"
|
||||
checksum = "e90636d5b74ce8a62e8507a8d075c4d997c3123a1709596d0f97c3070f993b2d"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dagger-core 0.2.2",
|
||||
"derive_builder",
|
||||
"eyre",
|
||||
"futures",
|
||||
@@ -347,10 +350,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.7"
|
||||
version = "0.2.9"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core 0.2.2",
|
||||
"dagger-core 0.2.3",
|
||||
"derive_builder",
|
||||
"eyre",
|
||||
"futures",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-rs"
|
||||
version = "0.2.9"
|
||||
version = "0.2.10"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -20,7 +20,7 @@ members = [
|
||||
|
||||
[dependencies]
|
||||
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.3" }
|
||||
dagger-core = { path = "crates/dagger-core", version = "^0.2.2" }
|
||||
dagger-core = { path = "crates/dagger-core", version = "^0.2.3" }
|
||||
|
||||
clap = "4.1.6"
|
||||
dirs = "4.0.0"
|
||||
@@ -42,3 +42,4 @@ sha2 = "0.10.6"
|
||||
tar = "0.4.38"
|
||||
tempfile = "3.3.0"
|
||||
color-eyre = "0.6.2"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
@@ -10,3 +10,4 @@ clap = "4.1.6"
|
||||
color-eyre = "0.6.2"
|
||||
dagger-sdk = "0.2.6"
|
||||
eyre = "0.6.8"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
@@ -2,7 +2,8 @@ use std::sync::Arc;
|
||||
|
||||
use dagger_sdk::{Container, HostDirectoryOpts, Query};
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
color_eyre::install().unwrap();
|
||||
|
||||
let matches = clap::Command::new("ci")
|
||||
@@ -15,10 +16,10 @@ fn main() -> eyre::Result<()> {
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("pr", _)) => {
|
||||
let base = select_base_image(client.clone())?;
|
||||
return validate_pr(client, base);
|
||||
let base = select_base_image(client.clone()).await?;
|
||||
return validate_pr(client, base).await;
|
||||
}
|
||||
Some(("release", subm)) => return release(client, subm),
|
||||
Some(("release", subm)) => return release(client, subm).await,
|
||||
Some(_) => {
|
||||
panic!("invalid subcommand selected!")
|
||||
}
|
||||
@@ -28,7 +29,7 @@ fn main() -> eyre::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
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(
|
||||
".",
|
||||
HostDirectoryOpts {
|
||||
@@ -40,7 +41,7 @@ fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyr
|
||||
.container()
|
||||
.from("rust:latest")
|
||||
.with_workdir("app")
|
||||
.with_mounted_directory("/app/", src_dir.id()?);
|
||||
.with_mounted_directory("/app/", src_dir.id().await?);
|
||||
|
||||
let container = base_image
|
||||
.with_exec(vec!["cargo", "install", "cargo-smart-release"])
|
||||
@@ -53,7 +54,7 @@ fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyr
|
||||
"dagger-rs",
|
||||
"dagger-sdk",
|
||||
]);
|
||||
let exit = container.exit_code()?;
|
||||
let exit = container.exit_code().await?;
|
||||
if exit != 0 {
|
||||
eyre::bail!("container failed with non-zero exit code");
|
||||
}
|
||||
@@ -63,7 +64,7 @@ fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyr
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
let cargo_dir = client.host().directory_opts(
|
||||
".",
|
||||
HostDirectoryOpts {
|
||||
@@ -121,16 +122,16 @@ fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
.with_env_variable("SCCACHE_BUCKET", "sccache")
|
||||
.with_env_variable("SCCACHE_REGION", "auto")
|
||||
.with_env_variable("SCCACHE_ENDPOINT", "https://api-minio.front.kjuulh.io")
|
||||
.with_mounted_cache("~/.cargo/bin", cache_cargo_bin.id()?)
|
||||
.with_mounted_cache("~/.cargo/registry/index", cache_cargo_bin.id()?)
|
||||
.with_mounted_cache("~/.cargo/registry/cache", cache_cargo_bin.id()?)
|
||||
.with_mounted_cache("~/.cargo/git/db", cache_cargo_bin.id()?)
|
||||
.with_mounted_cache("target/", cache_cargo_bin.id()?)
|
||||
.with_mounted_cache("~/.cargo/bin", cache_cargo_bin.id().await?)
|
||||
.with_mounted_cache("~/.cargo/registry/index", cache_cargo_bin.id().await?)
|
||||
.with_mounted_cache("~/.cargo/registry/cache", cache_cargo_bin.id().await?)
|
||||
.with_mounted_cache("~/.cargo/git/db", cache_cargo_bin.id().await?)
|
||||
.with_mounted_cache("target/", cache_cargo_bin.id().await?)
|
||||
.with_exec(vec!["cargo", "install", "cargo-chef"]);
|
||||
|
||||
let recipe = base_image
|
||||
.with_mounted_directory(".", cargo_dir.id()?)
|
||||
.with_mounted_cache("~/.cargo/.package-cache", cache_cargo_index_dir.id()?)
|
||||
.with_mounted_directory(".", cargo_dir.id().await?)
|
||||
.with_mounted_cache("~/.cargo/.package-cache", cache_cargo_index_dir.id().await?)
|
||||
.with_exec(vec![
|
||||
"cargo",
|
||||
"chef",
|
||||
@@ -141,7 +142,7 @@ fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
.file("/app/recipe.json");
|
||||
|
||||
let builder_start = base_image
|
||||
.with_mounted_file("/app/recipe.json", recipe.id()?)
|
||||
.with_mounted_file("/app/recipe.json", recipe.id().await?)
|
||||
.with_exec(vec![
|
||||
"cargo",
|
||||
"chef",
|
||||
@@ -151,23 +152,23 @@ fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
"--recipe-path",
|
||||
"recipe.json",
|
||||
])
|
||||
.with_mounted_cache("/app/", cache_cargo_deps.id()?)
|
||||
.with_mounted_directory("/app/", src_dir.id()?)
|
||||
.with_mounted_cache("/app/", cache_cargo_deps.id().await?)
|
||||
.with_mounted_directory("/app/", src_dir.id().await?)
|
||||
.with_exec(vec!["cargo", "build", "--all", "--release"]);
|
||||
|
||||
return Ok(builder_start);
|
||||
}
|
||||
|
||||
fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
let src_dir = get_dependencies(client.clone());
|
||||
async fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
|
||||
let src_dir = get_dependencies(client.clone()).await;
|
||||
|
||||
src_dir
|
||||
}
|
||||
|
||||
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()?;
|
||||
let exit = container.exit_code().await?;
|
||||
if exit != 0 {
|
||||
eyre::bail!("container failed with non-zero exit code");
|
||||
}
|
||||
|
@@ -5,6 +5,53 @@ 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.5 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4/> add documentation strings
|
||||
- <csr-id-9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598/> Use async runtime instead of blocking.
|
||||
Default to using async runtime instead of blocking. I.e.
|
||||
|
||||
```rust
|
||||
fn main() -> eyre::Result<()> {
|
||||
// ...
|
||||
|
||||
client.container().from("rust").publish("somewhere")?;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
// to
|
||||
|
||||
async fn main() -> eyre::Result<()> {
|
||||
// ...
|
||||
|
||||
client.container().from("rust").publish("somewhere").await?;
|
||||
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 2 commits contributed to the release.
|
||||
- 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**
|
||||
- add documentation strings ([`978ede6`](https://github.com/kjuulh/dagger-rs/commit/978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4))
|
||||
- Use async runtime instead of blocking. ([`9be6f43`](https://github.com/kjuulh/dagger-rs/commit/9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598))
|
||||
</details>
|
||||
|
||||
## v0.2.4 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
@@ -51,7 +98,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 5 commits contributed to the release.
|
||||
- 6 commits contributed to the release.
|
||||
- 5 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
@@ -62,6 +109,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-sdk v0.2.5, dagger-codegen v0.2.4 ([`f727318`](https://github.com/kjuulh/dagger-rs/commit/f72731807d8358fdb3d80432136b7a08bb7b1773))
|
||||
- cargo clippy ([`c627595`](https://github.com/kjuulh/dagger-rs/commit/c627595fd2695e236924175d137c42f1480ccd6b))
|
||||
- without Some in _opts functions ([`f29ff83`](https://github.com/kjuulh/dagger-rs/commit/f29ff836cfd72d5e051ca6a71a230ba1e9933091))
|
||||
- with _opts methods ([`9762da8`](https://github.com/kjuulh/dagger-rs/commit/9762da895a164e30c5dc60e89a83e934ceae47ab))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-codegen"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
|
@@ -64,9 +64,11 @@ pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
.pipe(|t| &t.type_ref)
|
||||
.pipe(|t| render_output_type(funcs, t));
|
||||
|
||||
if let Some((args, true)) = args {
|
||||
if let Some((args, desc, true)) = args {
|
||||
let required_args = format_required_function_args(funcs, field);
|
||||
Some(quote! {
|
||||
$(field.description.pipe(|d| format_struct_comment(d)))
|
||||
$(&desc)
|
||||
$(&signature)(
|
||||
$(required_args)
|
||||
) -> $(output_type.as_ref()) {
|
||||
@@ -77,6 +79,8 @@ pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
$(render_execution(funcs, field))
|
||||
}
|
||||
|
||||
$(field.description.pipe(|d| format_struct_comment(d)))
|
||||
$(&desc)
|
||||
$(&signature)_opts$(lifecycle)(
|
||||
$args
|
||||
) -> $(output_type) {
|
||||
@@ -90,8 +94,10 @@ pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
})
|
||||
} else {
|
||||
Some(quote! {
|
||||
$(field.description.pipe(|d| format_struct_comment(d)))
|
||||
$(if let Some((_, desc, _)) = &args => $desc)
|
||||
$(signature)(
|
||||
$(if let Some((args, _)) = args => $args)
|
||||
$(if let Some((args, _, _)) = &args => $args)
|
||||
) -> $(output_type) {
|
||||
let mut query = self.selection.select($(quoted(field.name.as_ref())));
|
||||
|
||||
@@ -268,7 +274,8 @@ fn format_function_args(
|
||||
funcs: &CommonFunctions,
|
||||
field: &FullTypeFields,
|
||||
lifecycle: Option<&rust::Tokens>,
|
||||
) -> Option<(rust::Tokens, bool)> {
|
||||
) -> Option<(rust::Tokens, rust::Tokens, bool)> {
|
||||
let mut argument_description = Vec::new();
|
||||
if let Some(args) = field.args.as_ref() {
|
||||
let args = args
|
||||
.into_iter()
|
||||
@@ -281,6 +288,18 @@ fn format_function_args(
|
||||
let t = funcs.format_input_type(&s.input_value.type_);
|
||||
let n = format_struct_name(&s.input_value.name);
|
||||
|
||||
if let Some(desc) = s.input_value.description.as_ref().and_then(|d| {
|
||||
if d != "" {
|
||||
Some(write_comment_line(&format!("* `{n}` - {}", d)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}) {
|
||||
argument_description.push(quote! {
|
||||
$(desc)
|
||||
});
|
||||
}
|
||||
|
||||
Some(quote! {
|
||||
$(n): $(t),
|
||||
})
|
||||
@@ -294,15 +313,34 @@ fn format_function_args(
|
||||
};
|
||||
|
||||
if type_field_has_optional(field) {
|
||||
let field_name = field_options_struct_name(field);
|
||||
argument_description.push(quote! {
|
||||
$(field_name.pipe(|_| write_comment_line(&format!("* `opt` - optional argument, see inner type for documentation, use <func>_opts to use"))))
|
||||
});
|
||||
|
||||
let description = quote! {
|
||||
$(if argument_description.len() > 0 => $(format!("/// ")))
|
||||
$(if argument_description.len() > 0 => $(format!("/// # Arguments")))
|
||||
$(if argument_description.len() > 0 => $(format!("/// ")))
|
||||
$(for arg_desc in argument_description join ($['\r']) => $arg_desc)
|
||||
};
|
||||
|
||||
Some((
|
||||
quote! {
|
||||
$(required_args)
|
||||
opts: $(field_options_struct_name(field))$(lifecycle)
|
||||
opts: $(field_name)$(lifecycle)
|
||||
},
|
||||
description,
|
||||
true,
|
||||
))
|
||||
} else {
|
||||
Some((required_args, false))
|
||||
let description = quote! {
|
||||
$(if argument_description.len() > 0 => $(format!("/// ")))
|
||||
$(if argument_description.len() > 0 => $(format!("/// # Arguments")))
|
||||
$(if argument_description.len() > 0 => $(format!("/// ")))
|
||||
$(for arg_desc in argument_description join ($['\r']) => $arg_desc)
|
||||
};
|
||||
Some((required_args, description, false))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
@@ -358,3 +396,36 @@ pub fn format_optional_args(
|
||||
.pipe(|t| render_optional_field_args(funcs, t))
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub fn write_comment_line(content: &str) -> Option<rust::Tokens> {
|
||||
let cnt = content.trim();
|
||||
if cnt == "" {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut tokens = rust::Tokens::new();
|
||||
|
||||
for line in content.split('\n') {
|
||||
tokens.append(format!("/// {}", line.trim()));
|
||||
tokens.push();
|
||||
}
|
||||
|
||||
Some(tokens)
|
||||
}
|
||||
|
||||
pub fn format_struct_comment(desc: &str) -> Option<rust::Tokens> {
|
||||
let lines = desc.trim().split("\n");
|
||||
|
||||
let formatted_lines = lines
|
||||
.into_iter()
|
||||
.map(write_comment_line)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if formatted_lines.len() > 0 {
|
||||
Some(quote! {
|
||||
$(for line in formatted_lines join($['\r']) => $line)
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ use itertools::Itertools;
|
||||
use crate::functions::{type_ref_is_optional, CommonFunctions};
|
||||
use crate::rust::functions::{
|
||||
field_options_struct_name, format_function, format_name, format_optional_args,
|
||||
format_struct_name,
|
||||
format_struct_comment, format_struct_name,
|
||||
};
|
||||
use crate::utility::OptionExt;
|
||||
|
||||
@@ -85,6 +85,7 @@ pub fn render_optional_field_args(
|
||||
contains_lifetime = true;
|
||||
}
|
||||
quote! {
|
||||
$(a.description.pipe(|d| format_struct_comment(d)))
|
||||
#[builder(setter(into, strip_option))]
|
||||
pub $(format_struct_name(&a.name)): Option<$(type_)>,
|
||||
}
|
||||
|
@@ -5,11 +5,12 @@ 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.2 (2023-02-19)
|
||||
## v0.2.3 (2023-02-20)
|
||||
|
||||
### New Features
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-6e5f4074329ab0462445b31d4153f8497c483438/> update to dagger v0.3.12
|
||||
- <csr-id-75bc17e57db222492c6ffd2dfe80208d2bda75c9/> Fix async panic on blocking #19
|
||||
Replaced internal threads with tokio spawn functions
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
@@ -26,6 +27,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Fix async panic on blocking #19 ([`75bc17e`](https://github.com/kjuulh/dagger-rs/commit/75bc17e57db222492c6ffd2dfe80208d2bda75c9))
|
||||
</details>
|
||||
|
||||
## v0.2.2 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-6e5f4074329ab0462445b31d4153f8497c483438/> update to dagger v0.3.12
|
||||
|
||||
### 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-core v0.2.2, dagger-codegen v0.2.2, dagger-rs v0.2.8 ([`1638f15`](https://github.com/kjuulh/dagger-rs/commit/1638f15fba9d16512e8452f87b908d6dce417cd9))
|
||||
- update to dagger v0.3.12 ([`6e5f407`](https://github.com/kjuulh/dagger-rs/commit/6e5f4074329ab0462445b31d4153f8497c483438))
|
||||
</details>
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-core"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -29,3 +29,4 @@ serde_json = "1.0.93"
|
||||
sha2 = "0.10.6"
|
||||
tar = "0.4.38"
|
||||
tempfile = "3.3.0"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
@@ -3,7 +3,7 @@ use std::{
|
||||
io::{BufRead, BufReader},
|
||||
path::PathBuf,
|
||||
process::{Child, Stdio},
|
||||
sync::{mpsc::sync_channel, Arc},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use crate::{config::Config, connect_params::ConnectParams};
|
||||
@@ -20,12 +20,12 @@ impl CliSession {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn connect(
|
||||
pub async fn connect(
|
||||
&self,
|
||||
config: &Config,
|
||||
cli_path: &PathBuf,
|
||||
) -> eyre::Result<(ConnectParams, Child)> {
|
||||
self.inner.connect(config, cli_path)
|
||||
self.inner.connect(config, cli_path).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ impl CliSession {
|
||||
struct InnerCliSession {}
|
||||
|
||||
impl InnerCliSession {
|
||||
pub fn connect(
|
||||
pub async fn connect(
|
||||
&self,
|
||||
config: &Config,
|
||||
cli_path: &PathBuf,
|
||||
) -> eyre::Result<(ConnectParams, Child)> {
|
||||
let proc = self.start(config, cli_path)?;
|
||||
let params = self.get_conn(proc)?;
|
||||
let params = self.get_conn(proc).await?;
|
||||
Ok(params)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ impl InnerCliSession {
|
||||
return Ok(proc);
|
||||
}
|
||||
|
||||
fn get_conn(
|
||||
async fn get_conn(
|
||||
&self,
|
||||
mut proc: std::process::Child,
|
||||
) -> eyre::Result<(ConnectParams, std::process::Child)> {
|
||||
@@ -84,14 +84,14 @@ impl InnerCliSession {
|
||||
.take()
|
||||
.ok_or(eyre::anyhow!("could not acquire stderr from child process"))?;
|
||||
|
||||
let (sender, receiver) = sync_channel(1);
|
||||
let (sender, mut receiver) = tokio::sync::mpsc::channel(1);
|
||||
|
||||
std::thread::spawn(move || {
|
||||
tokio::spawn(async move {
|
||||
let stdout_bufr = BufReader::new(stdout);
|
||||
for line in stdout_bufr.lines() {
|
||||
let out = line.as_ref().unwrap();
|
||||
if let Ok(conn) = serde_json::from_str::<ConnectParams>(&out) {
|
||||
sender.send(conn).unwrap();
|
||||
sender.send(conn).await.unwrap();
|
||||
}
|
||||
if let Ok(line) = line {
|
||||
println!("dagger: {}", line);
|
||||
@@ -99,7 +99,7 @@ impl InnerCliSession {
|
||||
}
|
||||
});
|
||||
|
||||
std::thread::spawn(|| {
|
||||
tokio::spawn(async move {
|
||||
let stderr_bufr = BufReader::new(stderr);
|
||||
for line in stderr_bufr.lines() {
|
||||
if let Ok(line) = line {
|
||||
@@ -109,7 +109,7 @@ impl InnerCliSession {
|
||||
}
|
||||
});
|
||||
|
||||
let conn = receiver.recv()?;
|
||||
let conn = receiver.recv().await.ok_or(eyre::anyhow!("could not receive ok signal from dagger-engine"))?;
|
||||
|
||||
Ok((conn, proc))
|
||||
}
|
||||
|
@@ -119,7 +119,7 @@ impl Downloader {
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
pub fn get_cli(&self) -> eyre::Result<PathBuf> {
|
||||
pub async fn get_cli(&self) -> eyre::Result<PathBuf> {
|
||||
let version = &self.version;
|
||||
let mut cli_bin_path = self.cache_dir()?;
|
||||
cli_bin_path.push(format!("{CLI_BIN_PREFIX}{version}"));
|
||||
@@ -129,7 +129,7 @@ impl Downloader {
|
||||
|
||||
if !cli_bin_path.exists() {
|
||||
cli_bin_path = self
|
||||
.download(cli_bin_path)
|
||||
.download(cli_bin_path).await
|
||||
.context("failed to download CLI from archive")?;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ impl Downloader {
|
||||
Ok(cli_bin_path)
|
||||
}
|
||||
|
||||
fn download(&self, path: PathBuf) -> eyre::Result<PathBuf> {
|
||||
let expected_checksum = self.expected_checksum()?;
|
||||
async fn download(&self, path: PathBuf) -> eyre::Result<PathBuf> {
|
||||
let expected_checksum = self.expected_checksum().await?;
|
||||
|
||||
let mut bytes = vec![];
|
||||
let actual_hash = self.extract_cli_archive(&mut bytes)?;
|
||||
@@ -165,15 +165,15 @@ impl Downloader {
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
fn expected_checksum(&self) -> eyre::Result<String> {
|
||||
async fn expected_checksum(&self) -> eyre::Result<String> {
|
||||
let archive_url = &self.archive_url();
|
||||
let archive_path = PathBuf::from(&archive_url);
|
||||
let archive_name = archive_path
|
||||
.file_name()
|
||||
.ok_or(eyre::anyhow!("could not get file_name from archive_url"))?;
|
||||
let resp = reqwest::blocking::get(self.checksum_url())?;
|
||||
let resp = reqwest::get(self.checksum_url()).await?;
|
||||
let resp = resp.error_for_status()?;
|
||||
for line in resp.text()?.lines() {
|
||||
for line in resp.text().await?.lines() {
|
||||
let mut content = line.split_whitespace();
|
||||
let checksum = content
|
||||
.next()
|
||||
@@ -240,9 +240,9 @@ impl Downloader {
|
||||
mod test {
|
||||
use super::Downloader;
|
||||
|
||||
#[test]
|
||||
fn download() {
|
||||
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().unwrap();
|
||||
#[tokio::test]
|
||||
async fn download() {
|
||||
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().await.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
Some("dagger-0.3.10"),
|
||||
|
@@ -11,17 +11,17 @@ impl Engine {
|
||||
Self {}
|
||||
}
|
||||
|
||||
fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
let cli = Downloader::new("0.3.12".into())?.get_cli()?;
|
||||
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
let cli = Downloader::new("0.3.12".into())?.get_cli().await?;
|
||||
|
||||
let cli_session = CliSession::new();
|
||||
|
||||
Ok(cli_session.connect(cfg, &cli)?)
|
||||
Ok(cli_session.connect(cfg, &cli).await?)
|
||||
}
|
||||
|
||||
pub fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
pub async fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
|
||||
// TODO: Add from existing session as well
|
||||
self.from_cli(cfg)
|
||||
self.from_cli(cfg).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ mod tests {
|
||||
use super::Engine;
|
||||
|
||||
// TODO: these tests potentially have a race condition
|
||||
#[test]
|
||||
fn engine_can_start() {
|
||||
#[tokio::test]
|
||||
async fn engine_can_start() {
|
||||
let engine = Engine::new();
|
||||
let params = engine.start(&Config::new(None, None, None, None)).unwrap();
|
||||
let params = engine.start(&Config::new(None, None, None, None)).await.unwrap();
|
||||
|
||||
assert_ne!(
|
||||
params.0,
|
||||
|
@@ -1,14 +1,14 @@
|
||||
use crate::introspection::IntrospectionResponse;
|
||||
use crate::{config::Config, engine::Engine, session::Session};
|
||||
|
||||
pub fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
||||
pub async fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
||||
let cfg = Config::new(None, None, None, None);
|
||||
|
||||
//TODO: Implement context for proc
|
||||
let (conn, _proc) = Engine::new().start(&cfg)?;
|
||||
let (conn, _proc) = Engine::new().start(&cfg).await?;
|
||||
let session = Session::new();
|
||||
let req_builder = session.start(&cfg, &conn)?;
|
||||
let schema = session.schema(req_builder)?;
|
||||
let schema = session.schema(req_builder).await?;
|
||||
|
||||
Ok(schema)
|
||||
}
|
||||
@@ -17,8 +17,8 @@ pub fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
||||
mod tests {
|
||||
use super::get_schema;
|
||||
|
||||
#[test]
|
||||
fn can_get_schema() {
|
||||
let _ = get_schema().unwrap();
|
||||
#[tokio::test]
|
||||
async fn can_get_schema() {
|
||||
let _ = get_schema().await.unwrap();
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use graphql_client::GraphQLQuery;
|
||||
use reqwest::{
|
||||
blocking::{Client, RequestBuilder},
|
||||
header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE},
|
||||
Client, RequestBuilder,
|
||||
};
|
||||
|
||||
use crate::{config::Config, connect_params::ConnectParams, introspection::IntrospectionResponse};
|
||||
@@ -37,14 +37,14 @@ impl Session {
|
||||
Ok(req_builder)
|
||||
}
|
||||
|
||||
pub fn schema(&self, req_builder: RequestBuilder) -> eyre::Result<IntrospectionResponse> {
|
||||
pub async fn schema(&self, req_builder: RequestBuilder) -> eyre::Result<IntrospectionResponse> {
|
||||
let request_body: graphql_client::QueryBody<()> = graphql_client::QueryBody {
|
||||
variables: (),
|
||||
query: introspection_query::QUERY,
|
||||
operation_name: introspection_query::OPERATION_NAME,
|
||||
};
|
||||
|
||||
let res = req_builder.json(&request_body).send()?;
|
||||
let res = req_builder.json(&request_body).send().await?;
|
||||
|
||||
if res.status().is_success() {
|
||||
// do nothing
|
||||
@@ -52,7 +52,7 @@ impl Session {
|
||||
return Err(eyre::anyhow!("server error!"));
|
||||
} else {
|
||||
let status = res.status();
|
||||
let error_message = match res.text() {
|
||||
let error_message = match res.text().await {
|
||||
Ok(msg) => match serde_json::from_str::<serde_json::Value>(&msg) {
|
||||
Ok(json) => {
|
||||
format!("HTTP {}\n{}", status, serde_json::to_string_pretty(&json)?)
|
||||
@@ -64,7 +64,7 @@ impl Session {
|
||||
return Err(eyre::anyhow!(error_message));
|
||||
}
|
||||
|
||||
let json: IntrospectionResponse = res.json()?;
|
||||
let json: IntrospectionResponse = res.json().await?;
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
|
@@ -5,6 +5,56 @@ 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.9 (2023-02-20)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-75bc17e57db222492c6ffd2dfe80208d2bda75c9/> Fix async panic on blocking #19
|
||||
Replaced internal threads with tokio spawn functions
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 1 commit 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**
|
||||
- Fix async panic on blocking #19 ([`75bc17e`](https://github.com/kjuulh/dagger-rs/commit/75bc17e57db222492c6ffd2dfe80208d2bda75c9))
|
||||
</details>
|
||||
|
||||
## v0.2.8 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4/> add documentation strings
|
||||
|
||||
### 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.8, dagger-codegen v0.2.5 ([`0499024`](https://github.com/kjuulh/dagger-rs/commit/04990247ba8e9d0555847f582fef14849dbedebf))
|
||||
- add documentation strings ([`978ede6`](https://github.com/kjuulh/dagger-rs/commit/978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4))
|
||||
</details>
|
||||
|
||||
## v0.2.7 (2023-02-19)
|
||||
|
||||
### Documentation
|
||||
@@ -18,21 +68,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
```rust
|
||||
fn main() -> eyre::Result<()> {
|
||||
// ...
|
||||
// ...
|
||||
|
||||
client.container().from("rust").publish("somewhere")?;
|
||||
client.container().from("rust").publish("somewhere")?;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
}
|
||||
|
||||
// to
|
||||
|
||||
async fn main() -> eyre::Result<()> {
|
||||
// ...
|
||||
// ...
|
||||
|
||||
client.container().from("rust").publish("somewhere").await?;
|
||||
client.container().from("rust").publish("somewhere").await?;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -40,7 +90,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
|
||||
|
||||
@@ -51,6 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-sdk v0.2.7 ([`a1887af`](https://github.com/kjuulh/dagger-rs/commit/a1887afc8b51f61491ba7f13c5e7a5b7619623c4))
|
||||
- change to await syntax ([`93f40b3`](https://github.com/kjuulh/dagger-rs/commit/93f40b356c48f14e910968516bed9487912095c1))
|
||||
- Use async runtime instead of blocking. ([`9be6f43`](https://github.com/kjuulh/dagger-rs/commit/9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598))
|
||||
</details>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.7"
|
||||
version = "0.2.9"
|
||||
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.2" }
|
||||
dagger-core = { path = "../dagger-core", version = "^0.2.3" }
|
||||
|
||||
base64 = "0.21.0"
|
||||
eyre = "0.6.8"
|
||||
|
@@ -2,7 +2,7 @@ use dagger_sdk::HostDirectoryOpts;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/build-the-application/app",
|
||||
|
@@ -2,7 +2,7 @@ use rand::Rng;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"./examples/caching/app",
|
||||
|
@@ -4,7 +4,7 @@ use rand::Rng;
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let context_dir = client
|
||||
.host()
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let version = client
|
||||
.container()
|
||||
|
@@ -3,7 +3,7 @@ use rand::Rng;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/publish-the-application/app",
|
||||
|
@@ -3,7 +3,7 @@ use rand::Rng;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
let output = "examples/publish-the-application/app/build";
|
||||
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
|
@@ -2,7 +2,7 @@ use dagger_sdk::HostDirectoryOpts;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/test-the-application/app",
|
||||
|
@@ -13,9 +13,9 @@ use crate::querybuilder::query;
|
||||
|
||||
pub type DaggerConn = Arc<Query>;
|
||||
|
||||
pub fn connect() -> eyre::Result<DaggerConn> {
|
||||
pub async fn connect() -> eyre::Result<DaggerConn> {
|
||||
let cfg = Config::default();
|
||||
let (conn, proc) = DaggerEngine::new().start(&cfg)?;
|
||||
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
|
||||
|
||||
Ok(Arc::new(Query {
|
||||
conn,
|
||||
@@ -44,8 +44,8 @@ pub fn graphql_client(conn: &ConnectParams) -> gql_client::Client {
|
||||
mod test {
|
||||
use super::connect;
|
||||
|
||||
#[test]
|
||||
fn test_connect() {
|
||||
let _ = connect().unwrap();
|
||||
#[tokio::test]
|
||||
async fn test_connect() {
|
||||
let _ = connect().await.unwrap();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_example_container() {
|
||||
let client = connect().unwrap();
|
||||
let client = connect().await.unwrap();
|
||||
|
||||
let alpine = client.container().from("alpine:3.16.2");
|
||||
|
||||
|
@@ -13,11 +13,11 @@ impl Cli {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn execute(self, args: &[&str]) -> eyre::Result<()> {
|
||||
pub async fn execute(self, args: &[&str]) -> eyre::Result<()> {
|
||||
let matches = self.cmd.get_matches_from(args);
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args)?,
|
||||
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args).await?,
|
||||
_ => eyre::bail!("command missing"),
|
||||
}
|
||||
|
||||
|
@@ -17,12 +17,12 @@ impl GenerateCommand {
|
||||
clap::Command::new("generate").arg(Arg::new("output").long("output"))
|
||||
}
|
||||
|
||||
pub fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
|
||||
pub async fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
|
||||
let cfg = Config::default();
|
||||
let (conn, _proc) = Engine::new().start(&cfg)?;
|
||||
let (conn, _proc) = Engine::new().start(&cfg).await?;
|
||||
let session = Session::new();
|
||||
let req = session.start(&cfg, &conn)?;
|
||||
let schema = session.schema(req)?;
|
||||
let schema = session.schema(req).await?;
|
||||
let code = generate(
|
||||
schema.into_schema().schema.unwrap(),
|
||||
Arc::new(RustGenerator {}),
|
||||
|
@@ -3,14 +3,15 @@ use cli::Cli;
|
||||
pub mod cli;
|
||||
mod cli_generate;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
#[tokio::main]
|
||||
async fn main() -> eyre::Result<()> {
|
||||
color_eyre::install().unwrap();
|
||||
|
||||
let args = std::env::args();
|
||||
let args = args.collect::<Vec<String>>();
|
||||
let args = args.iter().map(|s| s.as_str()).collect::<Vec<&str>>();
|
||||
|
||||
Cli::new()?.execute(args.as_slice())?;
|
||||
Cli::new()?.execute(args.as_slice()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user