mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-04-19 20:19:50 +02:00
Compare commits
No commits in common. "main" and "dagger-sdk-v0.2.22" have entirely different histories.
main
...
dagger-sdk
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -334,7 +334,6 @@ dependencies = [
|
|||||||
"sha2",
|
"sha2",
|
||||||
"tar",
|
"tar",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
@ -353,7 +352,6 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
@ -23,4 +23,3 @@ tracing-subscriber = { version = "0.3.16", features = [
|
|||||||
"tracing-log",
|
"tracing-log",
|
||||||
"tracing",
|
"tracing",
|
||||||
] }
|
] }
|
||||||
thiserror = "1.0.40"
|
|
||||||
|
68
README.md
68
README.md
@ -1,7 +1,69 @@
|
|||||||
# dagger-sdk
|
# dagger-sdk
|
||||||
|
|
||||||
A dagger sdk written in rust
|
A dagger sdk written in rust for rust.
|
||||||
|
|
||||||
## Disclaimer:
|
## Plan for next release
|
||||||
|
|
||||||
Repository has moved to: https://github.com/dagger/dagger/tree/main/sdk/rust
|
- [ ] Introduce [thiserror](https://docs.rs/thiserror/latest/thiserror/) for
|
||||||
|
better errors
|
||||||
|
- [ ] Add compatibility with `dagger run`
|
||||||
|
- [ ] Add open telemetry tracing to the sdk
|
||||||
|
- [ ] Remove `id().await?` from passing to other dagger graphs, this should make
|
||||||
|
the design much cleaner
|
||||||
|
- [ ] Start MkBook on how to actually use the sdk
|
||||||
|
- [ ] Update to newest upstream release
|
||||||
|
- [ ] Fix bugs
|
||||||
|
- [x] Run in conjunction with golang and other sdks
|
||||||
|
- [ ] Stabilize the initial `Arc<Query>` model into something more extensible
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
See [examples](./crates/dagger-sdk/examples/)
|
||||||
|
|
||||||
|
Run them like so
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run --example first-pipeline
|
||||||
|
```
|
||||||
|
|
||||||
|
The examples match the folder name in each directory in examples
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Simply install like:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo add dagger-sdk
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
```rust
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> eyre::Result<()> {
|
||||||
|
let client = dagger_sdk::connect().await?;
|
||||||
|
|
||||||
|
let version = client
|
||||||
|
.container()
|
||||||
|
.from("golang:1.19")
|
||||||
|
.with_exec(vec!["go", "version"])
|
||||||
|
.stdout()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("Hello from Dagger and {}", version.trim());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
And run it like a normal application:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contributing
|
||||||
|
|
||||||
|
See [CONTRIBUTING](./CONTRIBUTING.md)
|
||||||
|
|
||||||
|
or just cargo make codegen
|
||||||
|
@ -13,7 +13,7 @@ use self::generator::DynGenerator;
|
|||||||
fn set_schema_parents(mut schema: Schema) -> Schema {
|
fn set_schema_parents(mut schema: Schema) -> Schema {
|
||||||
for t in schema.types.as_mut().into_iter().flatten().flatten() {
|
for t in schema.types.as_mut().into_iter().flatten().flatten() {
|
||||||
let t_parent = t.full_type.clone();
|
let t_parent = t.full_type.clone();
|
||||||
for field in t.full_type.fields.as_mut().into_iter().flatten() {
|
for mut field in t.full_type.fields.as_mut().into_iter().flatten() {
|
||||||
field.parent_type = Some(t_parent.clone());
|
field.parent_type = Some(t_parent.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,10 +235,8 @@ fn render_output_type(funcs: &CommonFunctions, type_ref: &TypeRef) -> rust::Toke
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let dagger_error = rust::import("crate::errors", "DaggerError");
|
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
Result<$output_type, $dagger_error>
|
eyre::Result<$output_type>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ serde_json = { workspace = true }
|
|||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
tracing-subscriber = { workspace = true }
|
tracing-subscriber = { workspace = true }
|
||||||
thiserror.workspace = true
|
|
||||||
|
|
||||||
base64 = "0.21.0"
|
base64 = "0.21.0"
|
||||||
dirs = "4.0.0"
|
dirs = "4.0.0"
|
||||||
|
@ -15,7 +15,7 @@ pub struct GraphQLError {
|
|||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct GraphQLErrorMessage {
|
pub struct GraphQLErrorMessage {
|
||||||
pub message: String,
|
message: String,
|
||||||
locations: Option<Vec<GraphQLErrorLocation>>,
|
locations: Option<Vec<GraphQLErrorLocation>>,
|
||||||
extensions: Option<HashMap<String, String>>,
|
extensions: Option<HashMap<String, String>>,
|
||||||
path: Option<Vec<GraphQLErrorPathParam>>,
|
path: Option<Vec<GraphQLErrorPathParam>>,
|
||||||
|
@ -4,14 +4,13 @@ use std::sync::Arc;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use base64::engine::general_purpose;
|
use base64::engine::general_purpose;
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
use crate::connect_params::ConnectParams;
|
use crate::connect_params::ConnectParams;
|
||||||
use crate::gql_client::{ClientConfig, GQLClient};
|
use crate::gql_client::{ClientConfig, GQLClient};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait GraphQLClient {
|
pub trait GraphQLClient {
|
||||||
async fn query(&self, query: &str) -> Result<Option<serde_json::Value>, GraphQLError>;
|
async fn query(&self, query: &str) -> eyre::Result<Option<serde_json::Value>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type DynGraphQLClient = Arc<dyn GraphQLClient + Send + Sync>;
|
pub type DynGraphQLClient = Arc<dyn GraphQLClient + Send + Sync>;
|
||||||
@ -41,50 +40,13 @@ impl DefaultGraphQLClient {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl GraphQLClient for DefaultGraphQLClient {
|
impl GraphQLClient for DefaultGraphQLClient {
|
||||||
async fn query(&self, query: &str) -> Result<Option<serde_json::Value>, GraphQLError> {
|
async fn query(&self, query: &str) -> eyre::Result<Option<serde_json::Value>> {
|
||||||
let res: Option<serde_json::Value> =
|
let res: Option<serde_json::Value> = self
|
||||||
self.client.query(&query).await.map_err(map_graphql_error)?;
|
.client
|
||||||
|
.query(&query)
|
||||||
|
.await
|
||||||
|
.map_err(|r| eyre::anyhow!(r.to_string()))?;
|
||||||
|
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_graphql_error(gql_error: crate::gql_client::GraphQLError) -> GraphQLError {
|
|
||||||
let message = gql_error.message().to_string();
|
|
||||||
let json = gql_error.json();
|
|
||||||
|
|
||||||
if let Some(json) = json {
|
|
||||||
if !json.is_empty() {
|
|
||||||
return GraphQLError::DomainError {
|
|
||||||
message,
|
|
||||||
fields: GraphqlErrorMessages(json.into_iter().map(|e| e.message).collect()),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphQLError::HttpError(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum GraphQLError {
|
|
||||||
#[error("http error: {0}")]
|
|
||||||
HttpError(String),
|
|
||||||
#[error("domain error:\n{message}\n{fields}")]
|
|
||||||
DomainError {
|
|
||||||
message: String,
|
|
||||||
fields: GraphqlErrorMessages,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct GraphqlErrorMessages(Vec<String>);
|
|
||||||
|
|
||||||
impl std::fmt::Display for GraphqlErrorMessages {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
for error in self.0.iter() {
|
|
||||||
f.write_fmt(format_args!("{error}\n"))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,6 @@ serde = { workspace = true }
|
|||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-subscriber.workspace = true
|
tracing-subscriber.workspace = true
|
||||||
thiserror.workspace = true
|
|
||||||
|
|
||||||
futures = "0.3.28"
|
futures = "0.3.28"
|
||||||
derive_builder = "0.12.0"
|
derive_builder = "0.12.0"
|
||||||
|
@ -5,24 +5,20 @@ use dagger_core::graphql_client::DefaultGraphQLClient;
|
|||||||
use dagger_core::config::Config;
|
use dagger_core::config::Config;
|
||||||
use dagger_core::engine::Engine as DaggerEngine;
|
use dagger_core::engine::Engine as DaggerEngine;
|
||||||
|
|
||||||
use crate::errors::ConnectError;
|
|
||||||
use crate::gen::Query;
|
use crate::gen::Query;
|
||||||
use crate::logging::StdLogger;
|
use crate::logging::StdLogger;
|
||||||
use crate::querybuilder::query;
|
use crate::querybuilder::query;
|
||||||
|
|
||||||
pub type DaggerConn = Arc<Query>;
|
pub type DaggerConn = Arc<Query>;
|
||||||
|
|
||||||
pub async fn connect() -> Result<DaggerConn, ConnectError> {
|
pub async fn connect() -> eyre::Result<DaggerConn> {
|
||||||
let cfg = Config::new(None, None, None, None, Some(Arc::new(StdLogger::default())));
|
let cfg = Config::new(None, None, None, None, Some(Arc::new(StdLogger::default())));
|
||||||
|
|
||||||
connect_opts(cfg).await
|
connect_opts(cfg).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn connect_opts(cfg: Config) -> Result<DaggerConn, ConnectError> {
|
pub async fn connect_opts(cfg: Config) -> eyre::Result<DaggerConn> {
|
||||||
let (conn, proc) = DaggerEngine::new()
|
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
|
||||||
.start(&cfg)
|
|
||||||
.await
|
|
||||||
.map_err(ConnectError::FailedToConnect)?;
|
|
||||||
|
|
||||||
Ok(Arc::new(Query {
|
Ok(Arc::new(Query {
|
||||||
proc: proc.map(|p| Arc::new(p)),
|
proc: proc.map(|p| Arc::new(p)),
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum ConnectError {
|
|
||||||
#[error("failed to connect to dagger engine")]
|
|
||||||
FailedToConnect(#[source] eyre::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum DaggerError {
|
|
||||||
#[error("failed to build dagger internal graph")]
|
|
||||||
Build(#[source] eyre::Error),
|
|
||||||
#[error("failed to parse input type")]
|
|
||||||
Serialize(#[source] eyre::Error),
|
|
||||||
#[error("failed to query dagger engine: {0}")]
|
|
||||||
Query(#[source] dagger_core::graphql_client::GraphQLError),
|
|
||||||
#[error("failed to unpack response")]
|
|
||||||
Unpack(#[source] DaggerUnpackError),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum DaggerUnpackError {
|
|
||||||
#[error("Too many nested objects inside graphql response")]
|
|
||||||
TooManyNestedObjects,
|
|
||||||
#[error("failed to deserialize response")]
|
|
||||||
Deserialize(#[source] serde_json::Error),
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
use crate::errors::DaggerError;
|
|
||||||
use crate::querybuilder::Selection;
|
use crate::querybuilder::Selection;
|
||||||
use dagger_core::graphql_client::DynGraphQLClient;
|
use dagger_core::graphql_client::DynGraphQLClient;
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
@ -122,7 +121,7 @@ pub struct CacheVolume {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CacheVolume {
|
impl CacheVolume {
|
||||||
pub async fn id(&self) -> Result<CacheId, DaggerError> {
|
pub async fn id(&self) -> eyre::Result<CacheId> {
|
||||||
let query = self.selection.select("id");
|
let query = self.selection.select("id");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -398,7 +397,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Retrieves default arguments for future commands.
|
/// Retrieves default arguments for future commands.
|
||||||
pub async fn default_args(&self) -> Result<Vec<String>, DaggerError> {
|
pub async fn default_args(&self) -> eyre::Result<Vec<String>> {
|
||||||
let query = self.selection.select("defaultArgs");
|
let query = self.selection.select("defaultArgs");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -428,7 +427,7 @@ impl Container {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub async fn endpoint(&self) -> Result<String, DaggerError> {
|
pub async fn endpoint(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("endpoint");
|
let query = self.selection.select("endpoint");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -442,10 +441,7 @@ impl Container {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub async fn endpoint_opts<'a>(
|
pub async fn endpoint_opts<'a>(&self, opts: ContainerEndpointOpts<'a>) -> eyre::Result<String> {
|
||||||
&self,
|
|
||||||
opts: ContainerEndpointOpts<'a>,
|
|
||||||
) -> Result<String, DaggerError> {
|
|
||||||
let mut query = self.selection.select("endpoint");
|
let mut query = self.selection.select("endpoint");
|
||||||
|
|
||||||
if let Some(port) = opts.port {
|
if let Some(port) = opts.port {
|
||||||
@ -458,7 +454,7 @@ impl Container {
|
|||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// Retrieves entrypoint to be prepended to the arguments of all commands.
|
/// Retrieves entrypoint to be prepended to the arguments of all commands.
|
||||||
pub async fn entrypoint(&self) -> Result<Vec<String>, DaggerError> {
|
pub async fn entrypoint(&self) -> eyre::Result<Vec<String>> {
|
||||||
let query = self.selection.select("entrypoint");
|
let query = self.selection.select("entrypoint");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -468,7 +464,7 @@ impl Container {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `name` - The name of the environment variable to retrieve (e.g., "PATH").
|
/// * `name` - The name of the environment variable to retrieve (e.g., "PATH").
|
||||||
pub async fn env_variable(&self, name: impl Into<String>) -> Result<String, DaggerError> {
|
pub async fn env_variable(&self, name: impl Into<String>) -> eyre::Result<String> {
|
||||||
let mut query = self.selection.select("envVariable");
|
let mut query = self.selection.select("envVariable");
|
||||||
|
|
||||||
query = query.arg("name", name.into());
|
query = query.arg("name", name.into());
|
||||||
@ -535,7 +531,7 @@ impl Container {
|
|||||||
}
|
}
|
||||||
/// Exit code of the last executed command. Zero means success.
|
/// Exit code of the last executed command. Zero means success.
|
||||||
/// Will execute default command if none is set, or error if there's no default.
|
/// Will execute default command if none is set, or error if there's no default.
|
||||||
pub async fn exit_code(&self) -> Result<isize, DaggerError> {
|
pub async fn exit_code(&self) -> eyre::Result<isize> {
|
||||||
let query = self.selection.select("exitCode");
|
let query = self.selection.select("exitCode");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -549,7 +545,7 @@ impl Container {
|
|||||||
/// * `path` - Host's destination path (e.g., "./tarball").
|
/// * `path` - Host's destination path (e.g., "./tarball").
|
||||||
/// Path can be relative to the engine's workdir or absolute.
|
/// Path can be relative to the engine's workdir or absolute.
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub async fn export(&self, path: impl Into<String>) -> Result<bool, DaggerError> {
|
pub async fn export(&self, path: impl Into<String>) -> eyre::Result<bool> {
|
||||||
let mut query = self.selection.select("export");
|
let mut query = self.selection.select("export");
|
||||||
|
|
||||||
query = query.arg("path", path.into());
|
query = query.arg("path", path.into());
|
||||||
@ -570,7 +566,7 @@ impl Container {
|
|||||||
&self,
|
&self,
|
||||||
path: impl Into<String>,
|
path: impl Into<String>,
|
||||||
opts: ContainerExportOpts,
|
opts: ContainerExportOpts,
|
||||||
) -> Result<bool, DaggerError> {
|
) -> eyre::Result<bool> {
|
||||||
let mut query = self.selection.select("export");
|
let mut query = self.selection.select("export");
|
||||||
|
|
||||||
query = query.arg("path", path.into());
|
query = query.arg("path", path.into());
|
||||||
@ -638,19 +634,19 @@ impl Container {
|
|||||||
}
|
}
|
||||||
/// Retrieves a hostname which can be used by clients to reach this container.
|
/// Retrieves a hostname which can be used by clients to reach this container.
|
||||||
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||||
pub async fn hostname(&self) -> Result<String, DaggerError> {
|
pub async fn hostname(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("hostname");
|
let query = self.selection.select("hostname");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// A unique identifier for this container.
|
/// A unique identifier for this container.
|
||||||
pub async fn id(&self) -> Result<ContainerId, DaggerError> {
|
pub async fn id(&self) -> eyre::Result<ContainerId> {
|
||||||
let query = self.selection.select("id");
|
let query = self.selection.select("id");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The unique image reference which can only be retrieved immediately after the 'Container.From' call.
|
/// The unique image reference which can only be retrieved immediately after the 'Container.From' call.
|
||||||
pub async fn image_ref(&self) -> Result<String, DaggerError> {
|
pub async fn image_ref(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("imageRef");
|
let query = self.selection.select("imageRef");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -698,7 +694,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Retrieves the value of the specified label.
|
/// Retrieves the value of the specified label.
|
||||||
pub async fn label(&self, name: impl Into<String>) -> Result<String, DaggerError> {
|
pub async fn label(&self, name: impl Into<String>) -> eyre::Result<String> {
|
||||||
let mut query = self.selection.select("label");
|
let mut query = self.selection.select("label");
|
||||||
|
|
||||||
query = query.arg("name", name.into());
|
query = query.arg("name", name.into());
|
||||||
@ -716,7 +712,7 @@ impl Container {
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
/// Retrieves the list of paths where a directory is mounted.
|
/// Retrieves the list of paths where a directory is mounted.
|
||||||
pub async fn mounts(&self) -> Result<Vec<String>, DaggerError> {
|
pub async fn mounts(&self) -> eyre::Result<Vec<String>> {
|
||||||
let query = self.selection.select("mounts");
|
let query = self.selection.select("mounts");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -767,7 +763,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// The platform this container executes and publishes as.
|
/// The platform this container executes and publishes as.
|
||||||
pub async fn platform(&self) -> Result<Platform, DaggerError> {
|
pub async fn platform(&self) -> eyre::Result<Platform> {
|
||||||
let query = self.selection.select("platform");
|
let query = self.selection.select("platform");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -782,7 +778,7 @@ impl Container {
|
|||||||
///
|
///
|
||||||
/// Formatted as [host]/[user]/[repo]:[tag] (e.g. "docker.io/dagger/dagger:main").
|
/// Formatted as [host]/[user]/[repo]:[tag] (e.g. "docker.io/dagger/dagger:main").
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub async fn publish(&self, address: impl Into<String>) -> Result<String, DaggerError> {
|
pub async fn publish(&self, address: impl Into<String>) -> eyre::Result<String> {
|
||||||
let mut query = self.selection.select("publish");
|
let mut query = self.selection.select("publish");
|
||||||
|
|
||||||
query = query.arg("address", address.into());
|
query = query.arg("address", address.into());
|
||||||
@ -804,7 +800,7 @@ impl Container {
|
|||||||
&self,
|
&self,
|
||||||
address: impl Into<String>,
|
address: impl Into<String>,
|
||||||
opts: ContainerPublishOpts,
|
opts: ContainerPublishOpts,
|
||||||
) -> Result<String, DaggerError> {
|
) -> eyre::Result<String> {
|
||||||
let mut query = self.selection.select("publish");
|
let mut query = self.selection.select("publish");
|
||||||
|
|
||||||
query = query.arg("address", address.into());
|
query = query.arg("address", address.into());
|
||||||
@ -826,20 +822,20 @@ impl Container {
|
|||||||
}
|
}
|
||||||
/// The error stream of the last executed command.
|
/// The error stream of the last executed command.
|
||||||
/// Will execute default command if none is set, or error if there's no default.
|
/// Will execute default command if none is set, or error if there's no default.
|
||||||
pub async fn stderr(&self) -> Result<String, DaggerError> {
|
pub async fn stderr(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("stderr");
|
let query = self.selection.select("stderr");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The output stream of the last executed command.
|
/// The output stream of the last executed command.
|
||||||
/// Will execute default command if none is set, or error if there's no default.
|
/// Will execute default command if none is set, or error if there's no default.
|
||||||
pub async fn stdout(&self) -> Result<String, DaggerError> {
|
pub async fn stdout(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("stdout");
|
let query = self.selection.select("stdout");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// Retrieves the user to be set for all commands.
|
/// Retrieves the user to be set for all commands.
|
||||||
pub async fn user(&self) -> Result<String, DaggerError> {
|
pub async fn user(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("user");
|
let query = self.selection.select("user");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -1724,7 +1720,7 @@ impl Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Retrieves the working directory for all commands.
|
/// Retrieves the working directory for all commands.
|
||||||
pub async fn workdir(&self) -> Result<String, DaggerError> {
|
pub async fn workdir(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("workdir");
|
let query = self.selection.select("workdir");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -1886,7 +1882,7 @@ impl Directory {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||||
pub async fn entries(&self) -> Result<Vec<String>, DaggerError> {
|
pub async fn entries(&self) -> eyre::Result<Vec<String>> {
|
||||||
let query = self.selection.select("entries");
|
let query = self.selection.select("entries");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -1900,7 +1896,7 @@ impl Directory {
|
|||||||
pub async fn entries_opts<'a>(
|
pub async fn entries_opts<'a>(
|
||||||
&self,
|
&self,
|
||||||
opts: DirectoryEntriesOpts<'a>,
|
opts: DirectoryEntriesOpts<'a>,
|
||||||
) -> Result<Vec<String>, DaggerError> {
|
) -> eyre::Result<Vec<String>> {
|
||||||
let mut query = self.selection.select("entries");
|
let mut query = self.selection.select("entries");
|
||||||
|
|
||||||
if let Some(path) = opts.path {
|
if let Some(path) = opts.path {
|
||||||
@ -1914,7 +1910,7 @@ impl Directory {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `path` - Location of the copied directory (e.g., "logs/").
|
/// * `path` - Location of the copied directory (e.g., "logs/").
|
||||||
pub async fn export(&self, path: impl Into<String>) -> Result<bool, DaggerError> {
|
pub async fn export(&self, path: impl Into<String>) -> eyre::Result<bool> {
|
||||||
let mut query = self.selection.select("export");
|
let mut query = self.selection.select("export");
|
||||||
|
|
||||||
query = query.arg("path", path.into());
|
query = query.arg("path", path.into());
|
||||||
@ -1938,7 +1934,7 @@ impl Directory {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// The content-addressed identifier of the directory.
|
/// The content-addressed identifier of the directory.
|
||||||
pub async fn id(&self) -> Result<DirectoryId, DaggerError> {
|
pub async fn id(&self) -> eyre::Result<DirectoryId> {
|
||||||
let query = self.selection.select("id");
|
let query = self.selection.select("id");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2246,13 +2242,13 @@ pub struct EnvVariable {
|
|||||||
|
|
||||||
impl EnvVariable {
|
impl EnvVariable {
|
||||||
/// The environment variable name.
|
/// The environment variable name.
|
||||||
pub async fn name(&self) -> Result<String, DaggerError> {
|
pub async fn name(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("name");
|
let query = self.selection.select("name");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The environment variable value.
|
/// The environment variable value.
|
||||||
pub async fn value(&self) -> Result<String, DaggerError> {
|
pub async fn value(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("value");
|
let query = self.selection.select("value");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2267,7 +2263,7 @@ pub struct File {
|
|||||||
|
|
||||||
impl File {
|
impl File {
|
||||||
/// Retrieves the contents of the file.
|
/// Retrieves the contents of the file.
|
||||||
pub async fn contents(&self) -> Result<String, DaggerError> {
|
pub async fn contents(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("contents");
|
let query = self.selection.select("contents");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2277,7 +2273,7 @@ impl File {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `path` - Location of the written directory (e.g., "output.txt").
|
/// * `path` - Location of the written directory (e.g., "output.txt").
|
||||||
pub async fn export(&self, path: impl Into<String>) -> Result<bool, DaggerError> {
|
pub async fn export(&self, path: impl Into<String>) -> eyre::Result<bool> {
|
||||||
let mut query = self.selection.select("export");
|
let mut query = self.selection.select("export");
|
||||||
|
|
||||||
query = query.arg("path", path.into());
|
query = query.arg("path", path.into());
|
||||||
@ -2285,7 +2281,7 @@ impl File {
|
|||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// Retrieves the content-addressed identifier of the file.
|
/// Retrieves the content-addressed identifier of the file.
|
||||||
pub async fn id(&self) -> Result<FileId, DaggerError> {
|
pub async fn id(&self) -> eyre::Result<FileId> {
|
||||||
let query = self.selection.select("id");
|
let query = self.selection.select("id");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2301,7 +2297,7 @@ impl File {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Gets the size of the file, in bytes.
|
/// Gets the size of the file, in bytes.
|
||||||
pub async fn size(&self) -> Result<isize, DaggerError> {
|
pub async fn size(&self) -> eyre::Result<isize> {
|
||||||
let query = self.selection.select("size");
|
let query = self.selection.select("size");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2342,7 +2338,7 @@ pub struct GitRefTreeOpts<'a> {
|
|||||||
|
|
||||||
impl GitRef {
|
impl GitRef {
|
||||||
/// The digest of the current value of this ref.
|
/// The digest of the current value of this ref.
|
||||||
pub async fn digest(&self) -> Result<String, DaggerError> {
|
pub async fn digest(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("digest");
|
let query = self.selection.select("digest");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2409,7 +2405,7 @@ impl GitRepository {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Lists of branches on the repository.
|
/// Lists of branches on the repository.
|
||||||
pub async fn branches(&self) -> Result<Vec<String>, DaggerError> {
|
pub async fn branches(&self) -> eyre::Result<Vec<String>> {
|
||||||
let query = self.selection.select("branches");
|
let query = self.selection.select("branches");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2447,7 +2443,7 @@ impl GitRepository {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// Lists of tags on the repository.
|
/// Lists of tags on the repository.
|
||||||
pub async fn tags(&self) -> Result<Vec<String>, DaggerError> {
|
pub async fn tags(&self) -> eyre::Result<Vec<String>> {
|
||||||
let query = self.selection.select("tags");
|
let query = self.selection.select("tags");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2613,7 +2609,7 @@ impl HostVariable {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// The value of this variable.
|
/// The value of this variable.
|
||||||
pub async fn value(&self) -> Result<String, DaggerError> {
|
pub async fn value(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("value");
|
let query = self.selection.select("value");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2628,13 +2624,13 @@ pub struct Label {
|
|||||||
|
|
||||||
impl Label {
|
impl Label {
|
||||||
/// The label name.
|
/// The label name.
|
||||||
pub async fn name(&self) -> Result<String, DaggerError> {
|
pub async fn name(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("name");
|
let query = self.selection.select("name");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The label value.
|
/// The label value.
|
||||||
pub async fn value(&self) -> Result<String, DaggerError> {
|
pub async fn value(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("value");
|
let query = self.selection.select("value");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2649,19 +2645,19 @@ pub struct Port {
|
|||||||
|
|
||||||
impl Port {
|
impl Port {
|
||||||
/// The port description.
|
/// The port description.
|
||||||
pub async fn description(&self) -> Result<String, DaggerError> {
|
pub async fn description(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("description");
|
let query = self.selection.select("description");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The port number.
|
/// The port number.
|
||||||
pub async fn port(&self) -> Result<isize, DaggerError> {
|
pub async fn port(&self) -> eyre::Result<isize> {
|
||||||
let query = self.selection.select("port");
|
let query = self.selection.select("port");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The transport layer network protocol.
|
/// The transport layer network protocol.
|
||||||
pub async fn protocol(&self) -> Result<NetworkProtocol, DaggerError> {
|
pub async fn protocol(&self) -> eyre::Result<NetworkProtocol> {
|
||||||
let query = self.selection.select("protocol");
|
let query = self.selection.select("protocol");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2696,25 +2692,25 @@ impl Project {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// install the project's schema
|
/// install the project's schema
|
||||||
pub async fn install(&self) -> Result<bool, DaggerError> {
|
pub async fn install(&self) -> eyre::Result<bool> {
|
||||||
let query = self.selection.select("install");
|
let query = self.selection.select("install");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// name of the project
|
/// name of the project
|
||||||
pub async fn name(&self) -> Result<String, DaggerError> {
|
pub async fn name(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("name");
|
let query = self.selection.select("name");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// schema provided by the project
|
/// schema provided by the project
|
||||||
pub async fn schema(&self) -> Result<String, DaggerError> {
|
pub async fn schema(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("schema");
|
let query = self.selection.select("schema");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// sdk used to generate code for and/or execute this project
|
/// sdk used to generate code for and/or execute this project
|
||||||
pub async fn sdk(&self) -> Result<String, DaggerError> {
|
pub async fn sdk(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("sdk");
|
let query = self.selection.select("sdk");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -2829,7 +2825,7 @@ impl Query {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// The default platform of the builder.
|
/// The default platform of the builder.
|
||||||
pub async fn default_platform(&self) -> Result<Platform, DaggerError> {
|
pub async fn default_platform(&self) -> eyre::Result<Platform> {
|
||||||
let query = self.selection.select("defaultPlatform");
|
let query = self.selection.select("defaultPlatform");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -3098,13 +3094,13 @@ pub struct Secret {
|
|||||||
|
|
||||||
impl Secret {
|
impl Secret {
|
||||||
/// The identifier for this secret.
|
/// The identifier for this secret.
|
||||||
pub async fn id(&self) -> Result<SecretId, DaggerError> {
|
pub async fn id(&self) -> eyre::Result<SecretId> {
|
||||||
let query = self.selection.select("id");
|
let query = self.selection.select("id");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
}
|
}
|
||||||
/// The value of this secret.
|
/// The value of this secret.
|
||||||
pub async fn plaintext(&self) -> Result<String, DaggerError> {
|
pub async fn plaintext(&self) -> eyre::Result<String> {
|
||||||
let query = self.selection.select("plaintext");
|
let query = self.selection.select("plaintext");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
@ -3119,7 +3115,7 @@ pub struct Socket {
|
|||||||
|
|
||||||
impl Socket {
|
impl Socket {
|
||||||
/// The content-addressed identifier of the socket.
|
/// The content-addressed identifier of the socket.
|
||||||
pub async fn id(&self) -> Result<SocketId, DaggerError> {
|
pub async fn id(&self) -> eyre::Result<SocketId> {
|
||||||
let query = self.selection.select("id");
|
let query = self.selection.select("id");
|
||||||
|
|
||||||
query.execute(self.graphql_client.clone()).await
|
query.execute(self.graphql_client.clone()).await
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
mod client;
|
mod client;
|
||||||
pub mod errors;
|
|
||||||
mod gen;
|
mod gen;
|
||||||
pub mod logging;
|
pub mod logging;
|
||||||
mod querybuilder;
|
mod querybuilder;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use std::{collections::HashMap, ops::Add, sync::Arc};
|
use std::{collections::HashMap, ops::Add, sync::Arc};
|
||||||
|
|
||||||
use dagger_core::graphql_client::DynGraphQLClient;
|
use dagger_core::graphql_client::DynGraphQLClient;
|
||||||
|
use eyre::Context;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::errors::{DaggerError, DaggerUnpackError};
|
|
||||||
|
|
||||||
pub fn query() -> Selection {
|
pub fn query() -> Selection {
|
||||||
Selection::default()
|
Selection::default()
|
||||||
}
|
}
|
||||||
@ -93,7 +92,7 @@ impl Selection {
|
|||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(&self) -> Result<String, DaggerError> {
|
pub fn build(&self) -> eyre::Result<String> {
|
||||||
let mut fields = vec!["query".to_string()];
|
let mut fields = vec!["query".to_string()];
|
||||||
|
|
||||||
for sel in self.path() {
|
for sel in self.path() {
|
||||||
@ -118,7 +117,7 @@ impl Selection {
|
|||||||
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
|
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute<D>(&self, gql_client: DynGraphQLClient) -> Result<D, DaggerError>
|
pub async fn execute<D>(&self, gql_client: DynGraphQLClient) -> eyre::Result<D>
|
||||||
where
|
where
|
||||||
D: for<'de> Deserialize<'de>,
|
D: for<'de> Deserialize<'de>,
|
||||||
{
|
{
|
||||||
@ -128,7 +127,7 @@ impl Selection {
|
|||||||
|
|
||||||
let resp: Option<serde_json::Value> = match gql_client.query(&query).await {
|
let resp: Option<serde_json::Value> = match gql_client.query(&query).await {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => return Err(DaggerError::Query(e)),
|
Err(e) => eyre::bail!(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
let resp: Option<D> = self.unpack_resp(resp)?;
|
let resp: Option<D> = self.unpack_resp(resp)?;
|
||||||
@ -152,10 +151,7 @@ impl Selection {
|
|||||||
selections
|
selections
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn unpack_resp<D>(
|
pub(crate) fn unpack_resp<D>(&self, resp: Option<serde_json::Value>) -> eyre::Result<Option<D>>
|
||||||
&self,
|
|
||||||
resp: Option<serde_json::Value>,
|
|
||||||
) -> Result<Option<D>, DaggerError>
|
|
||||||
where
|
where
|
||||||
D: for<'de> Deserialize<'de>,
|
D: for<'de> Deserialize<'de>,
|
||||||
{
|
{
|
||||||
@ -165,23 +161,21 @@ impl Selection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unpack_resp_value<D>(&self, r: serde_json::Value) -> Result<D, DaggerError>
|
fn unpack_resp_value<D>(&self, r: serde_json::Value) -> eyre::Result<D>
|
||||||
where
|
where
|
||||||
D: for<'de> Deserialize<'de>,
|
D: for<'de> Deserialize<'de>,
|
||||||
{
|
{
|
||||||
if let Some(o) = r.as_object() {
|
if let Some(o) = r.as_object() {
|
||||||
let keys = o.keys();
|
let keys = o.keys();
|
||||||
if keys.len() != 1 {
|
if keys.len() != 1 {
|
||||||
return Err(DaggerError::Unpack(DaggerUnpackError::TooManyNestedObjects));
|
eyre::bail!("too many nested objects inside graphql response")
|
||||||
}
|
}
|
||||||
|
|
||||||
let first = keys.into_iter().next().unwrap();
|
let first = keys.into_iter().next().unwrap();
|
||||||
return self.unpack_resp_value(o.get(first).unwrap().clone());
|
return self.unpack_resp_value(o.get(first).unwrap().clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
serde_json::from_value::<D>(r)
|
serde_json::from_value::<D>(r).context("could not deserialize response")
|
||||||
.map_err(DaggerUnpackError::Deserialize)
|
|
||||||
.map_err(DaggerError::Unpack)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@ async fn test_err_message() {
|
|||||||
assert_eq!(alpine.is_err(), true);
|
assert_eq!(alpine.is_err(), true);
|
||||||
let err = alpine.expect_err("Tests expect err");
|
let err = alpine.expect_err("Tests expect err");
|
||||||
|
|
||||||
let error_msg = r#"failed to query dagger engine: domain error:
|
let error_msg = r#"
|
||||||
Look at json field for more details
|
GQLClient Error: Look at json field for more details
|
||||||
pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
|
Message: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
assert_eq!(err.to_string().as_str(), error_msg);
|
assert_eq!(err.to_string().as_str(), error_msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user