Skip to content

Commit

Permalink
Refactor deployment logs query handling (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Sep 18, 2024
1 parent a5290ab commit 5888398
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions cli/src/command/deployments/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use anyhow::Result;
use clap::Args;
use slot::credential::Credentials;
use slot::graphql::deployments::deployment_logs::DeploymentService;
use slot::graphql::{deployments::deployment_logs::*, GraphQLQuery, Response};
use slot::graphql::{deployments::deployment_logs::*, GraphQLQuery};
use slot::{api::Client, graphql::deployments::DeploymentLogs};

use super::services::Service;
Expand Down Expand Up @@ -90,21 +90,9 @@ impl LogReader {
limit: Some(limit),
});

let res: Response<ResponseData> = self.client.query(&request_body).await?;
if let Some(errors) = res.errors {
let error_message = errors
.into_iter()
.map(|err| err.message)
.collect::<Vec<_>>()
.join(", ");
return Err(anyhow::anyhow!(error_message));
}
let data: ResponseData = self.client.query(&request_body).await?;

let logs = res
.data
.and_then(|data| data.deployment)
.map(|deployment| deployment.logs)
.unwrap();
let logs = data.deployment.map(|deployment| deployment.logs).unwrap();

Ok(logs)
}
Expand Down

0 comments on commit 5888398

Please sign in to comment.