Skip to content

Commit

Permalink
fix(whoami): $APOLLO_KEY works with no default profile
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed May 6, 2021
1 parent 7886674 commit 44c8af6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/houston/src/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Profile {

/// Loads and deserializes configuration from the file system for a
/// specific profile.
pub fn load(
fn load(
profile_name: &str,
config: &Config,
opts: LoadOpts,
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Rover {

match &self.command {
Command::Config(command) => {
command.run(self.get_rover_config()?, self.get_client_config()?)
command.run(self.get_client_config()?)
}
Command::Supergraph(command) => command.run(),
Command::Docs(command) => command.run(),
Expand Down
13 changes: 5 additions & 8 deletions src/command/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ mod whoami;
use serde::Serialize;
use structopt::StructOpt;

use houston as config;

use crate::command::RoverStdout;
use crate::utils::client::StudioClientConfig;
use crate::Result;
Expand Down Expand Up @@ -40,15 +38,14 @@ pub enum Command {
impl Config {
pub fn run(
&self,
config: config::Config,
client_config: StudioClientConfig,
) -> Result<RoverStdout> {
match &self.command {
Command::Auth(command) => command.run(config),
Command::List(command) => command.run(config),
Command::Delete(command) => command.run(config),
Command::Clear(command) => command.run(config),
Command::Whoami(command) => command.run(config, client_config),
Command::Auth(command) => command.run(client_config.config),
Command::List(command) => command.run(client_config.config),
Command::Delete(command) => command.run(client_config.config),
Command::Clear(command) => command.run(client_config.config),
Command::Whoami(command) => command.run(client_config),
}
}
}
6 changes: 2 additions & 4 deletions src/command/config/whoami.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub struct WhoAmI {
impl WhoAmI {
pub fn run(
&self,
config: config::Config,
client_config: StudioClientConfig,
) -> Result<RoverStdout> {
let client = client_config.get_client(&self.profile_name)?;
Expand Down Expand Up @@ -74,12 +73,11 @@ impl WhoAmI {

message.push_str(&format!("{}: {}", Green.normal().paint("Origin"), &origin));

let opts = config::LoadOpts { sensitive: true };
let profile = config::Profile::load(&self.profile_name, &config, opts)?;
let credential = config::Profile::get_credential(&self.profile_name, &client_config.config)?;
message.push_str(&format!(
"\n{}: {}",
Green.normal().paint("API Key"),
profile
credential.api_key
));

eprintln!("{}", message);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const STUDIO_PROD_API_ENDPOINT: &str = "https://graphql.api.apollographql.com/ap

pub struct StudioClientConfig {
uri: String,
config: config::Config,
pub config: config::Config,
version: String,
}

Expand Down

0 comments on commit 44c8af6

Please sign in to comment.