diff --git a/.github/workflows/pr_pre-commit.yaml b/.github/workflows/pr_pre-commit.yaml index ec55fe78..bdc3ddfd 100644 --- a/.github/workflows/pr_pre-commit.yaml +++ b/.github/workflows/pr_pre-commit.yaml @@ -6,7 +6,7 @@ on: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN_VERSION: "1.82.0" + RUST_TOOLCHAIN_VERSION: "nightly-2025-01-15" HADOLINT_VERSION: "v2.12.0" PYTHON_VERSION: "3.12" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a36fdcb7..c5bd8ad1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,10 +17,6 @@ repos: - repo: https://github.com/doublify/pre-commit-rust rev: eeee35a89e69d5772bdee97db1a6a898467b686e # 1.0 hooks: - - id: fmt - # Pinning to a specific rustc version, so that we get consistent formatting - entry: RUSTUP_TOOLCHAIN=nightly-2025-01-15 cargo fmt - args: ["--all", "--", "--check"] - id: clippy args: ["--all-targets", "--", "-D", "warnings"] @@ -78,3 +74,10 @@ repos: entry: cargo test stages: [pre-commit, pre-merge-commit, manual] pass_filenames: false + + - id: cargo-rustfmt + name: cargo-rustfmt + language: system + entry: cargo +nightly-2025-01-15 fmt --all -- --check + stages: [pre-commit] + pass_filenames: false diff --git a/rust/crd/src/affinity.rs b/rust/crd/src/affinity.rs index ecaf78f9..434499a5 100644 --- a/rust/crd/src/affinity.rs +++ b/rust/crd/src/affinity.rs @@ -21,12 +21,9 @@ pub fn get_affinity(cluster_name: &str, role: &HiveRole) -> StackableAffinityFra #[cfg(test)] mod tests { - use super::*; - - use rstest::rstest; use std::collections::BTreeMap; - use crate::HiveCluster; + use rstest::rstest; use stackable_operator::{ commons::affinity::StackableAffinity, k8s_openapi::{ @@ -35,6 +32,9 @@ mod tests { }, }; + use super::*; + use crate::HiveCluster; + #[rstest] #[case(HiveRole::MetaStore)] fn test_affinity_defaults(#[case] role: HiveRole) { diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 14bc310c..35af5fa1 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -37,15 +37,16 @@ use stackable_operator::{ commons::{ product_image_selection::ResolvedProductImage, rbac::build_rbac_resources, - s3::{S3AccessStyle, S3ConnectionSpec}, + s3::{S3AccessStyle, S3ConnectionSpec, S3Error}, tls_verification::TlsClientDetailsError, }, k8s_openapi::{ api::{ apps::v1::{StatefulSet, StatefulSetSpec}, core::v1::{ - ConfigMap, ConfigMapVolumeSource, EmptyDirVolumeSource, Probe, Service, - ServicePort, ServiceSpec, TCPSocketAction, Volume, + ConfigMap, ConfigMapVolumeSource, EmptyDirVolumeSource, EnvVar, EnvVarSource, + Probe, SecretKeySelector, Service, ServicePort, ServiceSpec, TCPSocketAction, + Volume, }, }, apimachinery::pkg::{ @@ -80,10 +81,6 @@ use stackable_operator::{ time::Duration, utils::{cluster_info::KubernetesClusterInfo, COMMON_BASH_TRAP_FUNCTIONS}, }; -use stackable_operator::{ - commons::s3::S3Error, - k8s_openapi::api::core::v1::{EnvVar, EnvVarSource, SecretKeySelector}, -}; use strum::EnumDiscriminants; use tracing::warn; diff --git a/rust/operator-binary/src/discovery.rs b/rust/operator-binary/src/discovery.rs index 326b4c39..5e3f268a 100644 --- a/rust/operator-binary/src/discovery.rs +++ b/rust/operator-binary/src/discovery.rs @@ -1,16 +1,15 @@ -use crate::controller::build_recommended_labels; +use std::{collections::BTreeSet, num::TryFromIntError}; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_hive_crd::{HiveCluster, HiveRole, ServiceType, HIVE_PORT, HIVE_PORT_NAME}; -use stackable_operator::commons::product_image_selection::ResolvedProductImage; use stackable_operator::{ builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder}, - k8s_openapi::api::core::v1::ConfigMap, - k8s_openapi::api::core::v1::{Endpoints, Service, ServiceSpec}, + commons::product_image_selection::ResolvedProductImage, + k8s_openapi::api::core::v1::{ConfigMap, Endpoints, Service, ServiceSpec}, kube::{runtime::reflector::ObjectRef, Resource}, }; -use std::collections::BTreeSet; -use std::num::TryFromIntError; + +use crate::controller::build_recommended_labels; #[derive(Snafu, Debug)] pub enum Error { diff --git a/rust/operator-binary/src/kerberos.rs b/rust/operator-binary/src/kerberos.rs index f70d032d..aa95d69e 100644 --- a/rust/operator-binary/src/kerberos.rs +++ b/rust/operator-binary/src/kerberos.rs @@ -1,3 +1,5 @@ +use std::collections::BTreeMap; + use indoc::formatdoc; use snafu::{ResultExt, Snafu}; use stackable_hive_crd::{HiveCluster, HiveRole, HIVE_SITE_XML, STACKABLE_CONFIG_DIR}; @@ -16,7 +18,6 @@ use stackable_operator::{ kube::ResourceExt, utils::cluster_info::KubernetesClusterInfo, }; -use std::collections::BTreeMap; #[derive(Snafu, Debug)] #[allow(clippy::enum_variant_names)] // all variants have the same prefix: `Add` diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 7ed70087..0af87dfc 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -1,5 +1,3 @@ -use crate::controller::MAX_HIVE_LOG_FILES_SIZE; - use snafu::{OptionExt, ResultExt, Snafu}; use stackable_hive_crd::{ Container, HiveCluster, HIVE_METASTORE_LOG4J2_PROPERTIES, STACKABLE_LOG_DIR, @@ -17,6 +15,8 @@ use stackable_operator::{ role_utils::RoleGroupRef, }; +use crate::controller::MAX_HIVE_LOG_FILES_SIZE; + #[derive(Snafu, Debug)] pub enum Error { #[snafu(display("object has no namespace"))]