mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
8 Commits
dagger-sdk
...
v0.2.9
Author | SHA1 | Date | |
---|---|---|---|
92350306b3
|
|||
19ed6c267f | |||
de063eae85 | |||
5d66736990 | |||
9ada74960a | |||
90ab2e2b7d | |||
818ef6f74d | |||
691ecfbf52 |
1
.github/workflows/ci.yaml
vendored
1
.github/workflows/ci.yaml
vendored
@@ -8,6 +8,7 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
_EXPERIMENTAL_DAGGER_CACHE_CONFIG: type=gha;mode=max
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
15
.github/workflows/lint-pr.yml
vendored
Normal file
15
.github/workflows/lint-pr.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: "Lint PR"
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- synchronize
|
||||
jobs:
|
||||
main:
|
||||
name: Validate PR title
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: amannn/action-semantic-pull-request@v5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
26
CHANGELOG.md
26
CHANGELOG.md
@@ -5,6 +5,32 @@ 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-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-19ed6c267f779b72430422c463ceed553f6fc618/> re-export through lib.rs
|
||||
this means that you can now use dagger_sdk::connect() instead of
|
||||
dagger_sdk::client::connect();
|
||||
|
||||
### 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**
|
||||
- re-export through lib.rs ([`19ed6c2`](https://github.com/kjuulh/dagger-rs/commit/19ed6c267f779b72430422c463ceed553f6fc618))
|
||||
</details>
|
||||
|
||||
## v0.2.8 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
20
Cargo.lock
generated
20
Cargo.lock
generated
@@ -114,7 +114,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"dagger-sdk 0.2.1",
|
||||
"dagger-sdk 0.2.2",
|
||||
"eyre",
|
||||
]
|
||||
|
||||
@@ -245,7 +245,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-codegen"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"dagger-core 0.2.2",
|
||||
@@ -259,9 +259,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-core"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4805375918d0605477dac436be1c4d13a46c6f3fa1383b8eb624a31688a4b99b"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"dirs",
|
||||
@@ -284,6 +282,8 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "dagger-core"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7efe798e1fe0d882e335aab8928d5deaafb0d27869b69ec7e9e4686548e11753"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"dirs",
|
||||
@@ -305,7 +305,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-rs"
|
||||
version = "0.2.8"
|
||||
version = "0.2.9"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
@@ -330,12 +330,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91342638dfdcd44ca5d3a2cc1b962e3f2c0e461487e90fe62972ef31df74c061"
|
||||
checksum = "d1562df6d7d47fbb891331896ec9c04da1db129c1a9f073c40c33ab918f06e99"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core 0.2.1",
|
||||
"dagger-core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"eyre",
|
||||
"futures",
|
||||
"genco",
|
||||
@@ -348,7 +348,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core 0.2.2",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-rs"
|
||||
version = "0.2.8"
|
||||
version = "0.2.9"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -19,7 +19,7 @@ members = [
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.2" }
|
||||
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.3" }
|
||||
dagger-core = { path = "crates/dagger-core", version = "^0.2.2" }
|
||||
|
||||
clap = "4.1.6"
|
||||
|
@@ -21,7 +21,7 @@ See [dagger-sdk](./crates/dagger-sdk/README.md)
|
||||
- [x] Context
|
||||
- [x] Deserializer for nested response (bind)
|
||||
- [x] Add codegen to hook into querier
|
||||
- [ ] fix build / release cycle
|
||||
- [x] fix build / release cycle
|
||||
- [ ] general api stabilisation
|
||||
- [x] document usage
|
||||
- [ ] make async variant
|
||||
|
@@ -8,5 +8,5 @@ edition = "2021"
|
||||
[dependencies]
|
||||
clap = "4.1.6"
|
||||
color-eyre = "0.6.2"
|
||||
dagger-sdk = "0.2.1"
|
||||
dagger-sdk = "0.2.2"
|
||||
eyre = "0.6.8"
|
||||
|
@@ -5,6 +5,32 @@ 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.3 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-de063eae858eb3335d2558a57ee6a88689635200/> with return result instead of unwrap
|
||||
- <csr-id-5d667369900a47d3a6015cd3814c240bc5c54436/> remove unnecessary option returns
|
||||
|
||||
### 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**
|
||||
- with return result instead of unwrap ([`de063ea`](https://github.com/kjuulh/dagger-rs/commit/de063eae858eb3335d2558a57ee6a88689635200))
|
||||
- remove unnecessary option returns ([`5d66736`](https://github.com/kjuulh/dagger-rs/commit/5d667369900a47d3a6015cd3814c240bc5c54436))
|
||||
</details>
|
||||
|
||||
## v0.2.2 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
@@ -15,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 1 commit contributed to the release.
|
||||
- 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
|
||||
|
||||
@@ -26,6 +52,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.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-codegen"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
|
@@ -1,12 +1,12 @@
|
||||
use convert_case::{Case, Casing};
|
||||
use dagger_core::introspection::FullTypeFields;
|
||||
use dagger_core::introspection::{FullTypeFields, TypeRef};
|
||||
use genco::prelude::rust;
|
||||
use genco::quote;
|
||||
use genco::tokens::quoted;
|
||||
|
||||
use crate::functions::{
|
||||
type_field_has_optional, type_ref_is_list_of_objects, type_ref_is_object,
|
||||
type_ref_is_optional, CommonFunctions,
|
||||
type_field_has_optional, type_ref_is_list_of_objects, type_ref_is_object, type_ref_is_optional,
|
||||
CommonFunctions,
|
||||
};
|
||||
use crate::utility::OptionExt;
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
let output_type = field
|
||||
.type_
|
||||
.pipe(|t| &t.type_ref)
|
||||
.pipe(|t| funcs.format_output_type(t));
|
||||
.pipe(|t| render_output_type(funcs, t));
|
||||
|
||||
Some(quote! {
|
||||
$(signature)(
|
||||
@@ -67,7 +67,7 @@ fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
|
||||
let name = &s.input_value.name;
|
||||
|
||||
Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(n)).unwrap();
|
||||
query = query.arg($(quoted(name)), $(n));
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -98,7 +98,7 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
|
||||
|
||||
Some(quote! {
|
||||
if let Some($(&n)) = opts.$(&n) {
|
||||
query = query.arg($(quoted(name)), $(&n)).unwrap();
|
||||
query = query.arg($(quoted(name)), $(&n));
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -122,6 +122,20 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
|
||||
}
|
||||
}
|
||||
|
||||
fn render_output_type(funcs: &CommonFunctions, type_ref: &TypeRef) -> rust::Tokens {
|
||||
let output_type = funcs.format_output_type(type_ref);
|
||||
|
||||
if type_ref_is_object(type_ref) || type_ref_is_list_of_objects(type_ref) {
|
||||
return quote! {
|
||||
$(output_type)
|
||||
};
|
||||
}
|
||||
|
||||
quote! {
|
||||
eyre::Result<$output_type>
|
||||
}
|
||||
}
|
||||
|
||||
fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::Tokens {
|
||||
if let Some(true) = field.type_.pipe(|t| type_ref_is_object(&t.type_ref)) {
|
||||
let output_type = funcs.format_output_type(&field.type_.as_ref().unwrap().type_ref);
|
||||
@@ -163,7 +177,7 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
|
||||
let graphql_client = rust::import("crate::client", "graphql_client");
|
||||
|
||||
quote! {
|
||||
query.execute(&$graphql_client(&self.conn)).unwrap().unwrap()
|
||||
query.execute(&$graphql_client(&self.conn))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,36 @@ 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.3 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-19ed6c267f779b72430422c463ceed553f6fc618/> re-export through lib.rs
|
||||
this means that you can now use dagger_sdk::connect() instead of
|
||||
dagger_sdk::client::connect();
|
||||
- <csr-id-de063eae858eb3335d2558a57ee6a88689635200/> with return result instead of unwrap
|
||||
- <csr-id-5d667369900a47d3a6015cd3814c240bc5c54436/> remove unnecessary option returns
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 3 commits contributed to the release.
|
||||
- 3 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**
|
||||
- re-export through lib.rs ([`19ed6c2`](https://github.com/kjuulh/dagger-rs/commit/19ed6c267f779b72430422c463ceed553f6fc618))
|
||||
- with return result instead of unwrap ([`de063ea`](https://github.com/kjuulh/dagger-rs/commit/de063eae858eb3335d2558a57ee6a88689635200))
|
||||
- remove unnecessary option returns ([`5d66736`](https://github.com/kjuulh/dagger-rs/commit/5d667369900a47d3a6015cd3814c240bc5c54436))
|
||||
</details>
|
||||
|
||||
## v0.2.2 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
@@ -19,7 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 3 commits contributed to the release.
|
||||
- 4 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 +60,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.2 ([`e921ba1`](https://github.com/kjuulh/dagger-rs/commit/e921ba13638987ccf5beaa48c4be9be5fd879bd0))
|
||||
- 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))
|
||||
- fixed fmt errors ([`10bc6f3`](https://github.com/kjuulh/dagger-rs/commit/10bc6f3846b65cc82c2fb343d8cfe921784bef1b))
|
||||
- update to dagger v0.3.12 ([`6e5f407`](https://github.com/kjuulh/dagger-rs/commit/6e5f4074329ab0462445b31d4153f8497c483438))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use dagger_sdk::gen::HostDirectoryOpts;
|
||||
use dagger_sdk::HostDirectoryOpts;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/build-the-application/app".into(),
|
||||
@@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use dagger_sdk::gen::HostDirectoryOpts;
|
||||
use dagger_sdk::HostDirectoryOpts;
|
||||
use rand::Rng;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"./examples/caching/app".into(),
|
||||
@@ -12,12 +12,12 @@ fn main() -> eyre::Result<()> {
|
||||
}),
|
||||
);
|
||||
|
||||
let node_cache = client.cache_volume("node".into()).id();
|
||||
let node_cache = client.cache_volume("node".into()).id()?;
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?)
|
||||
.with_mounted_cache("/src/node_modules".into(), node_cache, None);
|
||||
|
||||
let runner = source
|
||||
@@ -43,11 +43,11 @@ fn main() -> eyre::Result<()> {
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id(), None)
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -1,10 +1,9 @@
|
||||
|
||||
use rand::Rng;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let context_dir = client
|
||||
.host()
|
||||
@@ -12,11 +11,11 @@ fn main() -> eyre::Result<()> {
|
||||
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.build(context_dir.id(), None)
|
||||
.build(context_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let version = client
|
||||
.container(None)
|
||||
.from("golang:1.19".into())
|
||||
.with_exec(vec!["go".into(), "version".into()], None)
|
||||
.stdout();
|
||||
.stdout()?;
|
||||
|
||||
println!("Hello from Dagger and {}", version.trim());
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use dagger_sdk::gen::HostDirectoryOpts;
|
||||
use dagger_sdk::HostDirectoryOpts;
|
||||
use rand::Rng;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/publish-the-application/app".into(),
|
||||
@@ -15,7 +15,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
@@ -40,11 +40,11 @@ fn main() -> eyre::Result<()> {
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id(), None)
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use dagger_sdk::gen::HostDirectoryOpts;
|
||||
use dagger_sdk::HostDirectoryOpts;
|
||||
use rand::Rng;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
let output = "examples/publish-the-application/app/build";
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
@@ -16,7 +16,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
@@ -44,13 +44,13 @@ fn main() -> eyre::Result<()> {
|
||||
.from("nginx".into())
|
||||
.with_directory(
|
||||
"/usr/share/nginx/html".into(),
|
||||
client.host().directory(output.into(), None).id(),
|
||||
client.host().directory(output.into(), None).id()?,
|
||||
None,
|
||||
)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use dagger_sdk::gen::HostDirectoryOpts;
|
||||
use dagger_sdk::HostDirectoryOpts;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::client::connect()?;
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/test-the-application/app".into(),
|
||||
@@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
@@ -30,7 +30,7 @@ fn main() -> eyre::Result<()> {
|
||||
],
|
||||
None,
|
||||
)
|
||||
.stderr();
|
||||
.stderr()?;
|
||||
|
||||
println!("{}", out);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,6 @@
|
||||
pub mod client;
|
||||
pub mod gen;
|
||||
mod client;
|
||||
mod gen;
|
||||
mod querybuilder;
|
||||
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
pub use client::*;
|
||||
pub use gen::*;
|
||||
|
@@ -46,13 +46,13 @@ impl Selection {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn arg<S>(&self, name: &str, value: S) -> eyre::Result<Selection>
|
||||
pub fn arg<S>(&self, name: &str, value: S) -> Selection
|
||||
where
|
||||
S: Serialize,
|
||||
{
|
||||
let mut s = self.clone();
|
||||
|
||||
let val = serde_json::to_string(&value)?;
|
||||
let val = serde_json::to_string(&value).unwrap();
|
||||
|
||||
match s.args.as_mut() {
|
||||
Some(args) => {
|
||||
@@ -65,7 +65,7 @@ impl Selection {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(s)
|
||||
s
|
||||
}
|
||||
|
||||
pub fn build(&self) -> eyre::Result<String> {
|
||||
@@ -93,7 +93,7 @@ impl Selection {
|
||||
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
|
||||
}
|
||||
|
||||
pub fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<Option<D>>
|
||||
pub fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<D>
|
||||
where
|
||||
D: for<'de> Deserialize<'de>,
|
||||
{
|
||||
@@ -111,7 +111,7 @@ impl Selection {
|
||||
|
||||
let resp: Option<D> = self.unpack_resp(resp)?;
|
||||
|
||||
Ok(resp)
|
||||
Ok(resp.unwrap())
|
||||
}
|
||||
|
||||
fn path(&self) -> Vec<Selection> {
|
||||
@@ -171,10 +171,8 @@ mod tests {
|
||||
.select("core")
|
||||
.select("image")
|
||||
.arg("ref", "alpine")
|
||||
.unwrap()
|
||||
.select("file")
|
||||
.arg("path", "/etc/alpine-release")
|
||||
.unwrap();
|
||||
.arg("path", "/etc/alpine-release");
|
||||
|
||||
let query = root.build().unwrap();
|
||||
|
||||
@@ -190,10 +188,8 @@ mod tests {
|
||||
.select("core")
|
||||
.select("image")
|
||||
.arg("ref", "alpine")
|
||||
.unwrap()
|
||||
.select_with_alias("foo", "file")
|
||||
.arg("path", "/etc/alpine-release")
|
||||
.unwrap();
|
||||
.arg("path", "/etc/alpine-release");
|
||||
|
||||
let query = root.build().unwrap();
|
||||
|
||||
@@ -208,10 +204,8 @@ mod tests {
|
||||
let root = query()
|
||||
.select("a")
|
||||
.arg("arg", "one")
|
||||
.unwrap()
|
||||
.select("b")
|
||||
.arg("arg", "two")
|
||||
.unwrap();
|
||||
.arg("arg", "two");
|
||||
|
||||
let query = root.build().unwrap();
|
||||
|
||||
@@ -222,7 +216,7 @@ mod tests {
|
||||
fn test_vec_arg() {
|
||||
let input = vec!["some-string"];
|
||||
|
||||
let root = query().select("a").arg("arg", input).unwrap();
|
||||
let root = query().select("a").arg("arg", input);
|
||||
let query = root.build().unwrap();
|
||||
|
||||
assert_eq!(query, r#"query{a(arg:["some-string"])}"#.to_string())
|
||||
@@ -232,7 +226,7 @@ mod tests {
|
||||
fn test_ref_slice_arg() {
|
||||
let input = &["some-string"];
|
||||
|
||||
let root = query().select("a").arg("arg", input).unwrap();
|
||||
let root = query().select("a").arg("arg", input);
|
||||
let query = root.build().unwrap();
|
||||
|
||||
assert_eq!(query, r#"query{a(arg:["some-string"])}"#.to_string())
|
||||
@@ -242,7 +236,7 @@ mod tests {
|
||||
fn test_stringb_arg() {
|
||||
let input = "some-string".to_string();
|
||||
|
||||
let root = query().select("a").arg("arg", input).unwrap();
|
||||
let root = query().select("a").arg("arg", input);
|
||||
let query = root.build().unwrap();
|
||||
|
||||
assert_eq!(query, r#"query{a(arg:"some-string")}"#.to_string())
|
||||
@@ -275,7 +269,7 @@ mod tests {
|
||||
})),
|
||||
};
|
||||
|
||||
let root = query().select("a").arg("arg", input).unwrap();
|
||||
let root = query().select("a").arg("arg", input);
|
||||
let query = root.build().unwrap();
|
||||
|
||||
assert_eq!(
|
||||
|
@@ -1,5 +1,4 @@
|
||||
use dagger_sdk::client::connect;
|
||||
use dagger_sdk::gen::ContainerExecOpts;
|
||||
use dagger_sdk::{connect, ContainerExecOpts};
|
||||
|
||||
#[test]
|
||||
fn test_example_container() {
|
||||
@@ -15,7 +14,8 @@ fn test_example_container() {
|
||||
redirect_stderr: None,
|
||||
experimental_privileged_nesting: None,
|
||||
}))
|
||||
.stdout();
|
||||
.stdout()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(out, "3.16.2\n".to_string())
|
||||
}
|
||||
|
@@ -4,8 +4,6 @@ pub mod cli;
|
||||
mod cli_generate;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
//
|
||||
|
||||
color_eyre::install().unwrap();
|
||||
|
||||
let args = std::env::args();
|
||||
|
Reference in New Issue
Block a user