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 4c07af1e..48c44529 100644 --- a/rust/crd/src/affinity.rs +++ b/rust/crd/src/affinity.rs @@ -21,11 +21,8 @@ pub fn get_affinity(cluster_name: &str, role: &NifiRole) -> StackableAffinityFra #[cfg(test)] mod tests { - use super::*; - use std::collections::BTreeMap; - use crate::NifiCluster; use stackable_operator::{ commons::affinity::StackableAffinity, k8s_openapi::{ @@ -34,6 +31,9 @@ mod tests { }, }; + use super::*; + use crate::NifiCluster; + #[test] fn test_affinity_defaults() { let input = r#" diff --git a/rust/crd/src/authentication.rs b/rust/crd/src/authentication.rs index c82aa869..b2441fd0 100644 --- a/rust/crd/src/authentication.rs +++ b/rust/crd/src/authentication.rs @@ -1,13 +1,13 @@ use std::future::Future; use snafu::{ResultExt, Snafu}; -use stackable_operator::commons::authentication::{ - ldap, oidc, static_, AuthenticationClassProvider, ClientAuthenticationDetails, -}; -use stackable_operator::kube::ResourceExt; use stackable_operator::{ - client::Client, commons::authentication::AuthenticationClass, - kube::runtime::reflector::ObjectRef, + client::Client, + commons::authentication::{ + ldap, oidc, static_, AuthenticationClass, AuthenticationClassProvider, + ClientAuthenticationDetails, + }, + kube::{runtime::reflector::ObjectRef, ResourceExt}, }; use crate::NifiCluster; diff --git a/rust/operator-binary/src/config/mod.rs b/rust/operator-binary/src/config/mod.rs index 5bdea514..c4a660ca 100644 --- a/rust/operator-binary/src/config/mod.rs +++ b/rust/operator-binary/src/config/mod.rs @@ -666,13 +666,12 @@ fn storage_quantity_to_nifi(quantity: MemoryQuantity) -> String { #[cfg(test)] mod tests { - use crate::config::build_bootstrap_conf; - - use super::*; - use indoc::indoc; use stackable_nifi_crd::NifiCluster; + use super::*; + use crate::config::build_bootstrap_conf; + #[test] fn test_build_bootstrap_conf_defaults() { let input = r#" diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index f8f26517..2592a74d 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -5,8 +5,11 @@ mod product_logging; mod reporting_task; mod security; +use std::sync::Arc; + use clap::{crate_description, crate_version, Parser}; use futures::stream::StreamExt; +use stackable_nifi_crd::NifiCluster; use stackable_operator::{ cli::{Command, ProductOperatorRun}, commons::authentication::AuthenticationClass, @@ -25,9 +28,6 @@ use stackable_operator::{ logging::controller::report_controller_reconciled, CustomResourceExt, }; -use std::sync::Arc; - -use stackable_nifi_crd::NifiCluster; use crate::controller::NIFI_FULL_CONTROLLER_NAME; diff --git a/rust/operator-binary/src/reporting_task/mod.rs b/rust/operator-binary/src/reporting_task/mod.rs index 84827f4c..6fff0b4a 100644 --- a/rust/operator-binary/src/reporting_task/mod.rs +++ b/rust/operator-binary/src/reporting_task/mod.rs @@ -24,15 +24,10 @@ //! use std::collections::BTreeMap; -use crate::security::{ - authentication::{NifiAuthenticationConfig, STACKABLE_ADMIN_USERNAME}, - build_tls_volume, -}; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_nifi_crd::{ NifiCluster, NifiRole, APP_NAME, HTTPS_PORT, HTTPS_PORT_NAME, METRICS_PORT, }; -use stackable_operator::time::Duration; use stackable_operator::{ builder::{ self, @@ -52,10 +47,15 @@ use stackable_operator::{ }, kube::ResourceExt, kvp::Labels, + time::Duration, utils::cluster_info::KubernetesClusterInfo, }; use super::controller::{build_recommended_labels, NIFI_UID}; +use crate::security::{ + authentication::{NifiAuthenticationConfig, STACKABLE_ADMIN_USERNAME}, + build_tls_volume, +}; const REPORTING_TASK_CERT_VOLUME_NAME: &str = "tls"; const REPORTING_TASK_CERT_VOLUME_MOUNT: &str = "/stackable/cert"; diff --git a/rust/operator-binary/src/security/authentication.rs b/rust/operator-binary/src/security/authentication.rs index fd8b9e13..1048b841 100644 --- a/rust/operator-binary/src/security/authentication.rs +++ b/rust/operator-binary/src/security/authentication.rs @@ -1,7 +1,6 @@ use indoc::{formatdoc, indoc}; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_nifi_crd::authentication::AuthenticationClassResolved; -use stackable_nifi_crd::NifiCluster; +use stackable_nifi_crd::{authentication::AuthenticationClassResolved, NifiCluster}; use stackable_operator::{ builder::{ self, diff --git a/rust/operator-binary/src/security/mod.rs b/rust/operator-binary/src/security/mod.rs index ce473170..34decae3 100644 --- a/rust/operator-binary/src/security/mod.rs +++ b/rust/operator-binary/src/security/mod.rs @@ -1,8 +1,9 @@ use snafu::{ResultExt, Snafu}; use stackable_nifi_crd::NifiCluster; -use stackable_operator::client::Client; -use stackable_operator::time::Duration; -use stackable_operator::{builder::pod::volume::SecretFormat, k8s_openapi::api::core::v1::Volume}; +use stackable_operator::{ + builder::pod::volume::SecretFormat, client::Client, k8s_openapi::api::core::v1::Volume, + time::Duration, +}; pub mod authentication; pub mod oidc; diff --git a/rust/operator-binary/src/security/tls.rs b/rust/operator-binary/src/security/tls.rs index 3cbae6d3..f46860e3 100644 --- a/rust/operator-binary/src/security/tls.rs +++ b/rust/operator-binary/src/security/tls.rs @@ -1,12 +1,13 @@ -use crate::security::authentication::STACKABLE_TLS_STORE_PASSWORD; use snafu::{ResultExt, Snafu}; use stackable_nifi_crd::NifiCluster; -use stackable_operator::time::Duration; use stackable_operator::{ builder::pod::volume::{SecretFormat, SecretOperatorVolumeSourceBuilder, VolumeBuilder}, k8s_openapi::api::core::v1::Volume, + time::Duration, }; +use crate::security::authentication::STACKABLE_TLS_STORE_PASSWORD; + pub const KEYSTORE_VOLUME_NAME: &str = "keystore"; pub const KEYSTORE_NIFI_CONTAINER_MOUNT: &str = "/stackable/keystore"; pub const TRUSTSTORE_VOLUME_NAME: &str = "truststore";