2
2
3
3
import io .kafbat .ui .model .MetricsConfig ;
4
4
import jakarta .annotation .PostConstruct ;
5
+ import jakarta .validation .Valid ;
6
+ import jakarta .validation .constraints .NotBlank ;
7
+ import jakarta .validation .constraints .NotNull ;
5
8
import java .util .ArrayList ;
6
9
import java .util .HashMap ;
7
10
import java .util .HashSet ;
17
20
import org .springframework .boot .context .properties .ConfigurationProperties ;
18
21
import org .springframework .context .annotation .Configuration ;
19
22
import org .springframework .util .StringUtils ;
23
+ import org .springframework .validation .annotation .Validated ;
20
24
21
25
@ Configuration
22
26
@ ConfigurationProperties ("kafka" )
23
27
@ Data
28
+ @ Validated
24
29
public class ClustersProperties {
25
30
26
- List <Cluster > clusters = new ArrayList <>();
31
+ List <@ Valid Cluster > clusters = new ArrayList <>();
27
32
28
33
String internalTopicPrefix ;
29
34
@@ -33,7 +38,9 @@ public class ClustersProperties {
33
38
34
39
@ Data
35
40
public static class Cluster {
41
+ @ NotBlank (message = "field name for for cluster could not be blank" )
36
42
String name ;
43
+ @ NotBlank (message = "field bootstrapServers for for cluster could not be blank" )
37
44
String bootstrapServers ;
38
45
39
46
TruststoreConfig ssl ;
@@ -46,9 +53,9 @@ public static class Cluster {
46
53
KsqldbServerAuth ksqldbServerAuth ;
47
54
KeystoreConfig ksqldbServerSsl ;
48
55
49
- List <ConnectCluster > kafkaConnect ;
56
+ List <@ Valid ConnectCluster > kafkaConnect ;
50
57
51
- List <SerdeConfig > serde ;
58
+ List <@ Valid SerdeConfig > serde ;
52
59
String defaultKeySerde ;
53
60
String defaultValueSerde ;
54
61
@@ -58,7 +65,7 @@ public static class Cluster {
58
65
59
66
Long pollingThrottleRate ;
60
67
61
- List <Masking > masking ;
68
+ List <@ Valid Masking > masking ;
62
69
63
70
AuditProperties audit ;
64
71
}
@@ -88,7 +95,9 @@ public static class MetricsConfigData {
88
95
@ Builder (toBuilder = true )
89
96
@ ToString (exclude = {"password" , "keystorePassword" })
90
97
public static class ConnectCluster {
98
+ @ NotBlank
91
99
String name ;
100
+ @ NotBlank
92
101
String address ;
93
102
String username ;
94
103
String password ;
@@ -122,6 +131,7 @@ public static class KeystoreConfig {
122
131
123
132
@ Data
124
133
public static class SerdeConfig {
134
+ @ NotBlank
125
135
String name ;
126
136
String className ;
127
137
String filePath ;
@@ -139,6 +149,7 @@ public static class KsqldbServerAuth {
139
149
140
150
@ Data
141
151
public static class Masking {
152
+ @ NotNull
142
153
Type type ;
143
154
List <String > fields ;
144
155
String fieldsNamePattern ;
@@ -160,7 +171,7 @@ public static class AuditProperties {
160
171
Integer auditTopicsPartitions ;
161
172
Boolean topicAuditEnabled ;
162
173
Boolean consoleAuditEnabled ;
163
- LogLevel level ;
174
+ LogLevel level = LogLevel . ALTER_ONLY ;
164
175
Map <String , String > auditTopicProperties ;
165
176
166
177
public enum LogLevel {
0 commit comments