mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-12-28 10:51:01 +01:00
Compare commits
5 Commits
46157ec536
...
99bab8e1b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
99bab8e1b0
|
|||
|
7a008be59e
|
|||
|
ec0d0b22e6
|
|||
|
9f0021b708
|
|||
|
2b49f9c190
|
193
Cargo.lock
generated
193
Cargo.lock
generated
@@ -200,7 +200,22 @@ dependencies = [
|
||||
name = "dagger-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"flate2",
|
||||
"genco",
|
||||
"graphql-introspection-query",
|
||||
"graphql_client",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
"platform-info",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tar",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -231,12 +246,16 @@ dependencies = [
|
||||
name = "dagger-sdk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core",
|
||||
"eyre",
|
||||
"futures",
|
||||
"genco",
|
||||
"gql_client",
|
||||
"pretty_assertions",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -339,7 +358,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"windows-sys",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -384,31 +403,58 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.25"
|
||||
name = "futures"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed"
|
||||
checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.25"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
|
||||
checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.25"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
|
||||
checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.25"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d"
|
||||
checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -417,22 +463,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.25"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9"
|
||||
checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.25"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea"
|
||||
checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.25"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6"
|
||||
checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
@@ -487,6 +534,18 @@ dependencies = [
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gql_client"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e57f4862d3e5cd4ffe8df03fa2137e620e33578bbc1895e6f8f569630e17b1db"
|
||||
dependencies = [
|
||||
"log",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql-introspection-query"
|
||||
version = "0.2.0"
|
||||
@@ -711,7 +770,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -729,7 +788,7 @@ dependencies = [
|
||||
"hermit-abi",
|
||||
"io-lifetimes",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -785,6 +844,16 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
@@ -824,7 +893,7 @@ dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"windows-sys",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -921,6 +990,29 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.2.0"
|
||||
@@ -1071,7 +1163,7 @@ dependencies = [
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1086,9 +1178,15 @@ version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.8.1"
|
||||
@@ -1166,6 +1264,15 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.7"
|
||||
@@ -1279,9 +1386,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.24.2"
|
||||
version = "1.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb"
|
||||
checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bytes",
|
||||
@@ -1289,9 +1396,23 @@ dependencies = [
|
||||
"memchr",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"windows-sys",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1572,6 +1693,30 @@ dependencies = [
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.42.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.42.1"
|
||||
|
||||
@@ -18,7 +18,8 @@ Work in progress. This is not ready for usage yet
|
||||
- [ ] Implement context and querier
|
||||
- [x] Marshaller
|
||||
- [x] Querier
|
||||
- [ ] Context
|
||||
- [x] Context
|
||||
- [ ] Deserializer for nested response (bind)
|
||||
- [ ] Add codegen to hook into querier
|
||||
- [ ] fix build / release cycle
|
||||
- [ ] general api stabilisation
|
||||
|
||||
@@ -6,4 +6,22 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "4.1.4"
|
||||
dirs = "4.0.0"
|
||||
eyre = "0.6.8"
|
||||
flate2 = { version = "1.0.25", features = ["zlib"] }
|
||||
genco = "0.17.3"
|
||||
graphql-introspection-query = "0.2.0"
|
||||
graphql_client = { version = "0.12.0", features = [
|
||||
"reqwest",
|
||||
"reqwest-blocking",
|
||||
] }
|
||||
hex = "0.4.3"
|
||||
hex-literal = "0.3.4"
|
||||
platform-info = "1.0.2"
|
||||
reqwest = { version = "0.11.14", features = ["stream", "blocking", "deflate"] }
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
serde_json = "1.0.91"
|
||||
sha2 = "0.10.6"
|
||||
tar = "0.4.38"
|
||||
tempfile = "3.3.0"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
pub mod cli_session;
|
||||
pub mod config;
|
||||
pub mod connect_params;
|
||||
pub mod downloader;
|
||||
pub mod engine;
|
||||
pub mod introspection;
|
||||
pub mod schema;
|
||||
pub mod session;
|
||||
|
||||
pub struct Scalar(String);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use dagger_core::introspection::IntrospectionResponse;
|
||||
|
||||
use crate::introspection::IntrospectionResponse;
|
||||
use crate::{config::Config, engine::Engine, session::Session};
|
||||
|
||||
pub fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
||||
@@ -1,11 +1,10 @@
|
||||
use dagger_core::introspection::{self, IntrospectionResponse};
|
||||
use graphql_client::GraphQLQuery;
|
||||
use reqwest::{
|
||||
blocking::{Client, RequestBuilder},
|
||||
header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE},
|
||||
};
|
||||
|
||||
use crate::{config::Config, connect_params::ConnectParams};
|
||||
use crate::{config::Config, connect_params::ConnectParams, introspection::IntrospectionResponse};
|
||||
|
||||
#[derive(GraphQLQuery)]
|
||||
#[graphql(
|
||||
@@ -65,7 +64,7 @@ impl Session {
|
||||
return Err(eyre::anyhow!(error_message));
|
||||
}
|
||||
|
||||
let json: introspection::IntrospectionResponse = res.json()?;
|
||||
let json: IntrospectionResponse = res.json()?;
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
@@ -9,10 +9,14 @@ description = "A dagger sdk for rust, written in rust"
|
||||
# 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" }
|
||||
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.92"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
||||
51
crates/dagger-sdk/src/client.rs
Normal file
51
crates/dagger-sdk/src/client.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use dagger_core::config::Config;
|
||||
use dagger_core::connect_params::ConnectParams;
|
||||
use dagger_core::engine::Engine as DaggerEngine;
|
||||
use gql_client::ClientConfig;
|
||||
|
||||
use crate::gen::Query;
|
||||
use crate::querybuilder::query;
|
||||
|
||||
pub type DaggerConn = Arc<Query>;
|
||||
|
||||
pub fn connect() -> eyre::Result<DaggerConn> {
|
||||
let cfg = Config::default();
|
||||
let (conn, proc) = DaggerEngine::new().start(&cfg)?;
|
||||
|
||||
Ok(Arc::new(Query {
|
||||
conn,
|
||||
proc: Arc::new(proc),
|
||||
selection: query(),
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn graphql_client(conn: &ConnectParams) -> gql_client::Client {
|
||||
let token = general_purpose::URL_SAFE.encode(format!("{}:", conn.session_token));
|
||||
|
||||
let mut headers = HashMap::new();
|
||||
headers.insert("Authorization".to_string(), format!("Basic {}", token));
|
||||
|
||||
gql_client::Client::new_with_config(ClientConfig {
|
||||
endpoint: conn.url(),
|
||||
timeout: None,
|
||||
headers: Some(headers),
|
||||
proxy: None,
|
||||
})
|
||||
}
|
||||
|
||||
// Conn will automatically close on drop of proc
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::connect;
|
||||
|
||||
#[test]
|
||||
fn test_connect() {
|
||||
let _ = connect().unwrap();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
use std::process::Child;
|
||||
use std::sync::Arc;
|
||||
|
||||
use dagger_core::connect_params::ConnectParams;
|
||||
use dagger_core::{Boolean, Input, Int, Scalar};
|
||||
|
||||
use crate::client::graphql_client;
|
||||
use crate::querybuilder::Selection;
|
||||
|
||||
// code generated by dagger. DO NOT EDIT.
|
||||
|
||||
/// A global cache volume identifier.
|
||||
@@ -46,7 +53,11 @@ impl CacheVolume {
|
||||
impl Input for CacheVolume {}
|
||||
|
||||
/// An OCI-compatible container, also known as a docker container.
|
||||
pub struct Container {}
|
||||
pub struct Container {
|
||||
pub conn: ConnectParams,
|
||||
pub proc: Arc<Child>,
|
||||
pub selection: Selection,
|
||||
}
|
||||
|
||||
impl Container {
|
||||
/// Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs.
|
||||
@@ -59,10 +70,10 @@ impl Container {
|
||||
/// * `target` - Target build stage to build.
|
||||
pub fn build(
|
||||
&self,
|
||||
context: DirectoryID,
|
||||
dockerfile: Option<String>,
|
||||
build_args: Option<Vec<BuildArg>>,
|
||||
target: Option<String>,
|
||||
_context: DirectoryID,
|
||||
_dockerfile: Option<String>,
|
||||
_build_args: Option<Vec<BuildArg>>,
|
||||
_target: Option<String>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
@@ -73,7 +84,7 @@ impl Container {
|
||||
}
|
||||
|
||||
/// Retrieves a directory at the given path. Mounts are included.
|
||||
pub fn directory(&self, path: String) -> Directory {
|
||||
pub fn directory(&self, _path: String) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -83,7 +94,7 @@ impl Container {
|
||||
}
|
||||
|
||||
/// Retrieves the value of the specified environment variable.
|
||||
pub fn env_variable(&self, name: String) -> Option<String> {
|
||||
pub fn env_variable(&self, _name: String) -> Option<String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -105,12 +116,19 @@ impl Container {
|
||||
pub fn exec(
|
||||
&self,
|
||||
args: Option<Vec<String>>,
|
||||
stdin: Option<String>,
|
||||
redirect_stdout: Option<String>,
|
||||
redirect_stderr: Option<String>,
|
||||
experimental_privileged_nesting: Option<Boolean>,
|
||||
_stdin: Option<String>,
|
||||
_redirect_stdout: Option<String>,
|
||||
_redirect_stderr: Option<String>,
|
||||
_experimental_privileged_nesting: Option<Boolean>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
let query = self.selection.select("exec");
|
||||
let query = query.arg("args", args).unwrap();
|
||||
|
||||
Container {
|
||||
conn: self.conn.clone(),
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
}
|
||||
}
|
||||
|
||||
/// Exit code of the last executed command. Zero means success.
|
||||
@@ -127,12 +145,12 @@ impl Container {
|
||||
/// Path can be relative to the engine's workdir or absolute.
|
||||
/// * `platformVariants` - Identifiers for other platform specific containers.
|
||||
/// Used for multi-platform image.
|
||||
pub fn export(&self, path: String, platform_variants: Option<Vec<ContainerID>>) -> Boolean {
|
||||
pub fn export(&self, _path: String, _platform_variants: Option<Vec<ContainerID>>) -> Boolean {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves a file at the given path. Mounts are included.
|
||||
pub fn file(&self, path: String) -> File {
|
||||
pub fn file(&self, _path: String) -> File {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -142,7 +160,14 @@ impl Container {
|
||||
/// * `address` - Image's address from its registry.
|
||||
/// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
|
||||
pub fn from(&self, address: String) -> Container {
|
||||
todo!()
|
||||
let query = self.selection.select("from");
|
||||
let query = query.arg("address", address).unwrap();
|
||||
|
||||
Container {
|
||||
conn: self.conn.clone(),
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves this container's root filesystem. Mounts are not included.
|
||||
@@ -156,7 +181,7 @@ impl Container {
|
||||
}
|
||||
|
||||
/// Retrieves the value of the specified label.
|
||||
pub fn label(&self, name: String) -> Option<String> {
|
||||
pub fn label(&self, _name: String) -> Option<String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -171,7 +196,7 @@ impl Container {
|
||||
}
|
||||
|
||||
/// Creates a named sub-pipeline
|
||||
pub fn pipeline(&self, name: String, description: Option<String>) -> Container {
|
||||
pub fn pipeline(&self, _name: String, _description: Option<String>) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -187,7 +212,11 @@ impl Container {
|
||||
/// Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
|
||||
/// * `platformVariants` - Identifiers for other platform specific containers.
|
||||
/// Used for multi-platform image.
|
||||
pub fn publish(&self, address: String, platform_variants: Option<Vec<ContainerID>>) -> String {
|
||||
pub fn publish(
|
||||
&self,
|
||||
_address: String,
|
||||
_platform_variants: Option<Vec<ContainerID>>,
|
||||
) -> String {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -205,7 +234,9 @@ impl Container {
|
||||
/// The output stream of the last executed command.
|
||||
/// Null if no command has been executed.
|
||||
pub fn stdout(&self) -> Option<String> {
|
||||
todo!()
|
||||
let query = self.selection.select("stdout");
|
||||
|
||||
query.execute(&graphql_client(&self.conn)).unwrap()
|
||||
}
|
||||
|
||||
/// Retrieves the user to be set for all commands.
|
||||
@@ -214,28 +245,28 @@ impl Container {
|
||||
}
|
||||
|
||||
/// Configures default arguments for future commands.
|
||||
pub fn with_default_args(&self, args: Option<Vec<String>>) -> Container {
|
||||
pub fn with_default_args(&self, _args: Option<Vec<String>>) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a directory written at the given path.
|
||||
pub fn with_directory(
|
||||
&self,
|
||||
path: String,
|
||||
directory: DirectoryID,
|
||||
exclude: Option<Vec<String>>,
|
||||
include: Option<Vec<String>>,
|
||||
_path: String,
|
||||
_directory: DirectoryID,
|
||||
_exclude: Option<Vec<String>>,
|
||||
_include: Option<Vec<String>>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container but with a different command entrypoint.
|
||||
pub fn with_entrypoint(&self, args: Vec<String>) -> Container {
|
||||
pub fn with_entrypoint(&self, _args: Vec<String>) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus the given environment variable.
|
||||
pub fn with_env_variable(&self, name: String, value: String) -> Container {
|
||||
pub fn with_env_variable(&self, _name: String, _value: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -252,111 +283,116 @@ impl Container {
|
||||
pub fn with_exec(
|
||||
&self,
|
||||
args: Vec<String>,
|
||||
stdin: Option<String>,
|
||||
redirect_stdout: Option<String>,
|
||||
redirect_stderr: Option<String>,
|
||||
experimental_privileged_nesting: Option<Boolean>,
|
||||
_stdin: Option<String>,
|
||||
_redirect_stdout: Option<String>,
|
||||
_redirect_stderr: Option<String>,
|
||||
_experimental_privileged_nesting: Option<Boolean>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Initializes this container from this DirectoryID.
|
||||
pub fn with_fs(&self, id: DirectoryID) -> Container {
|
||||
pub fn with_fs(&self, _id: DirectoryID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus the contents of the given file copied to the given path.
|
||||
pub fn with_file(&self, path: String, source: FileID, permissions: Option<Int>) -> Container {
|
||||
pub fn with_file(
|
||||
&self,
|
||||
_path: String,
|
||||
_source: FileID,
|
||||
_permissions: Option<Int>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus the given label.
|
||||
pub fn with_label(&self, name: String, value: String) -> Container {
|
||||
pub fn with_label(&self, _name: String, _value: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a cache volume mounted at the given path.
|
||||
pub fn with_mounted_cache(
|
||||
&self,
|
||||
path: String,
|
||||
cache: CacheID,
|
||||
source: Option<DirectoryID>,
|
||||
_path: String,
|
||||
_cache: CacheID,
|
||||
_source: Option<DirectoryID>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a directory mounted at the given path.
|
||||
pub fn with_mounted_directory(&self, path: String, source: DirectoryID) -> Container {
|
||||
pub fn with_mounted_directory(&self, _path: String, _source: DirectoryID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a file mounted at the given path.
|
||||
pub fn with_mounted_file(&self, path: String, source: FileID) -> Container {
|
||||
pub fn with_mounted_file(&self, _path: String, _source: FileID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a secret mounted into a file at the given path.
|
||||
pub fn with_mounted_secret(&self, path: String, source: SecretID) -> Container {
|
||||
pub fn with_mounted_secret(&self, _path: String, _source: SecretID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a temporary directory mounted at the given path.
|
||||
pub fn with_mounted_temp(&self, path: String) -> Container {
|
||||
pub fn with_mounted_temp(&self, _path: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a new file written at the given path.
|
||||
pub fn with_new_file(
|
||||
&self,
|
||||
path: String,
|
||||
contents: Option<String>,
|
||||
permissions: Option<Int>,
|
||||
_path: String,
|
||||
_contents: Option<String>,
|
||||
_permissions: Option<Int>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Initializes this container from this DirectoryID.
|
||||
pub fn with_rootfs(&self, id: DirectoryID) -> Container {
|
||||
pub fn with_rootfs(&self, _id: DirectoryID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus an env variable containing the given secret.
|
||||
pub fn with_secret_variable(&self, name: String, secret: SecretID) -> Container {
|
||||
pub fn with_secret_variable(&self, _name: String, _secret: SecretID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a socket forwarded to the given Unix socket path.
|
||||
pub fn with_unix_socket(&self, path: String, source: SocketID) -> Container {
|
||||
pub fn with_unix_socket(&self, _path: String, _source: SocketID) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this containers with a different command user.
|
||||
pub fn with_user(&self, name: String) -> Container {
|
||||
pub fn with_user(&self, _name: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container with a different working directory.
|
||||
pub fn with_workdir(&self, path: String) -> Container {
|
||||
pub fn with_workdir(&self, _path: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container minus the given environment variable.
|
||||
pub fn without_env_variable(&self, name: String) -> Container {
|
||||
pub fn without_env_variable(&self, _name: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container minus the given environment label.
|
||||
pub fn without_label(&self, name: String) -> Container {
|
||||
pub fn without_label(&self, _name: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container after unmounting everything at the given path.
|
||||
pub fn without_mount(&self, path: String) -> Container {
|
||||
pub fn without_mount(&self, _path: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this container with a previously added Unix socket removed.
|
||||
pub fn without_unix_socket(&self, path: String) -> Container {
|
||||
pub fn without_unix_socket(&self, _path: String) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -373,12 +409,12 @@ pub struct Directory {}
|
||||
|
||||
impl Directory {
|
||||
/// Gets the difference between this directory and an another directory.
|
||||
pub fn diff(&self, other: DirectoryID) -> Directory {
|
||||
pub fn diff(&self, _other: DirectoryID) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves a directory at the given path.
|
||||
pub fn directory(&self, path: String) -> Directory {
|
||||
pub fn directory(&self, _path: String) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -392,26 +428,26 @@ impl Directory {
|
||||
/// * `target` - Target build stage to build.
|
||||
pub fn docker_build(
|
||||
&self,
|
||||
dockerfile: Option<String>,
|
||||
platform: Option<Platform>,
|
||||
build_args: Option<Vec<BuildArg>>,
|
||||
target: Option<String>,
|
||||
_dockerfile: Option<String>,
|
||||
_platform: Option<Platform>,
|
||||
_build_args: Option<Vec<BuildArg>>,
|
||||
_target: Option<String>,
|
||||
) -> Container {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Returns a list of files and directories at the given path.
|
||||
pub fn entries(&self, path: Option<String>) -> Vec<String> {
|
||||
pub fn entries(&self, _path: Option<String>) -> Vec<String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Writes the contents of the directory to a path on the host.
|
||||
pub fn export(&self, path: String) -> Boolean {
|
||||
pub fn export(&self, _path: String) -> Boolean {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves a file at the given path.
|
||||
pub fn file(&self, path: String) -> File {
|
||||
pub fn file(&self, _path: String) -> File {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -421,12 +457,12 @@ impl Directory {
|
||||
}
|
||||
|
||||
/// load a project's metadata
|
||||
pub fn load_project(&self, config_path: String) -> Project {
|
||||
pub fn load_project(&self, _config_path: String) -> Project {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Creates a named sub-pipeline.
|
||||
pub fn pipeline(&self, name: String, description: Option<String>) -> Directory {
|
||||
pub fn pipeline(&self, _name: String, _description: Option<String>) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -439,46 +475,51 @@ impl Directory {
|
||||
/// (e.g. ["app/", "package.*"]).
|
||||
pub fn with_directory(
|
||||
&self,
|
||||
path: String,
|
||||
directory: DirectoryID,
|
||||
exclude: Option<Vec<String>>,
|
||||
include: Option<Vec<String>>,
|
||||
_path: String,
|
||||
_directory: DirectoryID,
|
||||
_exclude: Option<Vec<String>>,
|
||||
_include: Option<Vec<String>>,
|
||||
) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this directory plus the contents of the given file copied to the given path.
|
||||
pub fn with_file(&self, path: String, source: FileID, permissions: Option<Int>) -> Directory {
|
||||
pub fn with_file(
|
||||
&self,
|
||||
_path: String,
|
||||
_source: FileID,
|
||||
_permissions: Option<Int>,
|
||||
) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this directory plus a new directory created at the given path.
|
||||
pub fn with_new_directory(&self, path: String, permissions: Option<Int>) -> Directory {
|
||||
pub fn with_new_directory(&self, _path: String, _permissions: Option<Int>) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this directory plus a new file written at the given path.
|
||||
pub fn with_new_file(
|
||||
&self,
|
||||
path: String,
|
||||
contents: String,
|
||||
permissions: Option<Int>,
|
||||
_path: String,
|
||||
_contents: String,
|
||||
_permissions: Option<Int>,
|
||||
) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch.
|
||||
pub fn with_timestamps(&self, timestamp: Int) -> Directory {
|
||||
pub fn with_timestamps(&self, _timestamp: Int) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this directory with the directory at the given path removed.
|
||||
pub fn without_directory(&self, path: String) -> Directory {
|
||||
pub fn without_directory(&self, _path: String) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves this directory with the file at the given path removed.
|
||||
pub fn without_file(&self, path: String) -> Directory {
|
||||
pub fn without_file(&self, _path: String) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -512,7 +553,7 @@ impl File {
|
||||
}
|
||||
|
||||
/// Writes the file to a file path on the host.
|
||||
pub fn export(&self, path: String) -> Boolean {
|
||||
pub fn export(&self, _path: String) -> Boolean {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -532,7 +573,7 @@ impl File {
|
||||
}
|
||||
|
||||
/// Retrieves this file with its created/modified timestamps set to the given time, in seconds from the Unix epoch.
|
||||
pub fn with_timestamps(&self, timestamp: Int) -> File {
|
||||
pub fn with_timestamps(&self, _timestamp: Int) -> File {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -551,8 +592,8 @@ impl GitRef {
|
||||
/// The filesystem tree at this ref.
|
||||
pub fn tree(
|
||||
&self,
|
||||
ssh_known_hosts: Option<String>,
|
||||
ssh_auth_socket: Option<SocketID>,
|
||||
_ssh_known_hosts: Option<String>,
|
||||
_ssh_auth_socket: Option<SocketID>,
|
||||
) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
@@ -565,7 +606,7 @@ pub struct GitRepository {}
|
||||
|
||||
impl GitRepository {
|
||||
/// Returns details on one branch.
|
||||
pub fn branch(&self, name: String) -> GitRef {
|
||||
pub fn branch(&self, _name: String) -> GitRef {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -575,12 +616,12 @@ impl GitRepository {
|
||||
}
|
||||
|
||||
/// Returns details on one commit.
|
||||
pub fn commit(&self, id: String) -> GitRef {
|
||||
pub fn commit(&self, _id: String) -> GitRef {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Returns details on one tag.
|
||||
pub fn tag(&self, name: String) -> GitRef {
|
||||
pub fn tag(&self, _name: String) -> GitRef {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -599,25 +640,29 @@ impl Host {
|
||||
/// Accesses a directory on the host.
|
||||
pub fn directory(
|
||||
&self,
|
||||
path: String,
|
||||
exclude: Option<Vec<String>>,
|
||||
include: Option<Vec<String>>,
|
||||
_path: String,
|
||||
_exclude: Option<Vec<String>>,
|
||||
_include: Option<Vec<String>>,
|
||||
) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Accesses an environment variable on the host.
|
||||
pub fn env_variable(&self, name: String) -> Option<HostVariable> {
|
||||
pub fn env_variable(&self, _name: String) -> Option<HostVariable> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Accesses a Unix socket on the host.
|
||||
pub fn unix_socket(&self, path: String) -> Socket {
|
||||
pub fn unix_socket(&self, _path: String) -> Socket {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Retrieves the current working directory on the host.
|
||||
pub fn workdir(&self, exclude: Option<Vec<String>>, include: Option<Vec<String>>) -> Directory {
|
||||
pub fn workdir(
|
||||
&self,
|
||||
_exclude: Option<Vec<String>>,
|
||||
_include: Option<Vec<String>>,
|
||||
) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -696,22 +741,32 @@ impl Project {
|
||||
impl Input for Project {}
|
||||
|
||||
///
|
||||
pub struct Query {}
|
||||
pub struct Query {
|
||||
pub conn: ConnectParams,
|
||||
pub proc: Arc<Child>,
|
||||
pub selection: Selection,
|
||||
}
|
||||
|
||||
impl Query {
|
||||
/// Constructs a cache volume for a given cache key.
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `key` - A string identifier to target this cache volume (e.g. "myapp-cache").
|
||||
pub fn cache_volume(&self, key: String) -> CacheVolume {
|
||||
pub fn cache_volume(&self, _key: String) -> CacheVolume {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Loads a container from ID.
|
||||
/// Null ID returns an empty container (scratch).
|
||||
/// Optional platform argument initializes new containers to execute and publish as that platform. Platform defaults to that of the builder's host.
|
||||
pub fn container(&self, id: Option<ContainerID>, platform: Option<Platform>) -> Container {
|
||||
todo!()
|
||||
pub fn container(&self, _id: Option<ContainerID>, _platform: Option<Platform>) -> Container {
|
||||
let query = self.selection.select("container");
|
||||
|
||||
return Container {
|
||||
conn: self.conn.clone(),
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
};
|
||||
}
|
||||
|
||||
/// The default platform of the builder.
|
||||
@@ -720,17 +775,17 @@ impl Query {
|
||||
}
|
||||
|
||||
/// Load a directory by ID. No argument produces an empty directory.
|
||||
pub fn directory(&self, id: Option<DirectoryID>) -> Directory {
|
||||
pub fn directory(&self, _id: Option<DirectoryID>) -> Directory {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Loads a file by ID.
|
||||
pub fn file(&self, id: FileID) -> Option<File> {
|
||||
pub fn file(&self, _id: FileID) -> Option<File> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Queries a git repository.
|
||||
pub fn git(&self, url: String, keep_git_dir: Option<Boolean>) -> GitRepository {
|
||||
pub fn git(&self, _url: String, _keep_git_dir: Option<Boolean>) -> GitRepository {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -740,27 +795,27 @@ impl Query {
|
||||
}
|
||||
|
||||
/// Returns a file containing an http remote url content.
|
||||
pub fn http(&self, url: String) -> File {
|
||||
pub fn http(&self, _url: String) -> File {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Creates a named sub-pipeline
|
||||
pub fn pipeline(&self, name: String, description: Option<String>) -> Query {
|
||||
pub fn pipeline(&self, _name: String, _description: Option<String>) -> Query {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Look up a project by name
|
||||
pub fn project(&self, name: String) -> Project {
|
||||
pub fn project(&self, _name: String) -> Project {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Loads a secret from its ID.
|
||||
pub fn secret(&self, id: SecretID) -> Secret {
|
||||
pub fn secret(&self, _id: SecretID) -> Secret {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Loads a socket by its ID.
|
||||
pub fn socket(&self, id: Option<SocketID>) -> Socket {
|
||||
pub fn socket(&self, _id: Option<SocketID>) -> Socket {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod client;
|
||||
pub mod gen;
|
||||
mod querybuilder;
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
use std::{
|
||||
any::Any,
|
||||
collections::HashMap,
|
||||
ops::Add,
|
||||
rc::Rc,
|
||||
sync::{Arc, Once},
|
||||
};
|
||||
use std::{collections::HashMap, ops::Add, sync::Arc};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::task::block_in_place;
|
||||
|
||||
pub fn query() -> Selection {
|
||||
Selection {
|
||||
name: None,
|
||||
alias: None,
|
||||
args: None,
|
||||
prev: None,
|
||||
Selection::default()
|
||||
}
|
||||
|
||||
impl Default for Selection {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: Default::default(),
|
||||
alias: Default::default(),
|
||||
args: Default::default(),
|
||||
prev: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +93,27 @@ impl Selection {
|
||||
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
|
||||
}
|
||||
|
||||
pub fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<Option<D>>
|
||||
where
|
||||
D: for<'de> Deserialize<'de>,
|
||||
{
|
||||
let query = self.build()?;
|
||||
|
||||
let basic = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
dbg!(&query);
|
||||
|
||||
let resp: Option<D> = match basic.block_on(gql_client.query(&query)) {
|
||||
Ok(r) => r,
|
||||
Err(e) => eyre::bail!(e),
|
||||
};
|
||||
|
||||
Ok(resp)
|
||||
}
|
||||
|
||||
fn path(&self) -> Vec<Selection> {
|
||||
let mut selections: Vec<Selection> = vec![];
|
||||
let mut cur = self;
|
||||
|
||||
20
crates/dagger-sdk/tests/mod.rs
Normal file
20
crates/dagger-sdk/tests/mod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use dagger_sdk::client::connect;
|
||||
|
||||
#[test]
|
||||
fn test_example_container() {
|
||||
let client = connect().unwrap();
|
||||
|
||||
let alpine = client.container(None, None).from("alpine:3.16.2".into());
|
||||
|
||||
let out = alpine
|
||||
.exec(
|
||||
Some(vec!["cat".into(), "/etc/alpine-release".into()]),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.stdout();
|
||||
|
||||
assert_eq!(out, Some("3.16.2".to_string()))
|
||||
}
|
||||
@@ -2,8 +2,9 @@ use std::io::Write;
|
||||
|
||||
use clap::{Arg, ArgMatches};
|
||||
use dagger_codegen::codegen::CodeGeneration;
|
||||
|
||||
use crate::{config::Config, engine::Engine, session::Session};
|
||||
use dagger_core::config::Config;
|
||||
use dagger_core::engine::Engine;
|
||||
use dagger_core::session::Session;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct GenerateCommand;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn connect() -> eyre::Result<Client> {
|
||||
Client::new()
|
||||
}
|
||||
|
||||
struct InnerClient {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct Client {
|
||||
inner: Arc<InnerClient>,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new() -> eyre::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: Arc::new(InnerClient {}),
|
||||
})
|
||||
}
|
||||
|
||||
// pub fn container(&self) -> Container {}
|
||||
}
|
||||
@@ -2,14 +2,6 @@ use cli::Cli;
|
||||
|
||||
pub mod cli;
|
||||
mod cli_generate;
|
||||
mod cli_session;
|
||||
mod config;
|
||||
mod connect_params;
|
||||
pub mod dagger;
|
||||
mod downloader;
|
||||
mod engine;
|
||||
mod schema;
|
||||
mod session;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let args = std::env::args();
|
||||
|
||||
Reference in New Issue
Block a user