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 c4634f30..94052a57 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: &SupersetRole) -> StackableAffinit #[cfg(test)] mod tests { - use super::*; - use std::collections::BTreeMap; - use crate::SupersetCluster; use stackable_operator::{ commons::affinity::StackableAffinity, k8s_openapi::{ @@ -34,6 +31,9 @@ mod tests { }, }; + use super::*; + use crate::SupersetCluster; + #[test] fn test_affinity_defaults() { let input = r#" diff --git a/rust/crd/src/authentication.rs b/rust/crd/src/authentication.rs index d972c1a8..0cccd496 100644 --- a/rust/crd/src/authentication.rs +++ b/rust/crd/src/authentication.rs @@ -324,11 +324,16 @@ mod tests { use std::pin::Pin; use indoc::indoc; - use stackable_operator::commons::networking::HostName; - use stackable_operator::commons::tls_verification::{ - CaCert, Tls, TlsClientDetails, TlsServerVerification, TlsVerification, + use stackable_operator::{ + commons::{ + authentication::oidc, + networking::HostName, + tls_verification::{ + CaCert, Tls, TlsClientDetails, TlsServerVerification, TlsVerification, + }, + }, + kube, }; - use stackable_operator::{commons::authentication::oidc, kube}; use super::*; diff --git a/rust/crd/src/druidconnection.rs b/rust/crd/src/druidconnection.rs index d58612bb..0b705a24 100644 --- a/rust/crd/src/druidconnection.rs +++ b/rust/crd/src/druidconnection.rs @@ -1,10 +1,10 @@ use serde::{Deserialize, Serialize}; use snafu::Snafu; -use stackable_operator::k8s_openapi::apimachinery::pkg::apis::meta::v1::Time; -use stackable_operator::k8s_openapi::chrono::Utc; -use stackable_operator::kube::CustomResource; -use stackable_operator::kube::ResourceExt; -use stackable_operator::schemars::{self, JsonSchema}; +use stackable_operator::{ + k8s_openapi::{apimachinery::pkg::apis::meta::v1::Time, chrono::Utc}, + kube::{CustomResource, ResourceExt}, + schemars::{self, JsonSchema}, +}; #[derive(Snafu, Debug)] #[allow(clippy::enum_variant_names)] diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 0cbf3284..837f18ae 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -14,7 +14,11 @@ use stackable_operator::{ Resources, ResourcesFragment, }, }, - config::{fragment, fragment::Fragment, fragment::ValidationError, merge::Merge}, + config::{ + fragment, + fragment::{Fragment, ValidationError}, + merge::Merge, + }, k8s_openapi::apimachinery::pkg::api::resource::Quantity, kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt}, memory::{BinaryMultiple, MemoryQuantity}, diff --git a/rust/operator-binary/src/config.rs b/rust/operator-binary/src/config.rs index ee01a5f3..af2914e5 100644 --- a/rust/operator-binary/src/config.rs +++ b/rust/operator-binary/src/config.rs @@ -1,3 +1,5 @@ +use std::collections::BTreeMap; + use indoc::formatdoc; use snafu::{ResultExt, Snafu}; use stackable_operator::commons::authentication::{ldap, oidc}; @@ -8,7 +10,6 @@ use stackable_superset_crd::{ }, SupersetConfigOptions, }; -use std::collections::BTreeMap; #[derive(Snafu, Debug)] pub enum Error { diff --git a/rust/operator-binary/src/druid_connection_controller.rs b/rust/operator-binary/src/druid_connection_controller.rs index c61411fd..563839ce 100644 --- a/rust/operator-binary/src/druid_connection_controller.rs +++ b/rust/operator-binary/src/druid_connection_controller.rs @@ -1,5 +1,3 @@ -use crate::util::{get_job_state, JobState}; - use std::sync::Arc; use const_format::concatcp; @@ -16,8 +14,7 @@ use stackable_operator::{ core::v1::{ConfigMap, PodSpec, PodTemplateSpec}, }, kube::{ - core::DynamicObject, - core::{error_boundary, DeserializeGuard}, + core::{error_boundary, DeserializeGuard, DynamicObject}, runtime::{controller::Action, reflector::ObjectRef}, ResourceExt, }, @@ -31,7 +28,12 @@ use stackable_superset_crd::{ }; use strum::{EnumDiscriminants, IntoStaticStr}; -use crate::{rbac, superset_controller::DOCKER_IMAGE_BASE_NAME, APP_NAME, OPERATOR_NAME}; +use crate::{ + rbac, + superset_controller::DOCKER_IMAGE_BASE_NAME, + util::{get_job_state, JobState}, + APP_NAME, OPERATOR_NAME, +}; pub const DRUID_CONNECTION_CONTROLLER_NAME: &str = "druid-connection"; pub const DRUID_CONNECTION_FULL_CONTROLLER_NAME: &str = diff --git a/rust/operator-binary/src/util.rs b/rust/operator-binary/src/util.rs index 4cdb0b1c..84fd1a93 100644 --- a/rust/operator-binary/src/util.rs +++ b/rust/operator-binary/src/util.rs @@ -1,8 +1,8 @@ -use crate::OPERATOR_NAME; -use stackable_operator::k8s_openapi::api::batch::v1::Job; -use stackable_operator::kvp::ObjectLabels; +use stackable_operator::{k8s_openapi::api::batch::v1::Job, kvp::ObjectLabels}; use stackable_superset_crd::APP_NAME; +use crate::OPERATOR_NAME; + pub enum JobState { InProgress, Complete,