22
33import io .kafbat .ui .model .MetricsConfig ;
44import jakarta .annotation .PostConstruct ;
5+ import jakarta .validation .Valid ;
6+ import jakarta .validation .constraints .NotBlank ;
7+ import jakarta .validation .constraints .NotNull ;
58import java .util .ArrayList ;
69import java .util .HashMap ;
710import java .util .HashSet ;
1720import org .springframework .boot .context .properties .ConfigurationProperties ;
1821import org .springframework .context .annotation .Configuration ;
1922import org .springframework .util .StringUtils ;
23+ import org .springframework .validation .annotation .Validated ;
2024
2125@ Configuration
2226@ ConfigurationProperties ("kafka" )
2327@ Data
28+ @ Validated
2429public class ClustersProperties {
2530
26- List <Cluster > clusters = new ArrayList <>();
31+ List <@ Valid Cluster > clusters = new ArrayList <>();
2732
2833 String internalTopicPrefix ;
2934
@@ -33,7 +38,9 @@ public class ClustersProperties {
3338
3439 @ Data
3540 public static class Cluster {
41+ @ NotBlank (message = "field name for for cluster could not be blank" )
3642 String name ;
43+ @ NotBlank (message = "field bootstrapServers for for cluster could not be blank" )
3744 String bootstrapServers ;
3845
3946 TruststoreConfig ssl ;
@@ -46,9 +53,9 @@ public static class Cluster {
4653 KsqldbServerAuth ksqldbServerAuth ;
4754 KeystoreConfig ksqldbServerSsl ;
4855
49- List <ConnectCluster > kafkaConnect ;
56+ List <@ Valid ConnectCluster > kafkaConnect ;
5057
51- List <SerdeConfig > serde ;
58+ List <@ Valid SerdeConfig > serde ;
5259 String defaultKeySerde ;
5360 String defaultValueSerde ;
5461
@@ -58,7 +65,7 @@ public static class Cluster {
5865
5966 Long pollingThrottleRate ;
6067
61- List <Masking > masking ;
68+ List <@ Valid Masking > masking ;
6269
6370 AuditProperties audit ;
6471 }
@@ -88,7 +95,9 @@ public static class MetricsConfigData {
8895 @ Builder (toBuilder = true )
8996 @ ToString (exclude = {"password" , "keystorePassword" })
9097 public static class ConnectCluster {
98+ @ NotBlank
9199 String name ;
100+ @ NotBlank
92101 String address ;
93102 String username ;
94103 String password ;
@@ -122,6 +131,7 @@ public static class KeystoreConfig {
122131
123132 @ Data
124133 public static class SerdeConfig {
134+ @ NotBlank
125135 String name ;
126136 String className ;
127137 String filePath ;
@@ -139,6 +149,7 @@ public static class KsqldbServerAuth {
139149
140150 @ Data
141151 public static class Masking {
152+ @ NotNull
142153 Type type ;
143154 List <String > fields ;
144155 String fieldsNamePattern ;
@@ -160,7 +171,7 @@ public static class AuditProperties {
160171 Integer auditTopicsPartitions ;
161172 Boolean topicAuditEnabled ;
162173 Boolean consoleAuditEnabled ;
163- LogLevel level ;
174+ LogLevel level = LogLevel . ALTER_ONLY ;
164175 Map <String , String > auditTopicProperties ;
165176
166177 public enum LogLevel {
0 commit comments