Skip to content

Commit aab06b3

Browse files
fix: add correct profile arn for clients, allow changing start url from cli login (#1428)
1 parent 1e05983 commit aab06b3

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

crates/fig_api_client/src/clients/client.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,13 @@ impl Client {
100100

101101
let profile_arn = match fig_settings::state::get_value("api.codewhisperer.profile") {
102102
Ok(Some(profile)) => match profile.get("arn") {
103-
Some(arn) => Some(arn.to_string()),
103+
Some(arn) => match arn.as_str() {
104+
Some(arn) => Some(arn.to_string()),
105+
None => {
106+
error!("Stored arn is not a string. Instead it was: {arn}");
107+
None
108+
},
109+
},
104110
None => {
105111
error!("Stored profile does not contain an arn. Instead it was: {profile}");
106112
None

crates/fig_api_client/src/clients/streaming_client.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ impl StreamingClient {
9191

9292
let profile_arn = match fig_settings::state::get_value("api.codewhisperer.profile") {
9393
Ok(Some(profile)) => match profile.get("arn") {
94-
Some(arn) => Some(arn.to_string()),
94+
Some(arn) => match arn.as_str() {
95+
Some(arn) => Some(arn.to_string()),
96+
None => {
97+
error!("Stored arn is not a string. Instead it was: {arn}");
98+
None
99+
},
100+
},
95101
None => {
96102
error!("Stored profile does not contain an arn. Instead it was: {profile}");
97103
None

crates/q_cli/src/cli/user.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,8 @@ pub async fn login_interactive(args: LoginArgs) -> Result<()> {
260260
.region
261261
.or_else(|| fig_settings::state::get_string("auth.idc.region").ok().flatten());
262262

263-
let start_url = if let Some(url) = default_start_url.clone() {
264-
url
265-
} else {
266-
input("Enter Start URL", default_start_url.as_deref())?
267-
};
268-
269-
let region = if let Some(reg) = default_region.clone() {
270-
reg
271-
} else {
272-
input("Enter Region", default_region.as_deref())?
273-
};
263+
let start_url = input("Enter Start URL", default_start_url.as_deref())?;
264+
let region = input("Enter Region", default_region.as_deref())?;
274265

275266
let _ = fig_settings::state::set_value("auth.idc.start-url", start_url.clone());
276267
let _ = fig_settings::state::set_value("auth.idc.region", region.clone());
@@ -390,6 +381,10 @@ async fn try_device_authorization(
390381
}
391382

392383
async fn select_profile_interactive(whoami: bool) -> Result<()> {
384+
let mut spinner = Spinner::new(vec![
385+
SpinnerComponent::Spinner,
386+
SpinnerComponent::Text(" Fetching profiles...".into()),
387+
]);
393388
let profiles = list_available_profiles().await;
394389
if profiles.is_empty() {
395390
info!("Available profiles was empty");
@@ -409,6 +404,7 @@ async fn select_profile_interactive(whoami: bool) -> Result<()> {
409404
)
410405
.await;
411406
}
407+
spinner.stop_with_message(String::new());
412408
return Ok(fig_settings::state::set_value(
413409
"api.codewhisperer.profile",
414410
serde_json::to_value(&profiles[0])?,
@@ -425,6 +421,7 @@ async fn select_profile_interactive(whoami: bool) -> Result<()> {
425421
items[default_idx] = format!("{} (active)", items[default_idx].as_str());
426422
}
427423

424+
spinner.stop_with_message(String::new());
428425
let selected = Select::with_theme(&crate::util::dialoguer_theme())
429426
.with_prompt("Select an IAM Identity Center profile")
430427
.items(&items)

0 commit comments

Comments
 (0)