mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
13 Commits
dagger-cor
...
dagger-sdk
Author | SHA1 | Date | |
---|---|---|---|
a8e6dde615
|
|||
1bfd084cd2 | |||
5593fce2e1 | |||
2cc0231c5f | |||
9ba01396cb | |||
c025d17424 | |||
e9e35edb1c | |||
d7317e5cf3 | |||
f67928155f | |||
|
44fa0240f8 | ||
62de24153a
|
|||
9513bb5653
|
|||
6b43d5bc36
|
12
ARCHITECTURE.md
Normal file
12
ARCHITECTURE.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Architecture
|
||||
|
||||
- `.` Root project mainly used for generating the CLI, which in turn is used to
|
||||
bootstrap the code generation from `dagger`
|
||||
- `crates/dagger-core` Contains all base types used during actual usage. This is
|
||||
where the primary logic lives in which the user interacts (\*disclaimer: most
|
||||
stuff haven't moved in here yet.)
|
||||
- `crates/dagger-sdk` Contains the actual sdk in which the user interacts,
|
||||
`dagger-core` is reexported through this API as well.
|
||||
- `crates/dagger-codegen` This is the bulk of the work, it takes the input
|
||||
graphql and spits out the API in which the user interacts, this is heavily
|
||||
inspired by other `dagger-sdk's`. It primarily turns graphql into rust code.
|
11
CONTRIBUTING.md
Normal file
11
CONTRIBUTING.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Contributing
|
||||
|
||||
The sdk is still quite young, so feel free to either:
|
||||
|
||||
- Refactor
|
||||
- Document
|
||||
- Improve the code
|
||||
|
||||
Feel free to ping me on discord @Hermansen#4325, or just create an issue if
|
||||
there is a missing feature, or you'd like some mentorship in getting into the
|
||||
code
|
38
Cargo.lock
generated
38
Cargo.lock
generated
@@ -309,7 +309,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core",
|
||||
@@ -537,9 +537,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84"
|
||||
checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@@ -552,9 +552,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5"
|
||||
checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@@ -562,15 +562,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
|
||||
checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e"
|
||||
checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@@ -579,15 +579,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
|
||||
checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70"
|
||||
checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -596,21 +596,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364"
|
||||
checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366"
|
||||
checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.26"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1"
|
||||
checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
|
40
README.md
40
README.md
@@ -1,40 +0,0 @@
|
||||
# dagger-rs
|
||||
|
||||
A dagger sdk written in rust for rust.
|
||||
|
||||
# Usage
|
||||
|
||||
See [dagger-sdk](./crates/dagger-sdk/README.md)
|
||||
|
||||
### Status
|
||||
|
||||
- [x] dagger cli downloader
|
||||
- [x] dagger network session
|
||||
- [x] graphql rust codegen (User API)
|
||||
- [x] Scalars
|
||||
- [x] Enums
|
||||
- [x] Input
|
||||
- [x] Objects
|
||||
- [x] Implement context and querier
|
||||
- [x] Marshaller
|
||||
- [x] Querier
|
||||
- [x] Context
|
||||
- [x] Deserializer for nested response (bind)
|
||||
- [x] Add codegen to hook into querier
|
||||
- [x] fix build / release cycle
|
||||
- [x] general api stabilisation
|
||||
- [x] document usage
|
||||
- [x] make async variant
|
||||
|
||||
## Architecture
|
||||
|
||||
- `.` Root project mainly used for generating the CLI, which in turn is used to
|
||||
bootstrap the code generation from `dagger`
|
||||
- `crates/dagger-core` Contains all base types used during actual usage. This is
|
||||
where the primary logic lives in which the user interacts (\*disclaimer: most
|
||||
stuff haven't moved in here yet.)
|
||||
- `crates/dagger-sdk` Contains the actual sdk in which the user interacts,
|
||||
`dagger-core` is reexported through this API as well.
|
||||
- `crates/dagger-codegen` This is the bulk of the work, it takes the input
|
||||
graphql and spits out the API in which the user interacts, this is heavily
|
||||
inspired by other `dagger-sdk's`. It primarily turns graphql into rust code.
|
@@ -8,6 +8,6 @@ edition = "2021"
|
||||
[dependencies]
|
||||
clap = "4.1.6"
|
||||
color-eyre = "0.6.2"
|
||||
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.16" }
|
||||
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.17" }
|
||||
eyre = "0.6.8"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
@@ -11,6 +11,18 @@ pub fn render_scalar(t: &FullType) -> eyre::Result<rust::Tokens> {
|
||||
|
||||
Ok(quote! {
|
||||
#[derive($serialize, $deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct $(t.name.pipe(|n|format_name(n)))(String);
|
||||
pub struct $(t.name.pipe(|n|format_name(n)))(pub String);
|
||||
|
||||
impl Into<$(t.name.pipe(|n| format_name(n)))> for &str {
|
||||
fn into(self) -> $(t.name.pipe(|n| format_name(n))) {
|
||||
$(t.name.pipe(|n| format_name(n)))(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<$(t.name.pipe(|n| format_name(n)))> for String {
|
||||
fn into(self) -> $(t.name.pipe(|n| format_name(n))) {
|
||||
$(t.name.pipe(|n| format_name(n)))(self.clone())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -6,8 +6,57 @@ 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.17 (2023-03-13)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- <csr-id-1bfd084cd28e2b984c61de7f3f9a065cc41be007/> make sure tests have a command to execute
|
||||
- <csr-id-5593fce2e16e0aa97a2e6843f15d3bb1121048f5/> remove unused imports
|
||||
- <csr-id-c025d1742482d701946c292dcf104421d3cade8e/> add support for String as well
|
||||
- <csr-id-d7317e5cf34ee84a7b092357f5fbb15cd2bae2e3/> add public tuple field and into func
|
||||
- <csr-id-44fa0240f8197f49fdf942b5c3d89079b59195d1/> update rust crate futures to 0.3.27
|
||||
|
||||
### Other
|
||||
|
||||
- <csr-id-f67928155f02076cbb41abd4010523879ff3caf1/> initial issue
|
||||
|
||||
### Refactor
|
||||
|
||||
- <csr-id-2cc0231c5f29993081f0f7e15e44cac95a7d6086/> remove export and instead use exitcode
|
||||
- <csr-id-9ba01396cb44ee02cf7a16008e3f0bdae9f78754/> move issues to actual tests and refactor
|
||||
- <csr-id-e9e35edb1cb67eee8cc033212aba3b1888def78f/> move issues to another folder
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 9 commits contributed to the release over the course of 2 calendar days.
|
||||
- 2 days passed between releases.
|
||||
- 9 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**
|
||||
- make sure tests have a command to execute ([`1bfd084`](https://github.com/kjuulh/dagger-rs/commit/1bfd084cd28e2b984c61de7f3f9a065cc41be007))
|
||||
- remove unused imports ([`5593fce`](https://github.com/kjuulh/dagger-rs/commit/5593fce2e16e0aa97a2e6843f15d3bb1121048f5))
|
||||
- remove export and instead use exitcode ([`2cc0231`](https://github.com/kjuulh/dagger-rs/commit/2cc0231c5f29993081f0f7e15e44cac95a7d6086))
|
||||
- move issues to actual tests and refactor ([`9ba0139`](https://github.com/kjuulh/dagger-rs/commit/9ba01396cb44ee02cf7a16008e3f0bdae9f78754))
|
||||
- add support for String as well ([`c025d17`](https://github.com/kjuulh/dagger-rs/commit/c025d1742482d701946c292dcf104421d3cade8e))
|
||||
- move issues to another folder ([`e9e35ed`](https://github.com/kjuulh/dagger-rs/commit/e9e35edb1cb67eee8cc033212aba3b1888def78f))
|
||||
- add public tuple field and into func ([`d7317e5`](https://github.com/kjuulh/dagger-rs/commit/d7317e5cf34ee84a7b092357f5fbb15cd2bae2e3))
|
||||
- initial issue ([`f679281`](https://github.com/kjuulh/dagger-rs/commit/f67928155f02076cbb41abd4010523879ff3caf1))
|
||||
- update rust crate futures to 0.3.27 ([`44fa024`](https://github.com/kjuulh/dagger-rs/commit/44fa0240f8197f49fdf942b5c3d89079b59195d1))
|
||||
</details>
|
||||
|
||||
## v0.2.16 (2023-03-10)
|
||||
|
||||
<csr-id-e642778d9028726dfb07217814e15ad1dd3b83f2/>
|
||||
|
||||
### Chore
|
||||
|
||||
- <csr-id-e642778d9028726dfb07217814e15ad1dd3b83f2/> fix tasks
|
||||
@@ -32,7 +81,7 @@ and this project adheres to
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 6 commits contributed to the release over the course of 13 calendar days.
|
||||
- 7 commits contributed to the release over the course of 13 calendar days.
|
||||
- 13 days passed between releases.
|
||||
- 6 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
@@ -44,6 +93,7 @@ and this project adheres to
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-core v0.2.8, dagger-sdk v0.2.16 ([`f390eac`](https://github.com/kjuulh/dagger-rs/commit/f390eac29f1d041d18d2207a5aa0a8d993aab68c))
|
||||
- fix tasks ([`e642778`](https://github.com/kjuulh/dagger-rs/commit/e642778d9028726dfb07217814e15ad1dd3b83f2))
|
||||
- with dagger-engine v.0.4.0 ([`7133bfa`](https://github.com/kjuulh/dagger-rs/commit/7133bfae9508bc5977548e373c49342a1248d6e4))
|
||||
- fix missing await in connect ([`13b7805`](https://github.com/kjuulh/dagger-rs/commit/13b7805e7e6fcf47e0a1318adcc25b4ab773a3c9))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -15,7 +15,7 @@ dagger-core = { path = "../dagger-core", version = "^0.2.8" }
|
||||
|
||||
base64 = "0.21.0"
|
||||
eyre = "0.6.8"
|
||||
futures = "0.3.26"
|
||||
futures = "0.3.27"
|
||||
gql_client = "1.0.7"
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
serde_json = "1.0.93"
|
||||
|
@@ -7,28 +7,112 @@ use std::sync::Arc;
|
||||
use tokio::process::Child;
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct CacheId(String);
|
||||
pub struct CacheId(pub String);
|
||||
|
||||
impl Into<CacheId> for &str {
|
||||
fn into(self) -> CacheId {
|
||||
CacheId(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<CacheId> for String {
|
||||
fn into(self) -> CacheId {
|
||||
CacheId(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct ContainerId(String);
|
||||
pub struct ContainerId(pub String);
|
||||
|
||||
impl Into<ContainerId> for &str {
|
||||
fn into(self) -> ContainerId {
|
||||
ContainerId(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<ContainerId> for String {
|
||||
fn into(self) -> ContainerId {
|
||||
ContainerId(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct DirectoryId(String);
|
||||
pub struct DirectoryId(pub String);
|
||||
|
||||
impl Into<DirectoryId> for &str {
|
||||
fn into(self) -> DirectoryId {
|
||||
DirectoryId(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<DirectoryId> for String {
|
||||
fn into(self) -> DirectoryId {
|
||||
DirectoryId(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct FileId(String);
|
||||
pub struct FileId(pub String);
|
||||
|
||||
impl Into<FileId> for &str {
|
||||
fn into(self) -> FileId {
|
||||
FileId(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<FileId> for String {
|
||||
fn into(self) -> FileId {
|
||||
FileId(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct Platform(String);
|
||||
pub struct Platform(pub String);
|
||||
|
||||
impl Into<Platform> for &str {
|
||||
fn into(self) -> Platform {
|
||||
Platform(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Platform> for String {
|
||||
fn into(self) -> Platform {
|
||||
Platform(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct SecretId(String);
|
||||
pub struct SecretId(pub String);
|
||||
|
||||
impl Into<SecretId> for &str {
|
||||
fn into(self) -> SecretId {
|
||||
SecretId(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<SecretId> for String {
|
||||
fn into(self) -> SecretId {
|
||||
SecretId(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct SocketId(String);
|
||||
pub struct SocketId(pub String);
|
||||
|
||||
impl Into<SocketId> for &str {
|
||||
fn into(self) -> SocketId {
|
||||
SocketId(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<SocketId> for String {
|
||||
fn into(self) -> SocketId {
|
||||
SocketId(self.clone())
|
||||
}
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct BuildArg {
|
||||
pub value: String,
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct PipelineLabel {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
pub name: String,
|
||||
}
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CacheVolume {
|
||||
@@ -2764,12 +2848,12 @@ impl Socket {
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
pub enum CacheSharingMode {
|
||||
SHARED,
|
||||
PRIVATE,
|
||||
LOCKED,
|
||||
SHARED,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
pub enum NetworkProtocol {
|
||||
UDP,
|
||||
TCP,
|
||||
UDP,
|
||||
}
|
||||
|
47
crates/dagger-sdk/tests/issues/iss_30.rs
Normal file
47
crates/dagger-sdk/tests/issues/iss_30.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
use dagger_sdk::{QueryContainerOpts, QueryContainerOptsBuilder};
|
||||
|
||||
static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"];
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_issue_30_alt() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
for platform in PLATFORMS {
|
||||
let ref_ = client
|
||||
.container_opts(QueryContainerOpts {
|
||||
id: None,
|
||||
platform: Some(platform.to_string().into()),
|
||||
})
|
||||
.from("alpine")
|
||||
.with_exec(vec!["echo", "'hello'"])
|
||||
.exit_code()
|
||||
.await?;
|
||||
|
||||
println!("published image to: {:#?}", ref_);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_issue_30() -> eyre::Result<()> {
|
||||
let client = dagger_sdk::connect().await?;
|
||||
|
||||
for platform in PLATFORMS {
|
||||
let ref_ = client
|
||||
.container_opts(
|
||||
QueryContainerOptsBuilder::default()
|
||||
.platform(platform)
|
||||
.build()
|
||||
.unwrap(),
|
||||
)
|
||||
.from("alpine")
|
||||
.with_exec(vec!["echo", "'hello'"])
|
||||
.exit_code()
|
||||
.await?;
|
||||
|
||||
println!("published image to: {:#?}", ref_);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
1
crates/dagger-sdk/tests/issues/mod.rs
Normal file
1
crates/dagger-sdk/tests/issues/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod iss_30;
|
@@ -1,3 +1,5 @@
|
||||
mod issues;
|
||||
|
||||
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
|
Reference in New Issue
Block a user