11use std:: { fmt:: Display , str:: FromStr } ;
22
33use snafu:: { OptionExt , ResultExt , Snafu } ;
4- use stackable_operator:: {
4+ use strum:: { EnumDiscriminants , IntoStaticStr } ;
5+
6+ use crate :: {
57 builder:: pod:: { container:: FieldPathEnvVar , resources:: ResourceRequirementsBuilder } ,
68 commons:: product_image_selection:: ResolvedProductImage ,
9+ constant,
710 k8s_openapi:: api:: core:: v1:: { Container , VolumeMount } ,
811 product_logging:: {
912 framework:: VECTOR_CONFIG_FILE ,
@@ -12,12 +15,7 @@ use stackable_operator::{
1215 ContainerLogConfigChoice , CustomContainerLogConfig , LogLevel , Logging ,
1316 } ,
1417 } ,
15- } ;
16- use strum:: { EnumDiscriminants , IntoStaticStr } ;
17-
18- use crate :: {
19- constant,
20- framework:: {
18+ v2:: {
2119 builder:: pod:: container:: { EnvVarName , EnvVarSet , new_container_builder} ,
2220 role_group_utils,
2321 types:: kubernetes:: { ConfigMapKey , ConfigMapName , ContainerName , VolumeName } ,
@@ -54,7 +52,7 @@ pub enum Error {
5452
5553 #[ snafu( display( "failed to parse the container name" ) ) ]
5654 ParseContainerName {
57- source : crate :: framework :: macros:: attributed_string_type:: Error ,
55+ source : crate :: v2 :: macros:: attributed_string_type:: Error ,
5856 } ,
5957}
6058
@@ -63,7 +61,7 @@ type Result<T, E = Error> = std::result::Result<T, E>;
6361/// Validated [`ContainerLogConfigChoice`]
6462///
6563/// The ConfigMap name in the Custom variant is valid.
66- #[ derive( Clone , Debug , PartialEq ) ]
64+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
6765pub enum ValidatedContainerLogConfigChoice {
6866 Automatic ( AutomaticContainerLogConfig ) ,
6967 Custom ( ConfigMapName ) ,
@@ -72,7 +70,7 @@ pub enum ValidatedContainerLogConfigChoice {
7270/// Validated [`ContainerLogConfigChoice`] for the Vector container
7371///
7472/// It includes the discovery ConfigMap name of the Vector aggregator.
75- #[ derive( Clone , Debug , PartialEq ) ]
73+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
7674pub struct VectorContainerLogConfig {
7775 pub log_config : ValidatedContainerLogConfigChoice ,
7876 pub vector_aggregator_config_map_name : ConfigMapName ,
@@ -81,14 +79,14 @@ pub struct VectorContainerLogConfig {
8179/// Validates the log configuration of the container
8280pub fn validate_logging_configuration_for_container < T > (
8381 logging : & Logging < T > ,
84- container : T ,
82+ container : & T ,
8583) -> Result < ValidatedContainerLogConfigChoice >
8684where
8785 T : Clone + Display + Ord ,
8886{
8987 let container_log_config_choice = logging
9088 . containers
91- . get ( & container)
89+ . get ( container)
9290 . and_then ( |container_log_config| container_log_config. choice . as_ref ( ) )
9391 // This should never happen because default configurations should have been set for all
9492 // containers.
@@ -111,6 +109,7 @@ where
111109}
112110
113111/// Builds the Vector container
112+ #[ expect( clippy:: too_many_lines) ]
114113pub fn vector_container (
115114 container_name : & ContainerName ,
116115 image : & ResolvedProductImage ,
@@ -152,7 +151,7 @@ pub fn vector_container(
152151 . with_value ( & EnvVarName :: from_str_unsafe ( "LOG_DIR" ) , STACKABLE_LOG_DIR )
153152 . with_field_path (
154153 & EnvVarName :: from_str_unsafe ( "NAMESPACE" ) ,
155- FieldPathEnvVar :: Namespace ,
154+ & FieldPathEnvVar :: Namespace ,
156155 )
157156 . with_value (
158157 & EnvVarName :: from_str_unsafe ( "ROLE_GROUP_NAME" ) ,
@@ -235,27 +234,26 @@ pub fn vector_container(
235234mod tests {
236235 use std:: str:: FromStr ;
237236
238- use pretty_assertions:: assert_eq;
239237 use serde_json:: json;
240- use stackable_operator:: {
238+
239+ use super :: {
240+ ErrorDiscriminants , ValidatedContainerLogConfigChoice , VectorContainerLogConfig ,
241+ validate_logging_configuration_for_container, vector_container,
242+ } ;
243+ use crate :: {
241244 commons:: product_image_selection:: ResolvedProductImage ,
242245 kvp:: LabelValue ,
243246 product_logging:: spec:: {
244247 AutomaticContainerLogConfig , ConfigMapLogConfig , ContainerLogConfig ,
245248 ContainerLogConfigChoice , CustomContainerLogConfig , Logging ,
246249 } ,
247- } ;
248-
249- use super :: {
250- ErrorDiscriminants , ValidatedContainerLogConfigChoice , VectorContainerLogConfig ,
251- validate_logging_configuration_for_container, vector_container,
252- } ;
253- use crate :: framework:: {
254- builder:: pod:: container:: { EnvVarName , EnvVarSet } ,
255- role_group_utils,
256- types:: {
257- kubernetes:: { ConfigMapName , ContainerName , VolumeName } ,
258- operator:: { ClusterName , RoleGroupName , RoleName } ,
250+ v2:: {
251+ builder:: pod:: container:: { EnvVarName , EnvVarSet } ,
252+ role_group_utils,
253+ types:: {
254+ kubernetes:: { ConfigMapName , ContainerName , VolumeName } ,
255+ operator:: { ClusterName , RoleGroupName , RoleName } ,
256+ } ,
259257 } ,
260258 } ;
261259
@@ -276,7 +274,7 @@ mod tests {
276274
277275 assert_eq ! (
278276 ValidatedContainerLogConfigChoice :: Automatic ( AutomaticContainerLogConfig :: default ( ) ) ,
279- validate_logging_configuration_for_container( & logging, "container" )
277+ validate_logging_configuration_for_container( & logging, & "container" )
280278 . expect( "should be a valid log config" )
281279 ) ;
282280 }
@@ -302,7 +300,7 @@ mod tests {
302300 ValidatedContainerLogConfigChoice :: Custom ( ConfigMapName :: from_str_unsafe(
303301 "valid-config-map-name"
304302 ) ) ,
305- validate_logging_configuration_for_container( & logging, "container" )
303+ validate_logging_configuration_for_container( & logging, & "container" )
306304 . expect( "should be a valid log config" )
307305 ) ;
308306 }
@@ -320,15 +318,15 @@ mod tests {
320318
321319 assert_eq ! (
322320 Err ( ErrorDiscriminants :: GetContainerLogConfiguration ) ,
323- validate_logging_configuration_for_container( & logging_without_container, "container" )
321+ validate_logging_configuration_for_container( & logging_without_container, & "container" )
324322 . map_err( ErrorDiscriminants :: from)
325323 ) ;
326324
327325 assert_eq ! (
328326 Err ( ErrorDiscriminants :: GetContainerLogConfiguration ) ,
329327 validate_logging_configuration_for_container(
330328 & logging_without_container_log_config_choice,
331- "container"
329+ & "container"
332330 )
333331 . map_err( ErrorDiscriminants :: from)
334332 ) ;
@@ -353,12 +351,13 @@ mod tests {
353351
354352 assert_eq ! (
355353 Err ( ErrorDiscriminants :: ParseContainerName ) ,
356- validate_logging_configuration_for_container( & logging, "container" )
354+ validate_logging_configuration_for_container( & logging, & "container" )
357355 . map_err( ErrorDiscriminants :: from)
358356 ) ;
359357 }
360358
361359 #[ test]
360+ #[ expect( clippy:: too_many_lines) ]
362361 fn test_vector_container ( ) {
363362 let image = ResolvedProductImage {
364363 product_version : "1.0.0" . to_owned ( ) ,
0 commit comments