Skip to content

Commit 51cf3cc

Browse files
committed
fix: rustfmt lint
1 parent 6722016 commit 51cf3cc

File tree

11 files changed

+82
-84
lines changed

11 files changed

+82
-84
lines changed

rust/operator-binary/src/config/jvm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use stackable_operator::{
55
};
66

77
use crate::crd::{
8-
v1alpha1, AnyServiceConfig, HbaseRole, CONFIG_DIR_NAME, JVM_SECURITY_PROPERTIES_FILE,
9-
METRICS_PORT,
8+
AnyServiceConfig, CONFIG_DIR_NAME, HbaseRole, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
9+
v1alpha1,
1010
};
1111

1212
const JAVA_HEAP_FACTOR: f32 = 0.8;
@@ -144,7 +144,7 @@ fn is_heap_jvm_argument(jvm_argument: &str) -> bool {
144144
#[cfg(test)]
145145
mod tests {
146146
use super::*;
147-
use crate::crd::{v1alpha1, HbaseRole};
147+
use crate::crd::{HbaseRole, v1alpha1};
148148

149149
#[test]
150150
fn test_construct_jvm_arguments_defaults() {

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

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use stackable_operator::{
22
commons::affinity::{
3-
affinity_between_cluster_pods, affinity_between_role_pods, StackableAffinityFragment,
3+
StackableAffinityFragment, affinity_between_cluster_pods, affinity_between_role_pods,
44
},
55
k8s_openapi::api::core::v1::{PodAffinity, PodAntiAffinity},
66
};
77

8-
use crate::crd::{HbaseRole, APP_NAME};
8+
use crate::crd::{APP_NAME, HbaseRole};
99

1010
pub fn get_affinity(
1111
cluster_name: &str,
@@ -186,45 +186,39 @@ mod tests {
186186
HbaseRole::RestServer => (),
187187
};
188188

189-
assert_eq!(
190-
affinity,
191-
StackableAffinity {
192-
pod_affinity: Some(PodAffinity {
193-
preferred_during_scheduling_ignored_during_execution: Some(expected_affinities),
194-
required_during_scheduling_ignored_during_execution: None,
195-
}),
196-
pod_anti_affinity: Some(PodAntiAffinity {
197-
preferred_during_scheduling_ignored_during_execution: Some(vec![
198-
WeightedPodAffinityTerm {
199-
pod_affinity_term: PodAffinityTerm {
200-
label_selector: Some(LabelSelector {
201-
match_expressions: None,
202-
match_labels: Some(BTreeMap::from([
203-
("app.kubernetes.io/name".to_string(), "hbase".to_string(),),
204-
(
205-
"app.kubernetes.io/instance".to_string(),
206-
"simple-hbase".to_string(),
207-
),
208-
(
209-
"app.kubernetes.io/component".to_string(),
210-
role.to_string(),
211-
)
212-
]))
213-
}),
214-
match_label_keys: None,
215-
mismatch_label_keys: None,
216-
namespace_selector: None,
217-
namespaces: None,
218-
topology_key: "kubernetes.io/hostname".to_string(),
219-
},
220-
weight: 70
221-
}
222-
]),
223-
required_during_scheduling_ignored_during_execution: None,
224-
}),
225-
node_affinity: None,
226-
node_selector: None,
227-
}
228-
);
189+
assert_eq!(affinity, StackableAffinity {
190+
pod_affinity: Some(PodAffinity {
191+
preferred_during_scheduling_ignored_during_execution: Some(expected_affinities),
192+
required_during_scheduling_ignored_during_execution: None,
193+
}),
194+
pod_anti_affinity: Some(PodAntiAffinity {
195+
preferred_during_scheduling_ignored_during_execution: Some(vec![
196+
WeightedPodAffinityTerm {
197+
pod_affinity_term: PodAffinityTerm {
198+
label_selector: Some(LabelSelector {
199+
match_expressions: None,
200+
match_labels: Some(BTreeMap::from([
201+
("app.kubernetes.io/name".to_string(), "hbase".to_string(),),
202+
(
203+
"app.kubernetes.io/instance".to_string(),
204+
"simple-hbase".to_string(),
205+
),
206+
("app.kubernetes.io/component".to_string(), role.to_string(),)
207+
]))
208+
}),
209+
match_label_keys: None,
210+
mismatch_label_keys: None,
211+
namespace_selector: None,
212+
namespaces: None,
213+
topology_key: "kubernetes.io/hostname".to_string(),
214+
},
215+
weight: 70
216+
}
217+
]),
218+
required_during_scheduling_ignored_during_execution: None,
219+
}),
220+
node_affinity: None,
221+
node_selector: None,
222+
});
229223
}
230224
}

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use stackable_operator::{
2020
merge::{Atomic, Merge},
2121
},
2222
k8s_openapi::{
23+
DeepMerge,
2324
api::core::v1::{EnvVar, PodTemplateSpec},
2425
apimachinery::pkg::api::resource::Quantity,
25-
DeepMerge,
2626
},
27-
kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt},
27+
kube::{CustomResource, ResourceExt, runtime::reflector::ObjectRef},
2828
product_config_utils::Configuration,
2929
product_logging::{self, spec::Logging},
3030
role_utils::{GenericRoleConfig, JavaCommonConfig, Role, RoleGroupRef},
@@ -640,15 +640,14 @@ pub enum HbaseRole {
640640

641641
impl HbaseRole {
642642
const DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(20);
643-
const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
644-
Duration::from_minutes_unchecked(60);
645-
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
646-
Duration::from_minutes_unchecked(5);
647-
648643
// Auto TLS certificate lifetime
649644
const DEFAULT_MASTER_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
650645
const DEFAULT_REGION_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
646+
const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
647+
Duration::from_minutes_unchecked(60);
651648
const DEFAULT_REST_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
649+
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
650+
Duration::from_minutes_unchecked(5);
652651

653652
pub fn default_config(
654653
&self,
@@ -1153,27 +1152,31 @@ impl AnyServiceConfig {
11531152
AnyServiceConfig::RestServer(config) => &config.resources,
11541153
}
11551154
}
1155+
11561156
pub fn logging(&self) -> &Logging<Container> {
11571157
match self {
11581158
AnyServiceConfig::Master(config) => &config.logging,
11591159
AnyServiceConfig::RegionServer(config) => &config.logging,
11601160
AnyServiceConfig::RestServer(config) => &config.logging,
11611161
}
11621162
}
1163+
11631164
pub fn affinity(&self) -> &StackableAffinity {
11641165
match self {
11651166
AnyServiceConfig::Master(config) => &config.affinity,
11661167
AnyServiceConfig::RegionServer(config) => &config.affinity,
11671168
AnyServiceConfig::RestServer(config) => &config.affinity,
11681169
}
11691170
}
1171+
11701172
pub fn graceful_shutdown_timeout(&self) -> &Option<Duration> {
11711173
match self {
11721174
AnyServiceConfig::Master(config) => &config.graceful_shutdown_timeout,
11731175
AnyServiceConfig::RegionServer(config) => &config.graceful_shutdown_timeout,
11741176
AnyServiceConfig::RestServer(config) => &config.graceful_shutdown_timeout,
11751177
}
11761178
}
1179+
11771180
pub fn requested_secret_lifetime(&self) -> Option<Duration> {
11781181
match self {
11791182
AnyServiceConfig::Master(config) => config.requested_secret_lifetime,
@@ -1243,7 +1246,7 @@ mod tests {
12431246
use std::collections::{BTreeMap, HashMap};
12441247

12451248
use indoc::indoc;
1246-
use product_config::{types::PropertyNameKind, ProductConfigManager};
1249+
use product_config::{ProductConfigManager, types::PropertyNameKind};
12471250
use rstest::rstest;
12481251
use stackable_operator::product_config_utils::{
12491252
transform_all_roles_to_config, validate_all_roles_and_groups_config,

rust/operator-binary/src/discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use stackable_operator::{
1111
};
1212

1313
use crate::{
14-
crd::{v1alpha1, HbaseRole, HBASE_SITE_XML},
14+
crd::{HBASE_SITE_XML, HbaseRole, v1alpha1},
1515
hbase_controller::build_recommended_labels,
1616
kerberos::{self, kerberos_discovery_config_properties},
1717
zookeeper::ZookeeperConnectionInformation,

rust/operator-binary/src/hbase_controller.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use std::{
99

1010
use const_format::concatcp;
1111
use product_config::{
12-
types::PropertyNameKind,
13-
writer::{to_hadoop_xml, to_java_properties_string, PropertiesWriterError},
1412
ProductConfigManager,
13+
types::PropertyNameKind,
14+
writer::{PropertiesWriterError, to_hadoop_xml, to_java_properties_string},
1515
};
1616
use snafu::{OptionExt, ResultExt, Snafu};
1717
use stackable_operator::{
@@ -20,8 +20,8 @@ use stackable_operator::{
2020
configmap::ConfigMapBuilder,
2121
meta::ObjectMetaBuilder,
2222
pod::{
23-
container::ContainerBuilder, resources::ResourceRequirementsBuilder,
24-
security::PodSecurityContextBuilder, PodBuilder,
23+
PodBuilder, container::ContainerBuilder, resources::ResourceRequirementsBuilder,
24+
security::PodSecurityContextBuilder,
2525
},
2626
},
2727
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
@@ -37,9 +37,9 @@ use stackable_operator::{
3737
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
3838
},
3939
kube::{
40-
core::{error_boundary, DeserializeGuard},
41-
runtime::controller::Action,
4240
Resource, ResourceExt,
41+
core::{DeserializeGuard, error_boundary},
42+
runtime::controller::Action,
4343
},
4444
kvp::{Label, LabelError, Labels, ObjectLabels},
4545
logging::controller::ReconcilerError,
@@ -64,14 +64,15 @@ use stackable_operator::{
6464
use strum::{EnumDiscriminants, IntoStaticStr, ParseError};
6565

6666
use crate::{
67+
OPERATOR_NAME,
6768
config::jvm::{
6869
construct_global_jvm_args, construct_hbase_heapsize_env,
6970
construct_role_specific_non_heap_jvm_args,
7071
},
7172
crd::{
72-
merged_env, v1alpha1, AnyServiceConfig, Container, HbaseClusterStatus, HbaseRole, APP_NAME,
73-
HBASE_ENV_SH, HBASE_REST_PORT_NAME_HTTP, HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML,
74-
JVM_SECURITY_PROPERTIES_FILE, SSL_CLIENT_XML, SSL_SERVER_XML,
73+
APP_NAME, AnyServiceConfig, Container, HBASE_ENV_SH, HBASE_REST_PORT_NAME_HTTP,
74+
HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, HbaseClusterStatus, HbaseRole,
75+
JVM_SECURITY_PROPERTIES_FILE, SSL_CLIENT_XML, SSL_SERVER_XML, merged_env, v1alpha1,
7576
},
7677
discovery::build_discovery_configmap,
7778
kerberos::{
@@ -80,12 +81,11 @@ use crate::{
8081
},
8182
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
8283
product_logging::{
83-
extend_role_group_config_map, resolve_vector_aggregator_address,
84-
CONTAINERDEBUG_LOG_DIRECTORY, STACKABLE_LOG_DIR,
84+
CONTAINERDEBUG_LOG_DIRECTORY, STACKABLE_LOG_DIR, extend_role_group_config_map,
85+
resolve_vector_aggregator_address,
8586
},
8687
security::{self, opa::HbaseOpaConfig},
8788
zookeeper::{self, ZookeeperConnectionInformation},
88-
OPERATOR_NAME,
8989
};
9090

9191
pub const HBASE_CONTROLLER_NAME: &str = "hbasecluster";

rust/operator-binary/src/kerberos.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ use stackable_operator::{
55
builder::{
66
self,
77
pod::{
8+
PodBuilder,
89
container::ContainerBuilder,
910
volume::{SecretFormat, SecretOperatorVolumeSourceBuilder, VolumeBuilder},
10-
PodBuilder,
1111
},
1212
},
13-
kube::{runtime::reflector::ObjectRef, ResourceExt},
13+
kube::{ResourceExt, runtime::reflector::ObjectRef},
1414
time::Duration,
1515
utils::cluster_info::KubernetesClusterInfo,
1616
};
1717

18-
use crate::crd::{v1alpha1, TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_VOLUME_NAME};
18+
use crate::crd::{TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_VOLUME_NAME, v1alpha1};
1919

2020
#[derive(Snafu, Debug)]
2121
pub enum Error {

rust/operator-binary/src/main.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ use clap::Parser;
44
use futures::StreamExt;
55
use hbase_controller::FULL_HBASE_CONTROLLER_NAME;
66
use stackable_operator::{
7+
YamlSchema,
78
cli::{Command, ProductOperatorRun},
89
k8s_openapi::api::{apps::v1::StatefulSet, core::v1::Service},
910
kube::{
1011
core::DeserializeGuard,
1112
runtime::{
13+
Controller,
1214
events::{Recorder, Reporter},
13-
watcher, Controller,
15+
watcher,
1416
},
1517
},
1618
logging::controller::report_controller_reconciled,
1719
shared::yaml::SerializeOptions,
18-
YamlSchema,
1920
};
2021

21-
use crate::crd::{v1alpha1, HbaseCluster, APP_NAME};
22+
use crate::crd::{APP_NAME, HbaseCluster, v1alpha1};
2223

2324
mod config;
2425
mod crd;
@@ -80,13 +81,10 @@ async fn main() -> anyhow::Result<()> {
8081
)
8182
.await?;
8283

83-
let event_recorder = Arc::new(Recorder::new(
84-
client.as_kube_client(),
85-
Reporter {
86-
controller: FULL_HBASE_CONTROLLER_NAME.to_string(),
87-
instance: None,
88-
},
89-
));
84+
let event_recorder = Arc::new(Recorder::new(client.as_kube_client(), Reporter {
85+
controller: FULL_HBASE_CONTROLLER_NAME.to_string(),
86+
instance: None,
87+
}));
9088

9189
Controller::new(
9290
watch_namespace.get_api::<DeserializeGuard<v1alpha1::HbaseCluster>>(&client),

rust/operator-binary/src/operations/pdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use stackable_operator::{
55
};
66

77
use crate::{
8-
crd::{v1alpha1, HbaseRole, APP_NAME},
9-
hbase_controller::HBASE_CONTROLLER_NAME,
108
OPERATOR_NAME,
9+
crd::{APP_NAME, HbaseRole, v1alpha1},
10+
hbase_controller::HBASE_CONTROLLER_NAME,
1111
};
1212

1313
#[derive(Snafu, Debug)]

rust/operator-binary/src/product_logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use stackable_operator::{
1515
};
1616

1717
use crate::{
18-
crd::{v1alpha1, Container},
18+
crd::{Container, v1alpha1},
1919
hbase_controller::MAX_HBASE_LOG_FILES_SIZE,
2020
};
2121

rust/operator-binary/src/security/opa.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ impl HbaseOpaConfig {
4646
..HbaseOpaConfig::default()
4747
}
4848
}
49+
4950
pub async fn from_opa_config(
5051
client: &Client,
5152
hbase: &v1alpha1::HbaseCluster,

0 commit comments

Comments
 (0)