Skip to content

Commit e705399

Browse files
committed
chore: fix rustfmt and clippy type_complexity lint
1 parent 47df088 commit e705399

4 files changed

Lines changed: 56 additions & 34 deletions

File tree

rust/operator-binary/src/airflow_controller.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ use stackable_operator::{
6868
framework::LoggingError,
6969
spec::{ContainerLogConfig, Logging},
7070
},
71-
role_utils::{
72-
CommonConfiguration, GenericCommonConfig, GenericRoleConfig, RoleGroupRef,
73-
},
71+
role_utils::{CommonConfiguration, GenericCommonConfig, GenericRoleConfig, RoleGroupRef},
7472
shared::time::Duration,
7573
status::condition::{
7674
compute_conditions, operations::ClusterOperationsConditionBuilder,
@@ -84,11 +82,11 @@ use crate::{
8482
config::{self, PYTHON_IMPORTS},
8583
controller_commons::{self, CONFIG_VOLUME_NAME, LOG_CONFIG_VOLUME_NAME, LOG_VOLUME_NAME},
8684
crd::{
87-
self, AIRFLOW_CONFIG_FILENAME, AirflowConfigOverrides, APP_NAME, AirflowClusterStatus,
88-
AirflowConfig, AirflowConfigOptions, AirflowExecutor, AirflowRole, CONFIG_PATH, Container,
89-
ExecutorConfig, ExecutorConfigFragment, HTTP_PORT, HTTP_PORT_NAME, LISTENER_VOLUME_DIR,
90-
LISTENER_VOLUME_NAME, LOG_CONFIG_DIR, METRICS_PORT, METRICS_PORT_NAME, OPERATOR_NAME,
91-
STACKABLE_LOG_DIR, TEMPLATE_LOCATION, TEMPLATE_NAME, TEMPLATE_VOLUME_NAME,
85+
self, AIRFLOW_CONFIG_FILENAME, APP_NAME, AirflowClusterStatus, AirflowConfig,
86+
AirflowConfigOptions, AirflowConfigOverrides, AirflowExecutor, AirflowRole, CONFIG_PATH,
87+
Container, ExecutorConfig, ExecutorConfigFragment, HTTP_PORT, HTTP_PORT_NAME,
88+
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, LOG_CONFIG_DIR, METRICS_PORT, METRICS_PORT_NAME,
89+
OPERATOR_NAME, STACKABLE_LOG_DIR, TEMPLATE_LOCATION, TEMPLATE_NAME, TEMPLATE_VOLUME_NAME,
9290
authentication::{
9391
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved,
9492
},
@@ -687,7 +685,11 @@ pub async fn reconcile_airflow(
687685
#[allow(clippy::too_many_arguments)]
688686
async fn build_executor_template(
689687
airflow: &v1alpha2::AirflowCluster,
690-
common_config: &CommonConfiguration<ExecutorConfigFragment, GenericCommonConfig, AirflowConfigOverrides>,
688+
common_config: &CommonConfiguration<
689+
ExecutorConfigFragment,
690+
GenericCommonConfig,
691+
AirflowConfigOverrides,
692+
>,
691693
resolved_product_image: &ResolvedProductImage,
692694
authentication_config: &AirflowClientAuthenticationDetailsResolved,
693695
authorization_config: &AirflowAuthorizationResolved,

rust/operator-binary/src/config.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ fn append_oidc_config(
202202
config: &mut BTreeMap<String, String>,
203203
providers: &[(
204204
&oidc::v1alpha1::AuthenticationProvider,
205-
&oidc::v1alpha1::ClientAuthenticationOptions<oidc::v1alpha1::ClientAuthenticationMethodOption>,
205+
&oidc::v1alpha1::ClientAuthenticationOptions<
206+
oidc::v1alpha1::ClientAuthenticationMethodOption,
207+
>,
206208
)],
207209
) -> Result<(), Error> {
208210
// Additionally can be set via config
@@ -235,9 +237,12 @@ fn append_oidc_config(
235237
.well_known_config_url()
236238
.context(InvalidWellKnownConfigUrlSnafu)?;
237239

238-
let client_auth_method =
239-
serde_json::to_value(client_options.product_specific_fields.client_authentication_method)
240-
.expect("ClientAuthenticationMethod should serialize to JSON");
240+
let client_auth_method = serde_json::to_value(
241+
client_options
242+
.product_specific_fields
243+
.client_authentication_method,
244+
)
245+
.expect("ClientAuthenticationMethod should serialize to JSON");
241246
let client_auth_method = client_auth_method
242247
.as_str()
243248
.expect("ClientAuthenticationMethod should serialize to a string");

rust/operator-binary/src/crd/authentication.rs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ type Result<T, E = Error> = std::result::Result<T, E>;
8383
#[serde(rename_all = "camelCase")]
8484
pub struct AirflowClientAuthenticationDetails {
8585
#[serde(flatten)]
86-
pub common:
87-
auth_core::v1alpha1::ClientAuthenticationDetails<oidc::v1alpha1::ClientAuthenticationMethodOption>,
86+
pub common: auth_core::v1alpha1::ClientAuthenticationDetails<
87+
oidc::v1alpha1::ClientAuthenticationMethodOption,
88+
>,
8889

8990
/// Allow users who are not already in the FAB DB.
9091
/// Gets mapped to `AUTH_USER_REGISTRATION`
@@ -133,7 +134,9 @@ pub enum AirflowAuthenticationClassResolved {
133134
},
134135
Oidc {
135136
provider: oidc::v1alpha1::AuthenticationProvider,
136-
oidc: oidc::v1alpha1::ClientAuthenticationOptions<oidc::v1alpha1::ClientAuthenticationMethodOption>,
137+
oidc: oidc::v1alpha1::ClientAuthenticationOptions<
138+
oidc::v1alpha1::ClientAuthenticationMethodOption,
139+
>,
137140
},
138141
}
139142

@@ -143,15 +146,19 @@ impl AirflowClientAuthenticationDetailsResolved {
143146
client: &Client,
144147
) -> Result<AirflowClientAuthenticationDetailsResolved> {
145148
let resolve_auth_class =
146-
|auth_details: auth_core::v1alpha1::ClientAuthenticationDetails<oidc::v1alpha1::ClientAuthenticationMethodOption>| async move {
147-
auth_details.resolve_class(client).await
148-
};
149+
|auth_details: auth_core::v1alpha1::ClientAuthenticationDetails<
150+
oidc::v1alpha1::ClientAuthenticationMethodOption,
151+
>| async move { auth_details.resolve_class(client).await };
149152
AirflowClientAuthenticationDetailsResolved::resolve(auth_details, resolve_auth_class).await
150153
}
151154

152155
pub async fn resolve<R>(
153156
auth_details: &[AirflowClientAuthenticationDetails],
154-
resolve_auth_class: impl Fn(auth_core::v1alpha1::ClientAuthenticationDetails<oidc::v1alpha1::ClientAuthenticationMethodOption>) -> R,
157+
resolve_auth_class: impl Fn(
158+
auth_core::v1alpha1::ClientAuthenticationDetails<
159+
oidc::v1alpha1::ClientAuthenticationMethodOption,
160+
>,
161+
) -> R,
155162
) -> Result<AirflowClientAuthenticationDetailsResolved>
156163
where
157164
R: Future<
@@ -473,9 +480,10 @@ mod tests {
473480
oidc: oidc::v1alpha1::ClientAuthenticationOptions {
474481
client_credentials_secret_ref: "airflow-oidc-client1".into(),
475482
extra_scopes: vec!["groups".into()],
476-
product_specific_fields: oidc::v1alpha1::ClientAuthenticationMethodOption {
477-
client_authentication_method: Default::default(),
478-
}
483+
product_specific_fields:
484+
oidc::v1alpha1::ClientAuthenticationMethodOption {
485+
client_authentication_method: Default::default(),
486+
}
479487
}
480488
},
481489
AirflowAuthenticationClassResolved::Oidc {
@@ -491,9 +499,10 @@ mod tests {
491499
oidc: oidc::v1alpha1::ClientAuthenticationOptions {
492500
client_credentials_secret_ref: "airflow-oidc-client2".into(),
493501
extra_scopes: Vec::new(),
494-
product_specific_fields: oidc::v1alpha1::ClientAuthenticationMethodOption {
495-
client_authentication_method: Default::default(),
496-
}
502+
product_specific_fields:
503+
oidc::v1alpha1::ClientAuthenticationMethodOption {
504+
client_authentication_method: Default::default(),
505+
}
497506
}
498507
}
499508
],
@@ -929,10 +938,13 @@ mod tests {
929938
/// Use this function in the tests to replace
930939
/// `stackable_operator::commons::authentication::ClientAuthenticationDetails`
931940
/// which requires a Kubernetes client.
941+
#[allow(clippy::type_complexity)]
932942
fn create_auth_class_resolver(
933943
auth_classes: Vec<auth_core::v1alpha1::AuthenticationClass>,
934944
) -> impl Fn(
935-
auth_core::v1alpha1::ClientAuthenticationDetails<oidc::v1alpha1::ClientAuthenticationMethodOption>,
945+
auth_core::v1alpha1::ClientAuthenticationDetails<
946+
oidc::v1alpha1::ClientAuthenticationMethodOption,
947+
>,
936948
) -> Pin<
937949
Box<
938950
dyn Future<
@@ -943,7 +955,9 @@ mod tests {
943955
>,
944956
>,
945957
> {
946-
move |auth_details: auth_core::v1alpha1::ClientAuthenticationDetails<oidc::v1alpha1::ClientAuthenticationMethodOption>| {
958+
move |auth_details: auth_core::v1alpha1::ClientAuthenticationDetails<
959+
oidc::v1alpha1::ClientAuthenticationMethodOption,
960+
>| {
947961
let auth_classes = auth_classes.clone();
948962
Box::pin(async move {
949963
auth_classes

rust/operator-binary/src/crd/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use stackable_operator::{
1919
fragment::{self, Fragment, ValidationError},
2020
merge::Merge,
2121
},
22+
config_overrides::KeyValueConfigOverrides,
2223
crd::git_sync,
2324
deep_merger::ObjectOverrides,
2425
k8s_openapi::{
@@ -34,7 +35,6 @@ use stackable_operator::{
3435
framework::{create_vector_shutdown_file_command, remove_vector_shutdown_file_command},
3536
spec::Logging,
3637
},
37-
config_overrides::KeyValueConfigOverrides,
3838
role_utils::{
3939
CommonConfiguration, GenericCommonConfig, GenericRoleConfig, Role, RoleGroup, RoleGroupRef,
4040
},
@@ -505,9 +505,7 @@ impl v1alpha2::AirflowCluster {
505505
}
506506
}
507507

508-
fn extract_role_from_webserver_config(
509-
fragment: AirflowWebserverRoleType,
510-
) -> AirflowRoleType {
508+
fn extract_role_from_webserver_config(fragment: AirflowWebserverRoleType) -> AirflowRoleType {
511509
Role {
512510
config: CommonConfiguration {
513511
config: fragment.config.config,
@@ -855,8 +853,11 @@ pub enum AirflowExecutor {
855853
#[serde(rename = "kubernetesExecutors")]
856854
KubernetesExecutor {
857855
#[serde(flatten)]
858-
common_configuration:
859-
CommonConfiguration<ExecutorConfigFragment, GenericCommonConfig, AirflowConfigOverrides>,
856+
common_configuration: CommonConfiguration<
857+
ExecutorConfigFragment,
858+
GenericCommonConfig,
859+
AirflowConfigOverrides,
860+
>,
860861
},
861862
}
862863

0 commit comments

Comments
 (0)