diff --git a/crates/sputnik/README.md b/crates/sputnik/README.md index 4c2aed8ad..68413ca04 100644 --- a/crates/sputnik/README.md +++ b/crates/sputnik/README.md @@ -9,7 +9,7 @@ Sputnik declares the `sputnik::Session` struct which is used to capture informat ```sh body: command: - name: config profile list + name: config list arguments: machine_id: edd890f0-3f8d-43f5-a22e-d3731d7e5042 session_id: a9d345b6-75f9-4bc1-9685-8475c6771610 diff --git a/docs/source/configuring.md b/docs/source/configuring.md index 544fe28a7..45c4c6b02 100644 --- a/docs/source/configuring.md +++ b/docs/source/configuring.md @@ -25,7 +25,7 @@ You can provide your API key to Rover either via a [Rover command](#via-the-auth You can provide your API key to Rover by running the following command: ```shell -rover config profile auth +rover config auth ``` This method is recommended for local development. If you have more than one API key you want to use with Rover, you can assign those keys to different [configuration profiles](#configuration-profiles). @@ -51,7 +51,7 @@ If you don't specify a configuration profile for a command, Rover uses the defau To view all commands for working with configuration profiles, run the following command: ``` -rover config profile --help +rover config --help ``` ## Logging diff --git a/docs/source/getting-started.md b/docs/source/getting-started.md index eb2d6ff1d..d60f953bc 100644 --- a/docs/source/getting-started.md +++ b/docs/source/getting-started.md @@ -34,7 +34,7 @@ After you install Rover, you should authenticate it with [Apollo Studio](https:/ Run the following command: ```shell -rover config profile auth +rover config auth ``` This command instructs you where to obtain a personal API key and helps you set up a configuration profile. For more information, see [Configuring Rover](./configuring#configuration-profiles). diff --git a/src/cli.rs b/src/cli.rs index de6e22535..52ed8c97b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -22,7 +22,7 @@ Read the getting started guide: https://go.apollo.dev/r/start To begin working with Rover and to authenticate with Apollo Studio, run the following command: - $ rover config profile auth + $ rover config auth This will prompt you for an API Key that can be generated in Apollo Studio. diff --git a/src/command/config/profile/auth.rs b/src/command/config/auth.rs similarity index 86% rename from src/command/config/profile/auth.rs rename to src/command/config/auth.rs index 3cbd9f5db..c72ee5cdf 100644 --- a/src/command/config/profile/auth.rs +++ b/src/command/config/auth.rs @@ -9,14 +9,16 @@ use houston as config; use crate::command::RoverStdout; #[derive(Debug, Serialize, StructOpt)] -/// Set a configuration profile's Apollo Studio API key +/// Authenticate a configuration profile with an API key /// -/// Running this command with the --profile flag will create a new -/// named profile that can be used across Rover with the --profile -/// flag. +/// Running this command with a --profile argument will create a new +/// profile that can be referenced by name across Rover with the --profile +/// argument. /// -/// Running without the --profile flag will set the api key for -/// the `default` profile. +/// Running without the --profile flag will set an API key for +/// a profile named "default". +/// +/// See https://go.apollo.dev/r/api-keys for more details on Apollo's API keys. pub struct Auth { #[structopt(long = "profile", default_value = "default")] #[serde(skip_serializing)] diff --git a/src/command/config/profile/delete.rs b/src/command/config/delete.rs similarity index 100% rename from src/command/config/profile/delete.rs rename to src/command/config/delete.rs diff --git a/src/command/config/profile/list.rs b/src/command/config/list.rs similarity index 100% rename from src/command/config/profile/list.rs rename to src/command/config/list.rs diff --git a/src/command/config/mod.rs b/src/command/config/mod.rs index c01c46d43..1ca4b20c5 100644 --- a/src/command/config/mod.rs +++ b/src/command/config/mod.rs @@ -1,5 +1,8 @@ +mod auth; mod clear; -mod profile; +mod delete; +mod list; +mod show; use anyhow::Result; use serde::Serialize; @@ -17,17 +20,29 @@ pub struct Config { #[derive(Debug, Serialize, StructOpt)] pub enum Command { - /// Manage configuration profiles - Profile(profile::Profile), + /// Authenticate a configuration profile with an API token + Auth(auth::Auth), - /// Clear ALL configuration + /// Clear ALL configuration profiles Clear(clear::Clear), + + /// Delete a configuration profile + Delete(delete::Delete), + + /// List all configuration profiles + List(list::List), + + /// View a configuration profile's details + Show(show::Show), } impl Config { pub fn run(&self, config: config::Config) -> Result { match &self.command { - Command::Profile(command) => command.run(config), + Command::Auth(command) => command.run(config), + Command::List(command) => command.run(config), + Command::Show(command) => command.run(config), + Command::Delete(command) => command.run(config), Command::Clear(command) => command.run(config), } } diff --git a/src/command/config/profile/mod.rs b/src/command/config/profile/mod.rs deleted file mode 100644 index e9ceebde7..000000000 --- a/src/command/config/profile/mod.rs +++ /dev/null @@ -1,49 +0,0 @@ -mod auth; -mod delete; -mod list; -mod show; - -use anyhow::Result; -use serde::Serialize; -use structopt::StructOpt; - -use crate::command::RoverStdout; - -use houston as config; - -#[derive(Debug, Serialize, StructOpt)] -/// Commands for managing configuration profiles -/// -/// A profile is a saved set of global configuration options. -/// -/// For more on how profiles work, see here: https://go.apollo.dev/r/profiles -pub struct Profile { - #[structopt(subcommand)] - command: Command, -} - -impl Profile { - pub fn run(&self, config: config::Config) -> Result { - match &self.command { - Command::Auth(command) => command.run(config), - Command::List(command) => command.run(config), - Command::Show(command) => command.run(config), - Command::Delete(command) => command.run(config), - } - } -} - -#[derive(Debug, Serialize, StructOpt)] -pub enum Command { - /// Set a configuration profile's Apollo Studio API key - Auth(auth::Auth), - - /// List all configuration profiles - List(list::List), - - /// View a configuration profile's details - Show(show::Show), - - /// Delete a configuration profile - Delete(delete::Delete), -} diff --git a/src/command/config/profile/show.rs b/src/command/config/show.rs similarity index 100% rename from src/command/config/profile/show.rs rename to src/command/config/show.rs diff --git a/src/telemetry.rs b/src/telemetry.rs index 0ded3380e..2b208ba21 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -134,13 +134,13 @@ mod tests { #[test] fn it_can_serialize_commands() { let cli_name = env!("CARGO_PKG_NAME"); - let args = vec![cli_name, "config", "profile", "list"]; + let args = vec![cli_name, "config", "list"]; let rover = Rover::from_iter(args); let actual_serialized_command = rover .serialize_command() .expect("could not serialize command"); let expected_serialized_command = Command { - name: "config profile list".to_string(), + name: "config list".to_string(), arguments: HashMap::new(), }; assert_eq!(actual_serialized_command, expected_serialized_command); @@ -149,14 +149,7 @@ mod tests { #[test] fn it_can_serialize_commands_with_arguments() { let cli_name = env!("CARGO_PKG_NAME"); - let args = vec![ - cli_name, - "config", - "profile", - "show", - "default", - "--sensitive", - ]; + let args = vec![cli_name, "config", "show", "default", "--sensitive"]; let rover = Rover::from_iter(args); let actual_serialized_command = rover .serialize_command() @@ -164,7 +157,7 @@ mod tests { let mut expected_arguments = HashMap::new(); expected_arguments.insert("sensitive".to_string(), json!(true)); let expected_serialized_command = Command { - name: "config profile show".to_string(), + name: "config show".to_string(), arguments: expected_arguments, }; assert_eq!(actual_serialized_command, expected_serialized_command); @@ -174,7 +167,7 @@ mod tests { fn it_respects_apollo_telemetry_url() { let apollo_telemetry_url = "https://example.com/telemetry"; let cli_name = env!("CARGO_PKG_NAME"); - let args = vec![cli_name, "config", "profile", "list"]; + let args = vec![cli_name, "config", "list"]; let mut rover = Rover::from_iter(args); rover .env_store @@ -191,7 +184,7 @@ mod tests { #[test] fn it_can_be_disabled() { let cli_name = env!("CARGO_PKG_NAME"); - let args = vec![cli_name, "config", "profile", "list"]; + let args = vec![cli_name, "config", "list"]; let mut rover = Rover::from_iter(args); rover.env_store.insert(RoverEnvKey::TelemetryDisabled, "1"); let expect_enabled = false; @@ -203,7 +196,7 @@ mod tests { #[test] fn it_is_enabled_by_default() { let cli_name = env!("CARGO_PKG_NAME"); - let args = vec![cli_name, "config", "profile", "list"]; + let args = vec![cli_name, "config", "list"]; let rover = Rover::from_iter(args); let expect_enabled = true; let is_telemetry_enabled = rover.is_telemetry_enabled().unwrap(); diff --git a/tests/config/api_key.rs b/tests/config/api_key.rs index 23cdb109d..71753efce 100644 --- a/tests/config/api_key.rs +++ b/tests/config/api_key.rs @@ -5,7 +5,6 @@ use predicates::prelude::*; fn it_has_a_config_profile_auth_command() { let mut cmd = Command::cargo_bin("rover").unwrap(); cmd.arg("config") - .arg("profile") .arg("auth") .arg("--help") .assert() @@ -15,11 +14,6 @@ fn it_has_a_config_profile_auth_command() { #[test] fn it_errors_on_an_empty_apikey() { let mut cmd = Command::cargo_bin("rover").unwrap(); - let result = cmd - .arg("config") - .arg("profile") - .arg("auth") - .write_stdin("") - .assert(); + let result = cmd.arg("config").arg("auth").write_stdin("").assert(); result.stderr(predicate::str::contains("empty")); } diff --git a/tests/config/profile.rs b/tests/config/profile.rs index 06281a207..039e1bce1 100644 --- a/tests/config/profile.rs +++ b/tests/config/profile.rs @@ -20,7 +20,6 @@ fn it_can_list_no_profiles() { RoverEnvKey::ConfigHome.to_string(), get_temp_dir().to_string_lossy().to_string(), ) - .arg("profile") .arg("list") .assert(); result.stderr(predicate::str::contains("No profiles")); @@ -40,7 +39,6 @@ fn it_can_list_one_profile() { temp_dir.to_string_lossy().to_string(), ) .arg("config") - .arg("profile") .arg("list") .assert(); result.stderr(predicate::str::contains(CUSTOM_PROFILE));