Skip to content

Commit 0340488

Browse files
committed
fmt all
1 parent b4688de commit 0340488

7 files changed

Lines changed: 47 additions & 32 deletions

File tree

src/cli/credentials.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,15 @@ fn request_device_authorization(
476476
};
477477

478478
Ok(DeviceAuthResponse {
479-
device_code: field("device_code")?,
480-
user_code: field("user_code")?,
481-
verification_uri: field("verification_uri")?,
479+
device_code: field("device_code")?,
480+
user_code: field("user_code")?,
481+
verification_uri: field("verification_uri")?,
482482
verification_uri_complete: field("verification_uri_complete")?,
483-
expires_in: inner.get("expires_in").and_then(|v| v.as_u64()).unwrap_or(300),
484-
interval: inner.get("interval").and_then(|v| v.as_u64()).unwrap_or(5),
483+
expires_in: inner
484+
.get("expires_in")
485+
.and_then(|v| v.as_u64())
486+
.unwrap_or(300),
487+
interval: inner.get("interval").and_then(|v| v.as_u64()).unwrap_or(5),
485488
})
486489
}
487490

@@ -557,9 +560,7 @@ fn poll_device_token(
557560
"Session expired. Please run `stacker login` again.".to_string(),
558561
))
559562
}
560-
Some(other) => {
561-
return Err(CliError::AuthFailed(format!("Auth error: {other}")))
562-
}
563+
Some(other) => return Err(CliError::AuthFailed(format!("Auth error: {other}"))),
563564
None => {} // unexpected non-200 without error field — keep polling
564565
}
565566
}
@@ -586,7 +587,8 @@ pub fn fetch_user_email(auth_url: &str, access_token: &str) -> Result<Option<Str
586587
}
587588

