mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
10 Commits
dagger-sdk
...
dagger-sdk
Author | SHA1 | Date | |
---|---|---|---|
c312bc57ad
|
|||
04e70ce964
|
|||
f72731807d
|
|||
c627595fd2 | |||
3f13c40ab8 | |||
f29ff836cf | |||
9762da895a | |||
02006d40fc | |||
94336d0637 | |||
6e2292cf11
|
77
Cargo.lock
generated
77
Cargo.lock
generated
@@ -245,7 +245,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-codegen"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"dagger-core 0.2.2",
|
||||
@@ -348,10 +348,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.4"
|
||||
version = "0.2.6"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core 0.2.2",
|
||||
"derive_builder",
|
||||
"eyre",
|
||||
"futures",
|
||||
"genco",
|
||||
@@ -363,6 +364,72 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8"
|
||||
dependencies = [
|
||||
"derive_builder_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_core"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_builder_macro"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
|
||||
dependencies = [
|
||||
"derive_builder_core",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
@@ -839,6 +906,12 @@ dependencies = [
|
||||
"tokio-native-tls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.3.0"
|
||||
|
@@ -22,7 +22,7 @@ See [dagger-sdk](./crates/dagger-sdk/README.md)
|
||||
- [x] Deserializer for nested response (bind)
|
||||
- [x] Add codegen to hook into querier
|
||||
- [x] fix build / release cycle
|
||||
- [ ] general api stabilisation
|
||||
- [x] general api stabilisation
|
||||
- [x] document usage
|
||||
- [ ] make async variant
|
||||
|
||||
|
@@ -28,7 +28,7 @@ fn main() -> eyre::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn release(client: Arc<Query>, subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
|
||||
fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
|
||||
let src_dir = client.host().directory(
|
||||
".".into(),
|
||||
Some(HostDirectoryOpts {
|
||||
|
@@ -5,6 +5,70 @@ 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.4 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-f29ff836cfd72d5e051ca6a71a230ba1e9933091/> without Some in _opts functions
|
||||
Option has been removed as a wrapper around opts. This makes it much
|
||||
more convenient to use
|
||||
|
||||
```rust
|
||||
client.container_opts(Some(ContainerOpts{}))
|
||||
// ->
|
||||
client.container_opts(ContainerOpts{})
|
||||
```
|
||||
|
||||
The same options are still available, either an empty object can be
|
||||
passed, or a non _opts function can be used
|
||||
- <csr-id-9762da895a164e30c5dc60e89a83e934ceae47ab/> with _opts methods
|
||||
Now all opt values enter into a _opts function instead of the original.
|
||||
This avoids a lot of verbosity for both None in the case opts are
|
||||
unwanted, and Some() if they actually are.
|
||||
|
||||
They are used like so:
|
||||
|
||||
```rust
|
||||
client.container().from("...");
|
||||
client.container_opts(Some(ContainerOpts{ ... }))
|
||||
```
|
||||
|
||||
Some from opts will be removed in a future commit/pr
|
||||
- <csr-id-94336d06378f035464e233b921dc3858070f582d/> move to &str instead of String and introduce builder.
|
||||
This will make the api much easier to use, as we can now rely on ""
|
||||
instead of "".into() for normal string values.
|
||||
|
||||
Introduced builder as well, which makes it much easier to use *Opts, as
|
||||
it can handle the building of that, and get the benefits from String ->
|
||||
&str, as that is currently not allowed for optional values
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-c627595fd2695e236924175d137c42f1480ccd6b/> cargo clippy
|
||||
- <csr-id-02006d40fc2c0383e0412c15c36db9af7eda991f/> without phantom data
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 5 commits contributed to the release.
|
||||
- 5 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**
|
||||
- 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))
|
||||
- without phantom data ([`02006d4`](https://github.com/kjuulh/dagger-rs/commit/02006d40fc2c0383e0412c15c36db9af7eda991f))
|
||||
- move to &str instead of String and introduce builder. ([`94336d0`](https://github.com/kjuulh/dagger-rs/commit/94336d06378f035464e233b921dc3858070f582d))
|
||||
</details>
|
||||
|
||||
## v0.2.3 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
@@ -16,7 +80,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
|
||||
|
||||
@@ -27,6 +91,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.3, dagger-codegen v0.2.3, dagger-rs v0.2.9 ([`9235030`](https://github.com/kjuulh/dagger-rs/commit/92350306b3f0da40b4fc6dcaffcd90b891e83f70))
|
||||
- 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>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-codegen"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
|
@@ -6,8 +6,8 @@ use eyre::ContextCompat;
|
||||
use crate::utility::OptionExt;
|
||||
|
||||
pub trait FormatTypeFuncs {
|
||||
fn format_kind_list(&self, representation: &str) -> String;
|
||||
fn format_kind_scalar_string(&self, representation: &str) -> String;
|
||||
fn format_kind_list(&self, representation: &str, input: bool, immutable: bool) -> String;
|
||||
fn format_kind_scalar_string(&self, representation: &str, input: bool) -> String;
|
||||
fn format_kind_scalar_int(&self, representation: &str) -> String;
|
||||
fn format_kind_scalar_float(&self, representation: &str) -> String;
|
||||
fn format_kind_scalar_boolean(&self, representation: &str) -> String;
|
||||
@@ -36,14 +36,18 @@ impl CommonFunctions {
|
||||
}
|
||||
|
||||
pub fn format_input_type(&self, t: &TypeRef) -> String {
|
||||
self.format_type(t, true)
|
||||
self.format_type(t, true, false)
|
||||
}
|
||||
|
||||
pub fn format_output_type(&self, t: &TypeRef) -> String {
|
||||
self.format_type(t, false)
|
||||
self.format_type(t, false, false)
|
||||
}
|
||||
|
||||
fn format_type(&self, t: &TypeRef, input: bool) -> String {
|
||||
pub fn format_immutable_input_type(&self, t: &TypeRef) -> String {
|
||||
self.format_type(t, true, true)
|
||||
}
|
||||
|
||||
fn format_type(&self, t: &TypeRef, input: bool, immutable: bool) -> String {
|
||||
let mut representation = String::new();
|
||||
let mut r = Some(t.clone());
|
||||
while r.is_some() {
|
||||
@@ -57,9 +61,14 @@ impl CommonFunctions {
|
||||
Scalar::Float => self
|
||||
.format_type_funcs
|
||||
.format_kind_scalar_float(&mut representation),
|
||||
Scalar::String => self
|
||||
.format_type_funcs
|
||||
.format_kind_scalar_string(&mut representation),
|
||||
Scalar::String => {
|
||||
if immutable {
|
||||
"&'a str".into()
|
||||
} else {
|
||||
self.format_type_funcs
|
||||
.format_kind_scalar_string(&mut representation, input)
|
||||
}
|
||||
}
|
||||
Scalar::Boolean => self
|
||||
.format_type_funcs
|
||||
.format_kind_scalar_boolean(&mut representation),
|
||||
@@ -87,12 +96,15 @@ impl CommonFunctions {
|
||||
.as_ref()
|
||||
.map(|t| t.clone())
|
||||
.map(|t| *t)
|
||||
.map(|t| self.format_type(&t, input))
|
||||
.map(|t| self.format_type(&t, input, immutable))
|
||||
.context("could not get inner type of list")
|
||||
.unwrap();
|
||||
|
||||
representation =
|
||||
self.format_type_funcs.format_kind_list(&mut inner_type);
|
||||
representation = self.format_type_funcs.format_kind_list(
|
||||
&mut inner_type,
|
||||
input,
|
||||
immutable,
|
||||
);
|
||||
|
||||
return representation;
|
||||
}
|
||||
|
@@ -5,13 +5,17 @@ use super::functions::format_name;
|
||||
pub struct FormatTypeFunc;
|
||||
|
||||
impl FormatTypeFuncs for FormatTypeFunc {
|
||||
fn format_kind_list(&self, representation: &str) -> String {
|
||||
fn format_kind_list(&self, representation: &str, _input: bool, _immutable: bool) -> String {
|
||||
format!("Vec<{}>", representation)
|
||||
}
|
||||
|
||||
fn format_kind_scalar_string(&self, representation: &str) -> String {
|
||||
fn format_kind_scalar_string(&self, representation: &str, input: bool) -> String {
|
||||
let mut rep = representation.to_string();
|
||||
rep.push_str("String");
|
||||
if input {
|
||||
rep.push_str("impl Into<String>");
|
||||
} else {
|
||||
rep.push_str("String");
|
||||
}
|
||||
rep
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,8 @@ 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, type_ref_is_list_of_objects, type_ref_is_object,
|
||||
type_ref_is_optional, type_ref_is_scalar, CommonFunctions, Scalar,
|
||||
};
|
||||
use crate::utility::OptionExt;
|
||||
|
||||
@@ -39,18 +39,44 @@ pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
.pipe(|t| &t.type_ref)
|
||||
.pipe(|t| render_output_type(funcs, t));
|
||||
|
||||
Some(quote! {
|
||||
$(signature)(
|
||||
$(args)
|
||||
) -> $(output_type) {
|
||||
let mut query = self.selection.select($(quoted(field.name.as_ref())));
|
||||
if let Some((args, true)) = args {
|
||||
let required_args = format_required_function_args(funcs, field);
|
||||
Some(quote! {
|
||||
$(&signature)(
|
||||
$(required_args)
|
||||
) -> $(output_type.as_ref()) {
|
||||
let mut query = self.selection.select($(quoted(field.name.as_ref())));
|
||||
|
||||
$(render_required_args(funcs, field))
|
||||
$(render_optional_args(funcs, field))
|
||||
$(render_required_args(funcs, field))
|
||||
|
||||
$(render_execution(funcs, field))
|
||||
}
|
||||
})
|
||||
$(render_execution(funcs, field))
|
||||
}
|
||||
|
||||
$(&signature)_opts(
|
||||
$args
|
||||
) -> $(output_type) {
|
||||
let mut query = self.selection.select($(quoted(field.name.as_ref())));
|
||||
|
||||
$(render_required_args(funcs, field))
|
||||
$(render_optional_args(funcs, field))
|
||||
|
||||
$(render_execution(funcs, field))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Some(quote! {
|
||||
$(signature)(
|
||||
$(if let Some((args, _)) = args => $args)
|
||||
) -> $(output_type) {
|
||||
let mut query = self.selection.select($(quoted(field.name.as_ref())));
|
||||
|
||||
$(render_required_args(funcs, field))
|
||||
$(render_optional_args(funcs, field))
|
||||
|
||||
$(render_execution(funcs, field))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Option<rust::Tokens> {
|
||||
@@ -66,6 +92,40 @@ fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
|
||||
let n = format_struct_name(&s.input_value.name);
|
||||
let name = &s.input_value.name;
|
||||
|
||||
if type_ref_is_scalar(&s.input_value.type_) {
|
||||
if let Scalar::String =
|
||||
Scalar::from(&*s.input_value.type_.of_type.as_ref().unwrap().clone())
|
||||
{
|
||||
return Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(&n).into());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if type_ref_is_list(&s.input_value.type_) {
|
||||
let inner = *s
|
||||
.input_value
|
||||
.type_
|
||||
.of_type
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
.of_type
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone();
|
||||
println!("type: {:?}", inner);
|
||||
if type_ref_is_scalar(&inner) {
|
||||
if let Scalar::String =
|
||||
Scalar::from(&*inner.of_type.as_ref().unwrap().clone())
|
||||
{
|
||||
return Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(&n).into_iter().map(|i| i.into()).collect::<Vec<String>>());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some(quote! {
|
||||
query = query.arg($(quoted(name)), $(n));
|
||||
})
|
||||
@@ -111,9 +171,7 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
|
||||
}
|
||||
|
||||
let required_args = quote! {
|
||||
if let Some(opts) = opts {
|
||||
$(for arg in args join ($['\r']) => $arg)
|
||||
}
|
||||
$(for arg in args join ($['\r']) => $arg)
|
||||
};
|
||||
|
||||
Some(required_args)
|
||||
@@ -181,7 +239,10 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
|
||||
}
|
||||
}
|
||||
|
||||
fn format_function_args(funcs: &CommonFunctions, field: &FullTypeFields) -> Option<rust::Tokens> {
|
||||
fn format_function_args(
|
||||
funcs: &CommonFunctions,
|
||||
field: &FullTypeFields,
|
||||
) -> Option<(rust::Tokens, bool)> {
|
||||
if let Some(args) = field.args.as_ref() {
|
||||
let args = args
|
||||
.into_iter()
|
||||
@@ -207,14 +268,51 @@ fn format_function_args(funcs: &CommonFunctions, field: &FullTypeFields) -> Opti
|
||||
};
|
||||
|
||||
if type_field_has_optional(field) {
|
||||
Some(quote! {
|
||||
$(required_args)
|
||||
opts: Option<$(field_options_struct_name(field))>
|
||||
})
|
||||
Some((
|
||||
quote! {
|
||||
$(required_args)
|
||||
opts: $(field_options_struct_name(field))
|
||||
},
|
||||
true,
|
||||
))
|
||||
} else {
|
||||
Some(required_args)
|
||||
Some((required_args, false))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn format_required_function_args(
|
||||
funcs: &CommonFunctions,
|
||||
field: &FullTypeFields,
|
||||
) -> Option<rust::Tokens> {
|
||||
if let Some(args) = field.args.as_ref() {
|
||||
let args = args
|
||||
.into_iter()
|
||||
.map(|a| {
|
||||
a.as_ref().and_then(|s| {
|
||||
if type_ref_is_optional(&s.input_value.type_) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let t = funcs.format_input_type(&s.input_value.type_);
|
||||
let n = format_struct_name(&s.input_value.name);
|
||||
|
||||
Some(quote! {
|
||||
$(n): $(t),
|
||||
})
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
.collect::<Vec<_>>();
|
||||
let required_args = quote! {
|
||||
&self,
|
||||
$(for arg in args join ($['\r']) => $arg)
|
||||
};
|
||||
|
||||
Some(required_args)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ pub fn render_enum(t: &FullType) -> eyre::Result<rust::Tokens> {
|
||||
let serialize = rust::import("serde", "Serialize");
|
||||
|
||||
Ok(quote! {
|
||||
#[derive($serialize)]
|
||||
#[derive($serialize, Clone, PartialEq, Debug)]
|
||||
pub enum $(t.name.as_ref()) {
|
||||
$(render_enum_values(t))
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ pub fn render_input(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust:
|
||||
let deserialize = rust::import("serde", "Deserialize");
|
||||
let serialize = rust::import("serde", "Serialize");
|
||||
Ok(quote! {
|
||||
#[derive($serialize, $deserialize)]
|
||||
#[derive($serialize, $deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct $(format_name(t.name.as_ref().unwrap())) {
|
||||
$(render_input_fields(funcs, t.input_fields.as_ref().unwrap_or(&Vec::new()) ))
|
||||
}
|
||||
@@ -33,6 +33,6 @@ pub fn render_input_fields(
|
||||
|
||||
pub fn render_input_field(funcs: &CommonFunctions, field: &FullTypeInputFields) -> rust::Tokens {
|
||||
quote! {
|
||||
pub $(format_struct_name(&field.input_value.name)): $(funcs.format_input_type(&field.input_value.type_)),
|
||||
pub $(format_struct_name(&field.input_value.name)): $(funcs.format_output_type(&field.input_value.type_)),
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs};
|
||||
use genco::prelude::rust;
|
||||
use genco::quote;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::functions::{type_ref_is_optional, CommonFunctions};
|
||||
use crate::rust::functions::{
|
||||
@@ -61,9 +62,15 @@ fn render_optional_arg(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
.pipe(|t| render_optional_field_args(funcs, t))
|
||||
.flatten();
|
||||
|
||||
if let Some(fields) = fields {
|
||||
let builder = rust::import("derive_builder", "Builder");
|
||||
let _phantom_data = rust::import("std::marker", "PhantomData");
|
||||
|
||||
if let Some((fields, contains_lifetime)) = fields {
|
||||
Some(quote! {
|
||||
pub struct $output_type {
|
||||
#[derive($builder, Debug, PartialEq)]
|
||||
pub struct $output_type$(if contains_lifetime => <'a>) {
|
||||
//#[builder(default, setter(skip))]
|
||||
//pub marker: $(phantom_data)<&'a ()>,
|
||||
$fields
|
||||
}
|
||||
})
|
||||
@@ -75,19 +82,28 @@ fn render_optional_arg(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
||||
fn render_optional_field_args(
|
||||
funcs: &CommonFunctions,
|
||||
args: &Vec<&FullTypeFieldsArgs>,
|
||||
) -> Option<rust::Tokens> {
|
||||
) -> Option<(rust::Tokens, bool)> {
|
||||
if args.len() == 0 {
|
||||
return None;
|
||||
}
|
||||
let mut contains_lifetime = false;
|
||||
let rendered_args = args.into_iter().map(|a| &a.input_value).map(|a| {
|
||||
let type_ = funcs.format_immutable_input_type(&a.type_);
|
||||
if type_.contains("str") {
|
||||
contains_lifetime = true;
|
||||
}
|
||||
quote! {
|
||||
pub $(format_struct_name(&a.name)): Option<$(funcs.format_output_type(&a.type_))>,
|
||||
#[builder(setter(into, strip_option))]
|
||||
pub $(format_struct_name(&a.name)): Option<$(type_)>,
|
||||
}
|
||||
});
|
||||
|
||||
Some(quote! {
|
||||
$(for arg in rendered_args join ($['\r']) => $arg)
|
||||
})
|
||||
Some((
|
||||
quote! {
|
||||
$(for arg in rendered_args join ($['\r']) => $arg)
|
||||
},
|
||||
contains_lifetime,
|
||||
))
|
||||
}
|
||||
|
||||
fn render_functions(funcs: &CommonFunctions, fields: &Vec<FullTypeFields>) -> Option<rust::Tokens> {
|
||||
|
@@ -10,7 +10,7 @@ pub fn render_scalar(t: &FullType) -> eyre::Result<rust::Tokens> {
|
||||
let serialize = rust::import("serde", "Serialize");
|
||||
|
||||
Ok(quote! {
|
||||
#[derive($serialize, $deserialize)]
|
||||
#[derive($serialize, $deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct $(t.name.pipe(|n|format_name(n)))(String);
|
||||
})
|
||||
}
|
||||
|
@@ -5,11 +5,11 @@ 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.4 (2023-02-19)
|
||||
## v0.2.6 (2023-02-19)
|
||||
|
||||
### Bug Fixes
|
||||
### Documentation
|
||||
|
||||
- <csr-id-7d04ab1240e497e7804fed23a378d28c78f50a0a/> readme dagger-rs -> dagger-sdk
|
||||
- <csr-id-04e70ce964b343e28b3dbd0c46d10ccda958ab8c/> fix readme
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
@@ -26,6 +26,98 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- fix readme ([`04e70ce`](https://github.com/kjuulh/dagger-rs/commit/04e70ce964b343e28b3dbd0c46d10ccda958ab8c))
|
||||
</details>
|
||||
|
||||
## v0.2.5 (2023-02-19)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-f29ff836cfd72d5e051ca6a71a230ba1e9933091/> without Some in _opts functions
|
||||
Option has been removed as a wrapper around opts. This makes it much
|
||||
more convenient to use
|
||||
|
||||
```rust
|
||||
client.container_opts(Some(ContainerOpts{}))
|
||||
// ->
|
||||
client.container_opts(ContainerOpts{})
|
||||
```
|
||||
|
||||
The same options are still available, either an empty object can be
|
||||
passed, or a non _opts function can be used
|
||||
- <csr-id-9762da895a164e30c5dc60e89a83e934ceae47ab/> with _opts methods
|
||||
Now all opt values enter into a _opts function instead of the original.
|
||||
This avoids a lot of verbosity for both None in the case opts are
|
||||
unwanted, and Some() if they actually are.
|
||||
|
||||
They are used like so:
|
||||
|
||||
```rust
|
||||
client.container().from("...");
|
||||
client.container_opts(Some(ContainerOpts{ ... }))
|
||||
```
|
||||
|
||||
Some from opts will be removed in a future commit/pr
|
||||
- <csr-id-94336d06378f035464e233b921dc3858070f582d/> move to &str instead of String and introduce builder.
|
||||
This will make the api much easier to use, as we can now rely on ""
|
||||
instead of "".into() for normal string values.
|
||||
|
||||
Introduced builder as well, which makes it much easier to use *Opts, as
|
||||
it can handle the building of that, and get the benefits from String ->
|
||||
&str, as that is currently not allowed for optional values
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-c627595fd2695e236924175d137c42f1480ccd6b/> cargo clippy
|
||||
- <csr-id-02006d40fc2c0383e0412c15c36db9af7eda991f/> without phantom data
|
||||
- <csr-id-6e2292cf11942fbd26a52fe4e0fc8471e6eb70a3/> dependencies
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 7 commits contributed to the release.
|
||||
- 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**
|
||||
- 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))
|
||||
- without phantom data ([`02006d4`](https://github.com/kjuulh/dagger-rs/commit/02006d40fc2c0383e0412c15c36db9af7eda991f))
|
||||
- move to &str instead of String and introduce builder. ([`94336d0`](https://github.com/kjuulh/dagger-rs/commit/94336d06378f035464e233b921dc3858070f582d))
|
||||
- dependencies ([`6e2292c`](https://github.com/kjuulh/dagger-rs/commit/6e2292cf11942fbd26a52fe4e0fc8471e6eb70a3))
|
||||
</details>
|
||||
|
||||
## v0.2.4 (2023-02-19)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-7d04ab1240e497e7804fed23a378d28c78f50a0a/> readme dagger-rs -> dagger-sdk
|
||||
|
||||
### 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.4 ([`cc81124`](https://github.com/kjuulh/dagger-rs/commit/cc81124f899f44f80c1ee7d1e23a7e02d8cc4b7c))
|
||||
- readme dagger-rs -> dagger-sdk ([`7d04ab1`](https://github.com/kjuulh/dagger-rs/commit/7d04ab1240e497e7804fed23a378d28c78f50a0a))
|
||||
</details>
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.4"
|
||||
version = "0.2.6"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -11,17 +11,18 @@ publish = true
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.21.0"
|
||||
dagger-core = { path = "../dagger-core", version = "^0.2.2" }
|
||||
|
||||
base64 = "0.21.0"
|
||||
eyre = "0.6.8"
|
||||
futures = "0.3.26"
|
||||
|
||||
genco = "0.17.3"
|
||||
gql_client = "1.0.7"
|
||||
pretty_assertions = "1.3.0"
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
serde_json = "1.0.93"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
derive_builder = "0.12.0"
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.3.0"
|
||||
rand = "0.8.5"
|
||||
genco = "0.17.3"
|
||||
|
@@ -29,9 +29,9 @@ fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let version = client
|
||||
.container(None)
|
||||
.from("golang:1.19".into())
|
||||
.with_exec(vec!["go".into(), "version".into()], None)
|
||||
.container()
|
||||
.from("golang:1.19")
|
||||
.with_exec(vec!["go", "version"])
|
||||
.stdout()?;
|
||||
|
||||
println!("Hello from Dagger and {}", version.trim());
|
||||
|
@@ -3,40 +3,32 @@ use dagger_sdk::HostDirectoryOpts;
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/build-the-application/app".into(),
|
||||
Some(HostDirectoryOpts {
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/build-the-application/app",
|
||||
HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
||||
include: None,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
.container()
|
||||
.from("node:16")
|
||||
.with_mounted_directory("/src", host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
.with_exec(vec!["npm".into(), "install".into()], None);
|
||||
.with_workdir("/src")
|
||||
.with_exec(vec!["npm", "install"]);
|
||||
|
||||
let test = runner.with_exec(
|
||||
vec![
|
||||
"npm".into(),
|
||||
"test".into(),
|
||||
"--".into(),
|
||||
"--watchAll=false".into(),
|
||||
],
|
||||
None,
|
||||
);
|
||||
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
|
||||
|
||||
let build_dir = test
|
||||
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
|
||||
.directory("./build".into());
|
||||
.with_exec(vec!["npm", "run", "build"])
|
||||
.directory("./build");
|
||||
|
||||
let _ = build_dir.export("./build".into());
|
||||
let _ = build_dir.export("./build");
|
||||
|
||||
let entries = build_dir.entries(None);
|
||||
let entries = build_dir.entries();
|
||||
|
||||
println!("build dir contents: \n {:?}", entries);
|
||||
|
||||
|
@@ -1,53 +1,40 @@
|
||||
use dagger_sdk::HostDirectoryOpts;
|
||||
use rand::Rng;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"./examples/caching/app".into(),
|
||||
Some(HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
||||
include: None,
|
||||
}),
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"./examples/caching/app",
|
||||
dagger_sdk::HostDirectoryOptsBuilder::default()
|
||||
.exclude(vec!["node_modules", "ci/"])
|
||||
.build()?,
|
||||
);
|
||||
|
||||
let node_cache = client.cache_volume("node".into()).id()?;
|
||||
let node_cache = client.cache_volume("node").id()?;
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?)
|
||||
.with_mounted_cache("/src/node_modules".into(), node_cache, None);
|
||||
.container()
|
||||
.from("node:16")
|
||||
.with_mounted_directory("/src", host_source_dir.id()?)
|
||||
.with_mounted_cache("/src/node_modules", node_cache);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
.with_exec(vec!["npm".into(), "install".into()], None);
|
||||
.with_workdir("/src")
|
||||
.with_exec(vec!["npm", "install"]);
|
||||
|
||||
let test = runner.with_exec(
|
||||
vec![
|
||||
"npm".into(),
|
||||
"test".into(),
|
||||
"--".into(),
|
||||
"--watchAll=false".into(),
|
||||
],
|
||||
None,
|
||||
);
|
||||
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
|
||||
|
||||
let build_dir = test
|
||||
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
|
||||
.directory("./build".into());
|
||||
.with_exec(vec!["npm", "run", "build"])
|
||||
.directory("./build");
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
)?;
|
||||
.container()
|
||||
.from("nginx")
|
||||
.with_directory("/usr/share/nginx/html", build_dir.id()?)
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -7,15 +7,12 @@ fn main() -> eyre::Result<()> {
|
||||
|
||||
let context_dir = client
|
||||
.host()
|
||||
.directory("./examples/existing-dockerfile/app".into(), None);
|
||||
.directory("./examples/existing-dockerfile/app");
|
||||
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.build(context_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
)?;
|
||||
.container()
|
||||
.build(context_dir.id()?)
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -2,9 +2,9 @@ fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let version = client
|
||||
.container(None)
|
||||
.from("golang:1.19".into())
|
||||
.with_exec(vec!["go".into(), "version".into()], None)
|
||||
.container()
|
||||
.from("golang:1.19")
|
||||
.with_exec(vec!["go", "version".into()])
|
||||
.stdout()?;
|
||||
|
||||
println!("Hello from Dagger and {}", version.trim());
|
||||
|
@@ -4,47 +4,36 @@ use rand::Rng;
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/publish-the-application/app".into(),
|
||||
Some(HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/publish-the-application/app",
|
||||
HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules", "ci/"]),
|
||||
include: None,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
.container()
|
||||
.from("node:16")
|
||||
.with_mounted_directory("/src", host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
.with_exec(vec!["npm".into(), "install".into()], None);
|
||||
.with_workdir("/src")
|
||||
.with_exec(vec!["npm", "install"]);
|
||||
|
||||
let test = runner.with_exec(
|
||||
vec![
|
||||
"npm".into(),
|
||||
"test".into(),
|
||||
"--".into(),
|
||||
"--watchAll=false".into(),
|
||||
],
|
||||
None,
|
||||
);
|
||||
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
|
||||
|
||||
let build_dir = test
|
||||
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
|
||||
.directory("./build".into());
|
||||
.with_exec(vec!["npm", "run", "build"])
|
||||
.directory("./build");
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
)?;
|
||||
.container()
|
||||
.from("nginx")
|
||||
.with_directory("/usr/share/nginx/html", build_dir.id()?)
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -5,52 +5,40 @@ fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
let output = "examples/publish-the-application/app/build";
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/publish-the-application/app".into(),
|
||||
Some(HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/publish-the-application/app",
|
||||
HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules", "ci/"]),
|
||||
include: None,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
.container()
|
||||
.from("node:16")
|
||||
.with_mounted_directory("/src", host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
.with_exec(vec!["npm".into(), "install".into()], None);
|
||||
.with_workdir("/src")
|
||||
.with_exec(vec!["npm", "install"]);
|
||||
|
||||
let test = runner.with_exec(
|
||||
vec![
|
||||
"npm".into(),
|
||||
"test".into(),
|
||||
"--".into(),
|
||||
"--watchAll=false".into(),
|
||||
],
|
||||
None,
|
||||
);
|
||||
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
|
||||
|
||||
let _ = test
|
||||
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
|
||||
.directory("./build".into())
|
||||
.export(output.into());
|
||||
.with_exec(vec!["npm", "run", "build"])
|
||||
.directory("./build")
|
||||
.export(output);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.container()
|
||||
.from("nginx")
|
||||
.with_directory(
|
||||
"/usr/share/nginx/html".into(),
|
||||
client.host().directory(output.into(), None).id()?,
|
||||
None,
|
||||
"/usr/share/nginx/html",
|
||||
client.host().directory(output).id()?,
|
||||
)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
)?;
|
||||
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -3,33 +3,25 @@ use dagger_sdk::HostDirectoryOpts;
|
||||
fn main() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect()?;
|
||||
|
||||
let host_source_dir = client.host().directory(
|
||||
"examples/test-the-application/app".into(),
|
||||
Some(HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"examples/test-the-application/app",
|
||||
HostDirectoryOpts {
|
||||
exclude: Some(vec!["node_modules", "ci/"]),
|
||||
include: None,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
.container()
|
||||
.from("node:16")
|
||||
.with_mounted_directory("/src", host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
.with_exec(vec!["npm".into(), "install".into()], None);
|
||||
.with_workdir("/src")
|
||||
.with_exec(vec!["npm", "install"]);
|
||||
|
||||
let out = runner
|
||||
.with_exec(
|
||||
vec![
|
||||
"npm".into(),
|
||||
"test".into(),
|
||||
"--".into(),
|
||||
"--watchAll=false".into(),
|
||||
],
|
||||
None,
|
||||
)
|
||||
.with_exec(vec!["npm", "test", "--", "--watchAll=false"])
|
||||
.stderr()?;
|
||||
|
||||
println!("{}", out);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,18 @@
|
||||
use dagger_sdk::{connect, ContainerExecOpts};
|
||||
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||
|
||||
#[test]
|
||||
fn test_example_container() {
|
||||
let client = connect().unwrap();
|
||||
|
||||
let alpine = client.container(None).from("alpine:3.16.2".into());
|
||||
let alpine = client.container().from("alpine:3.16.2");
|
||||
|
||||
let out = alpine
|
||||
.exec(Some(ContainerExecOpts {
|
||||
args: Some(vec!["cat".into(), "/etc/alpine-release".into()]),
|
||||
stdin: None,
|
||||
redirect_stdout: None,
|
||||
redirect_stderr: None,
|
||||
experimental_privileged_nesting: None,
|
||||
}))
|
||||
.exec_opts(
|
||||
ContainerExecOptsBuilder::default()
|
||||
.args(vec!["cat", "/etc/alpine-release"])
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.stdout()
|
||||
.unwrap();
|
||||
|
||||
|
Reference in New Issue
Block a user