Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
move code to dagger-core
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Feb 5, 2023
1 parent 9f0021b commit ec0d0b2
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 32 deletions.
85 changes: 71 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions crates/dagger-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions src/dagger.rs → crates/dagger-core/src/dagger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ impl Client {
inner: Arc::new(InnerClient {}),
})
}

// pub fn container(&self) -> Container {}
}
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions crates/dagger-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
pub mod cli_session;
pub mod config;
pub mod connect_params;
pub mod dagger;
pub mod downloader;
pub mod engine;
pub mod introspection;
pub mod schema;
pub mod session;

pub struct Scalar(String);

Expand Down
3 changes: 1 addition & 2 deletions src/schema.rs → crates/dagger-core/src/schema.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
5 changes: 2 additions & 3 deletions src/session.rs → crates/dagger-core/src/session.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/dagger-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ description = "A dagger sdk for rust, written in rust"
[dependencies]
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"
10 changes: 10 additions & 0 deletions crates/dagger-sdk/examples_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[cfg(example_test)]
mod examples {
#[test]
fn test_example_container() {
unimplemented!();
}
}



17 changes: 16 additions & 1 deletion crates/dagger-sdk/src/querybuilder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::HashMap, ops::Add, sync::Arc};

use serde::Serialize;
use futures::executor::block_on;
use serde::{Deserialize, Serialize};

pub fn query() -> Selection {
Selection::default()
Expand Down Expand Up @@ -92,6 +93,20 @@ 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 resp: Option<D> = match 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;
Expand Down
5 changes: 3 additions & 2 deletions src/cli_generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ec0d0b2

Please sign in to comment.