Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removes unnecessary context #211

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/command/config/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use config::Profile;
use houston as config;

use crate::command::RoverStdout;
use crate::{anyhow, Context, Result};
use crate::{anyhow, Result};

#[derive(Debug, Serialize, StructOpt)]
/// Authenticate a configuration profile with an API key
Expand All @@ -28,13 +28,10 @@ pub struct Auth {
impl Auth {
pub fn run(&self, config: config::Config) -> Result<RoverStdout> {
let api_key = api_key_prompt()?;
Profile::set_api_key(&self.profile_name, &config, &api_key)
.context("Failed while saving API key")?;
Profile::get_api_key(&self.profile_name, &config)
.map(|_| {
tracing::info!("Successfully saved API key.");
})
.context("Failed while loading API key")?;
Profile::set_api_key(&self.profile_name, &config, &api_key)?;
Profile::get_api_key(&self.profile_name, &config).map(|_| {
tracing::info!("Successfully saved API key.");
})?;
Ok(RoverStdout::None)
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/command/config/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::Serialize;
use structopt::StructOpt;

use crate::command::RoverStdout;
use crate::{Context, Result};
use crate::Result;

use houston as config;

Expand All @@ -14,9 +14,7 @@ pub struct Clear {}

impl Clear {
pub fn run(&self, config: config::Config) -> Result<RoverStdout> {
config
.clear()
.context("Failed to clear all configuration.")?;
config.clear()?;
tracing::info!("Successfully cleared all configuration.");
Ok(RoverStdout::None)
}
Expand Down
4 changes: 2 additions & 2 deletions src/command/config/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use structopt::StructOpt;
use houston as config;

use crate::command::RoverStdout;
use crate::{Context, Result};
use crate::Result;

#[derive(Debug, Serialize, StructOpt)]
/// Delete a configuration profile
Expand All @@ -21,7 +21,7 @@ pub struct Delete {

impl Delete {
pub fn run(&self, config: config::Config) -> Result<RoverStdout> {
config::Profile::delete(&self.name, &config).context("Could not delete profile.")?;
config::Profile::delete(&self.name, &config)?;
tracing::info!("Successfully deleted profile \"{}\"", &self.name);
Ok(RoverStdout::None)
}
Expand Down
4 changes: 2 additions & 2 deletions src/command/config/list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::Serialize;
use structopt::StructOpt;

use crate::{Context, Result};
use crate::Result;
use houston as config;

use crate::command::RoverStdout;
Expand All @@ -12,7 +12,7 @@ pub struct List {}

impl List {
pub fn run(&self, config: config::Config) -> Result<RoverStdout> {
let profiles = config::Profile::list(&config).context("Could not list profiles.")?;
let profiles = config::Profile::list(&config)?;
if profiles.is_empty() {
tracing::info!("No profiles found.")
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/command/graph/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::client::StudioClientConfig;
use crate::command::RoverStdout;
use crate::utils::loaders::load_schema_from_flag;
use crate::utils::parsers::{parse_graph_ref, parse_schema_source, GraphRef, SchemaSource};
use crate::{Context, Result};
use crate::Result;

#[derive(Debug, Serialize, StructOpt)]
pub struct Check {
Expand Down Expand Up @@ -41,8 +41,7 @@ impl Check {
schema: Some(sdl),
},
&client,
)
.context("Failed to validate schema")?;
)?;

tracing::info!(
"Validated the proposed subgraph against metrics from {}",
Expand Down
5 changes: 2 additions & 3 deletions src/command/graph/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::client::StudioClientConfig;
use crate::command::RoverStdout;
use crate::utils::loaders::load_schema_from_flag;
use crate::utils::parsers::{parse_graph_ref, parse_schema_source, GraphRef, SchemaSource};
use crate::{Context, Result};
use crate::Result;

#[derive(Debug, Serialize, StructOpt)]
pub struct Push {
Expand Down Expand Up @@ -51,8 +51,7 @@ impl Push {
schema_document: Some(schema_document),
},
&client,
)
.context("Failed while pushing to Apollo Studio. To see a full printout of the schema attempting to push, rerun with `--log debug`")?;
)?;

let hash = handle_response(&self.graph, push_response);
Ok(RoverStdout::SchemaHash(hash))
Expand Down
5 changes: 2 additions & 3 deletions src/command/subgraph/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use prettytable::{cell, row, Table};
use serde::Serialize;
use structopt::StructOpt;

use crate::{Context, Result};
use crate::Result;
use rover_client::query::subgraph::check;

use crate::client::StudioClientConfig;
Expand Down Expand Up @@ -54,8 +54,7 @@ impl Check {
implementing_service_name: self.subgraph.clone(),
},
&client,
)
.context("Failed to validate schema")?;
)?;

tracing::info!("Checked the proposed subgraph against {}", &self.graph);

Expand Down
5 changes: 2 additions & 3 deletions src/command/subgraph/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rover_client::query::subgraph::fetch;
use crate::client::StudioClientConfig;
use crate::command::RoverStdout;
use crate::utils::parsers::{parse_graph_ref, GraphRef};
use crate::{Context, Result};
use crate::Result;

#[derive(Debug, Serialize, StructOpt)]
pub struct Fetch {
Expand Down Expand Up @@ -46,8 +46,7 @@ impl Fetch {
},
&client,
&self.subgraph,
)
.context("Failed while fetching from Apollo Studio")?;
)?;

Ok(RoverStdout::SDL(sdl))
}
Expand Down
5 changes: 2 additions & 3 deletions src/command/subgraph/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::client::StudioClientConfig;
use crate::command::RoverStdout;
use crate::utils::loaders::load_schema_from_flag;
use crate::utils::parsers::{parse_graph_ref, parse_schema_source, GraphRef, SchemaSource};
use crate::{Context, Result};
use crate::Result;

use rover_client::query::subgraph::push::{self, PushPartialSchemaResponse};

Expand Down Expand Up @@ -69,8 +69,7 @@ impl Push {
url: self.routing_url.clone(),
},
&client,
)
.context("Failed while pushing to Apollo Studio. To see a full printout of the schema attempting to push, rerun with `--log debug`")?;
)?;

handle_response(push_response, &self.subgraph, &self.graph.name);
Ok(RoverStdout::None)
Expand Down