588589
let data: serde_json::Value = resp.json().unwrap_or(serde_json::Value::Null);
589-
let email = data.get("email")
590+
let email = data
591+
.get("email")
590592
.or_else(|| data.get("user").and_then(|u| u.get("email")))
591593
.and_then(|v| v.as_str())
592594
.map(|s| s.to_string());
@@ -616,11 +618,23 @@ pub fn browser_login<S: CredentialStore>(
616618

617619
let opened = {
618620
#[cfg(target_os = "macos")]
619-
{ std::process::Command::new("open").arg(&device_auth.verification_uri_complete).status().is_ok() }
621+
{
622+
std::process::Command::new("open")
623+
.arg(&device_auth.verification_uri_complete)
624+
.status()
625+
.is_ok()
626+
}
620627
#[cfg(target_os = "linux")]
621-
{ std::process::Command::new("xdg-open").arg(&device_auth.verification_uri_complete).status().is_ok() }
628+
{
629+
std::process::Command::new("xdg-open")
630+
.arg(&device_auth.verification_uri_complete)
631+
.status()
632+
.is_ok()
633+
}
622634
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
623-
{ false }
635+
{
636+
false
637+
}
624638
};
625639
if opened {
626640
eprintln!(" (Browser opened automatically)");
@@ -647,7 +661,9 @@ pub fn browser_login<S: CredentialStore>(
647661
token_type: "Bearer".to_string(),
648662
expires_at,
649663
email,
650-
server_url: Some(crate::cli::install_runner::normalize_stacker_server_url(server_url)),
664+
server_url: Some(crate::cli::install_runner::normalize_stacker_server_url(
665+
server_url,
666+
)),
651667
org: org.map(|s| s.to_string()),
652668
domain: domain.map(|s| s.to_string()),
653669
};

src/cli/user_config.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ impl UserConfig {
5555

5656
/// Default browser preference: `true` unless explicitly disabled.
5757
pub fn browser_default(&self) -> bool {
58-
self.login
59-
.as_ref()
60-
.and_then(|l| l.browser)
61-
.unwrap_or(true)
58+
self.login.as_ref().and_then(|l| l.browser).unwrap_or(true)
6259
}
6360

6461
/// Default provider: `gc` (Google) unless overridden.

src/console/commands/cli/agent.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ fn json_error_message(value: &serde_json::Value) -> Option<String> {
190190
fn sanitize_npm_credentials_message(raw_message: String, code: Option<&str>) -> String {
191191
// Fall back to substring match when the error arrives as a pre-formatted string
192192
// with no structured "code" field (the server embeds the code inline).
193-
if code == Some("npm_credentials_invalid")
194-
|| raw_message.contains("npm_credentials_invalid")
195-
{
193+
if code == Some("npm_credentials_invalid") || raw_message.contains("npm_credentials_invalid") {
196194
let user_msg = "NPM credentials are invalid or missing. \
197195
Update them with:\n \
198196
stacker secrets set npm_credentials --scope server \

src/console/commands/cli/cloud_firewall.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ impl CloudFirewallCommand {
4444

4545
if let Ok(Some(lock)) = DeploymentLock::load_active(&project_dir) {
4646
if let Some(server_name) = lock.server_name {
47-
if let Ok(Some(server)) =
48-
ctx.block_on(ctx.client.find_server_by_name(&server_name))
47+
if let Ok(Some(server)) = ctx.block_on(ctx.client.find_server_by_name(&server_name))
4948
{
5049
return Ok(server.id);
5150
}

src/console/commands/cli/deploy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,9 @@ fn validate_cross_source_port_collisions(
16651665
}
16661666
for spec in &config.app.ports {
16671667
if let Some(port) = extract_host_port_from_string(spec) {
1668-
stacker_port_owners.entry(port).or_insert_with(|| "app".to_string());
1668+
stacker_port_owners
1669+
.entry(port)
1670+
.or_insert_with(|| "app".to_string());
16691671
}
16701672
}
16711673

src/console/commands/cli/login.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::io::{self, IsTerminal};
22

3-
use crate::cli::credentials::{browser_login, login, CredentialsManager, HttpOAuthClient, LoginRequest};
3+
use crate::cli::credentials::{
4+
browser_login, login, CredentialsManager, HttpOAuthClient, LoginRequest,
5+
};
46
use crate::cli::user_config::UserConfig;
57
use crate::console::commands::CallableTrait;
68
use dialoguer::{Password, Select};
@@ -32,7 +34,7 @@ impl LoginCommand {
3234
domain,
3335
auth_url,
3436
server_url,
35-
browser, // raw flag only; browser_default() is applied in call()
37+
browser, // raw flag only; browser_default() is applied in call()
3638
provider,
3739
user,
3840
}
@@ -98,7 +100,8 @@ impl LoginCommand {
98100
.or_else(|| std::env::var("STACKER_API_URL").ok())
99101
.or_else(|| cfg.auth_url)
100102
.ok_or_else(|| {
101-
"Missing auth URL. Pass --auth-url <user-service-url> or set STACKER_AUTH_URL.".into()
103+
"Missing auth URL. Pass --auth-url <user-service-url> or set STACKER_AUTH_URL."
104+
.into()
102105
})
103106
}
104107

@@ -109,7 +112,8 @@ impl LoginCommand {
109112
.or_else(|| std::env::var("STACKER_URL").ok())
110113
.or_else(|| cfg.server_url)
111114
.ok_or_else(|| {
112-
"Missing Stacker API URL. Pass --server-url <stacker-api-url> or set STACKER_URL.".into()
115+
"Missing Stacker API URL. Pass --server-url <stacker-api-url> or set STACKER_URL."
116+
.into()
113117
})
114118
}
115119
}
@@ -119,9 +123,9 @@ impl CallableTrait for LoginCommand {
119123
// --user/-u always means email/password; skip prompt and browser.
120124
// --browser flag forces browser; on a tty, browser_default() from config applies.
121125
// Piped stdin always falls back to email/password regardless of config.
122-
let use_browser = self.user.is_none() && (
123-
self.browser || (io::stdin().is_terminal() && UserConfig::load().browser_default())
124-
);
126+
let use_browser = self.user.is_none()
127+
&& (self.browser
128+
|| (io::stdin().is_terminal() && UserConfig::load().browser_default()));
125129

126130
if use_browser {
127131
// Resolve provider — may show an interactive menu.

src/console/commands/cli/secrets.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,8 +1345,7 @@ impl CallableTrait for SecretsDeleteCommand {
13451345
println!("✓ Deleted service secret {} from {}", key, app_code);
13461346
}
13471347
RemoteSecretScope::Server => {
1348-
let server_id =
1349-
target.server_id().map_or_else(server_id_from_lock, Ok)?;
1348+
let server_id = target.server_id().map_or_else(server_id_from_lock, Ok)?;
13501349
ctx.block_on(ctx.client.delete_server_secret(server_id, key))
13511350
.map_err(|error| remap_remote_secret_error(operation, error))?;
13521351
println!("✓ Deleted server secret {} from server {}", key, server_id);

0 commit comments

Comments
 (0)