Skip to content

Commit

Permalink
Merge branch 'main' into bump/kafka-3.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLarsenNZ authored Feb 4, 2025
2 parents 8e793ee + b9b7ecf commit 7f52f04
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr_pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: eeee35a89e69d5772bdee97db1a6a898467b686e # 1.0
hooks:
- id: fmt
args: ["--all", "--", "--check"]
- id: clippy
args: ["--all-targets", "--", "-D", "warnings"]

Expand Down Expand Up @@ -76,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
2 changes: 1 addition & 1 deletion deploy/helm/kafka-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ spec:
metadata:
annotations:
internal.stackable.tech/image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
{{- with .Values.podAnnotations }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
Expand Down
8 changes: 4 additions & 4 deletions rust/crd/src/affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ pub fn get_affinity(cluster_name: &str, role: &KafkaRole) -> StackableAffinityFr

#[cfg(test)]
mod tests {
use super::*;

use rstest::rstest;
use std::collections::BTreeMap;

use crate::KafkaCluster;
use rstest::rstest;
use stackable_operator::{
commons::affinity::StackableAffinity,
k8s_openapi::{
Expand All @@ -35,6 +32,9 @@ mod tests {
},
};

use super::*;
use crate::KafkaCluster;

#[rstest]
#[case(KafkaRole::Broker)]
fn test_affinity_defaults(#[case] role: KafkaRole) {
Expand Down
7 changes: 3 additions & 4 deletions rust/crd/src/authentication.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use crate::ObjectRef;

use serde::{Deserialize, Serialize};
use snafu::{ResultExt, Snafu};
use stackable_operator::commons::authentication::AuthenticationClassProvider;
use stackable_operator::{
client::Client,
commons::authentication::AuthenticationClass,
commons::authentication::{AuthenticationClass, AuthenticationClassProvider},
schemars::{self, JsonSchema},
};

use crate::ObjectRef;

pub const SUPPORTED_AUTHENTICATION_CLASS_PROVIDERS: [&str; 2] = ["TLS", "Kerberos"];

#[derive(Snafu, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ pub mod listener;
pub mod security;
pub mod tls;

use crate::authorization::KafkaAuthorization;
use crate::tls::KafkaTls;
use std::{collections::BTreeMap, str::FromStr};

use affinity::get_affinity;
use authentication::KafkaAuthentication;
Expand Down Expand Up @@ -38,9 +37,10 @@ use stackable_operator::{
time::Duration,
utils::cluster_info::KubernetesClusterInfo,
};
use std::{collections::BTreeMap, str::FromStr};
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};

use crate::{authorization::KafkaAuthorization, tls::KafkaTls};

pub const DOCKER_IMAGE_BASE_NAME: &str = "kafka";
pub const APP_NAME: &str = "kafka";
pub const OPERATOR_NAME: &str = "kafka.stackable.tech";
Expand Down
18 changes: 9 additions & 9 deletions rust/crd/src/listener.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};
use std::{
collections::BTreeMap,
fmt::{Display, Formatter},
};

use snafu::{OptionExt, Snafu};
use stackable_operator::kube::ResourceExt;
use stackable_operator::utils::cluster_info::KubernetesClusterInfo;
use stackable_operator::{kube::ResourceExt, utils::cluster_info::KubernetesClusterInfo};
use strum::{EnumDiscriminants, EnumString};

use crate::security::KafkaTlsSecurity;
use crate::{KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};
use crate::{security::KafkaTlsSecurity, KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};

const LISTENER_LOCAL_ADDRESS: &str = "0.0.0.0";

Expand Down Expand Up @@ -260,9 +260,6 @@ pub fn pod_fqdn(

#[cfg(test)]
mod tests {
use super::*;
use crate::authentication::ResolvedAuthenticationClasses;

use stackable_operator::{
builder::meta::ObjectMetaBuilder,
commons::{
Expand All @@ -275,6 +272,9 @@ mod tests {
},
};

use super::*;
use crate::authentication::ResolvedAuthenticationClasses;

fn default_cluster_info() -> KubernetesClusterInfo {
KubernetesClusterInfo {
cluster_domain: DomainName::try_from("cluster.local").unwrap(),
Expand Down
21 changes: 9 additions & 12 deletions rust/crd/src/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,8 @@
//! This is required due to overlaps between TLS encryption and e.g. mTLS authentication or Kerberos
use std::collections::BTreeMap;

use crate::{
authentication::{self, ResolvedAuthenticationClasses},
listener::{self, KafkaListenerConfig},
tls, KafkaCluster, LISTENER_BOOTSTRAP_VOLUME_NAME, SERVER_PROPERTIES_FILE,
STACKABLE_CONFIG_DIR,
};
use crate::{
listener::node_address_cmd, STACKABLE_KERBEROS_KRB5_PATH, STACKABLE_LISTENER_BOOTSTRAP_DIR,
STACKABLE_LISTENER_BROKER_DIR,
};
use crate::{KafkaRole, LISTENER_BROKER_VOLUME_NAME, STACKABLE_LOG_DIR};
use indoc::formatdoc;
use snafu::{ensure, ResultExt, Snafu};
use stackable_operator::time::Duration;
use stackable_operator::{
builder::{
self,
Expand All @@ -35,9 +23,18 @@ use stackable_operator::{
product_logging::framework::{
create_vector_shutdown_file_command, remove_vector_shutdown_file_command,
},
time::Duration,
utils::COMMON_BASH_TRAP_FUNCTIONS,
};

use crate::{
authentication::{self, ResolvedAuthenticationClasses},
listener::{self, node_address_cmd, KafkaListenerConfig},
tls, KafkaCluster, KafkaRole, LISTENER_BOOTSTRAP_VOLUME_NAME, LISTENER_BROKER_VOLUME_NAME,
SERVER_PROPERTIES_FILE, STACKABLE_CONFIG_DIR, STACKABLE_KERBEROS_KRB5_PATH,
STACKABLE_LISTENER_BOOTSTRAP_DIR, STACKABLE_LISTENER_BROKER_DIR, STACKABLE_LOG_DIR,
};

#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("failed to process authentication class"))]
Expand Down
5 changes: 2 additions & 3 deletions rust/operator-binary/src/kerberos.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use snafu::{ResultExt, Snafu};
use stackable_kafka_crd::{security::KafkaTlsSecurity, KafkaRole};
use stackable_kafka_crd::{
LISTENER_BOOTSTRAP_VOLUME_NAME, LISTENER_BROKER_VOLUME_NAME, STACKABLE_KERBEROS_DIR,
STACKABLE_KERBEROS_KRB5_PATH,
security::KafkaTlsSecurity, KafkaRole, LISTENER_BOOTSTRAP_VOLUME_NAME,
LISTENER_BROKER_VOLUME_NAME, STACKABLE_KERBEROS_DIR, STACKABLE_KERBEROS_KRB5_PATH,
};
use stackable_operator::builder::{
self,
Expand Down
5 changes: 5 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file includes unstable features, so you need to run "cargo +nightly fmt" to format your code.
# It's also ok to use the stable toolchain by simple running "cargo fmt", but using the nigthly formatter is prefered.

imports_granularity = "Crate"
group_imports = "StdExternalCrate"

0 comments on commit 7f52f04

Please sign in to comment.