mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-11 15:46:53 +00:00
lint: clippy rules or_fun_call (#2561)
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -20,7 +20,6 @@ use rustfs_iam::store::object::ObjectStore;
|
||||
use rustfs_iam::sys::IamSys;
|
||||
use rustfs_policy::policy::{Args, action::Action};
|
||||
use s3s::{S3Result, s3_error};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tracing::debug;
|
||||
|
||||
@@ -79,7 +78,7 @@ async fn check_admin_request_auth(
|
||||
action,
|
||||
conditions: &conditions,
|
||||
is_owner: ctx.is_owner,
|
||||
claims: ctx.cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: ctx.cred.claims_or_empty(),
|
||||
deny_only: ctx.deny_only,
|
||||
bucket,
|
||||
object,
|
||||
|
||||
@@ -419,7 +419,7 @@ fn get_console_config_from_env() -> (bool, u32, u64, String) {
|
||||
let cors_allowed_origins = std::env::var(rustfs_config::ENV_CONSOLE_CORS_ALLOWED_ORIGINS)
|
||||
.unwrap_or_else(|_| rustfs_config::DEFAULT_CONSOLE_CORS_ALLOWED_ORIGINS.to_string())
|
||||
.parse::<String>()
|
||||
.unwrap_or(rustfs_config::DEFAULT_CONSOLE_CORS_ALLOWED_ORIGINS.to_string());
|
||||
.unwrap_or_else(|_| rustfs_config::DEFAULT_CONSOLE_CORS_ALLOWED_ORIGINS.to_string());
|
||||
|
||||
(rate_limit_enable, rate_limit_rpm, auth_timeout, cors_allowed_origins)
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ fn parse_set_bucket_quota_request(body: &[u8]) -> Result<SetBucketQuotaRequest,
|
||||
quota: request
|
||||
.size
|
||||
.filter(|quota| *quota > 0)
|
||||
.or(request.quota.filter(|quota| *quota > 0)),
|
||||
.or_else(|| request.quota.filter(|quota| *quota > 0)),
|
||||
quota_type: request.quota_type.unwrap_or_else(default_quota_type),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ impl Operation for AddServiceAccount {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false, // Always require explicit Allow permission
|
||||
})
|
||||
.await
|
||||
@@ -546,7 +546,7 @@ impl Operation for UpdateServiceAccount {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
@@ -662,7 +662,7 @@ impl Operation for InfoServiceAccount {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
@@ -729,7 +729,7 @@ impl Operation for TemporaryAccountInfo {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
@@ -803,7 +803,7 @@ impl Operation for InfoAccessKey {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
@@ -940,7 +940,7 @@ impl Operation for ListServiceAccount {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
@@ -1076,7 +1076,7 @@ impl Operation for ListAccessKeysBulk {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
@@ -1099,7 +1099,7 @@ impl Operation for ListAccessKeysBulk {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: self_only,
|
||||
})
|
||||
.await
|
||||
@@ -1268,7 +1268,7 @@ impl Operation for DeleteServiceAccount {
|
||||
),
|
||||
is_owner: owner,
|
||||
object: "",
|
||||
claims: cred.claims.as_ref().unwrap_or(&HashMap::new()),
|
||||
claims: cred.claims_or_empty(),
|
||||
deny_only: false,
|
||||
})
|
||||
.await
|
||||
|
||||
@@ -245,7 +245,7 @@ async fn handle_assume_role(
|
||||
expiration: Timestamp::from(
|
||||
new_cred
|
||||
.expiration
|
||||
.unwrap_or(OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600))),
|
||||
.unwrap_or_else(|| OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600))),
|
||||
),
|
||||
secret_access_key: new_cred.secret_key,
|
||||
session_token: new_cred.session_token,
|
||||
@@ -326,7 +326,7 @@ async fn handle_assume_role_with_web_identity(body: AssumeRoleRequest) -> S3Resu
|
||||
// Build XML response (AssumeRoleWithWebIdentityResponse)
|
||||
let expiration = new_cred
|
||||
.expiration
|
||||
.unwrap_or(OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600)));
|
||||
.unwrap_or_else(|| OffsetDateTime::now_utc().saturating_add(Duration::seconds(3600)));
|
||||
let exp_str = expiration
|
||||
.format(&time::format_description::well_known::Rfc3339)
|
||||
.unwrap_or_default();
|
||||
|
||||
Reference in New Issue
Block a user