@@ -243,25 +243,27 @@ func (r *SingleInstanceDatabase) ValidateCreate() error {
243
243
field .Invalid (field .NewPath ("spec" ).Child ("listenerPort" ), r .Spec .ListenerPort ,
244
244
"listenerPort should be in 30000-32767 range." ))
245
245
}
246
- if r .Spec .TcpsListenerPort != 0 && (r .Spec .TcpsListenerPort < 30000 || r .Spec .TcpsListenerPort > 32767 ) {
246
+ if r .Spec .EnableTCPS && r . Spec . TcpsListenerPort != 0 && (r .Spec .TcpsListenerPort < 30000 || r .Spec .TcpsListenerPort > 32767 ) {
247
247
allErrs = append (allErrs ,
248
248
field .Invalid (field .NewPath ("spec" ).Child ("tcpsListenerPort" ), r .Spec .TcpsListenerPort ,
249
249
"tcpsListenerPort should be in 30000-32767 range." ))
250
250
}
251
+ } else {
252
+ // LoadBalancer Service is expected.
253
+ if r .Spec .EnableTCPS && r .Spec .TcpsListenerPort == 0 && r .Spec .ListenerPort == 1522 {
254
+ allErrs = append (allErrs ,
255
+ field .Invalid (field .NewPath ("spec" ).Child ("listenerPort" ), r .Spec .ListenerPort ,
256
+ "listenerPort can not be 1522 as the default port for tcpsListenerPort is 1522." ))
257
+ }
251
258
}
252
- if r .Spec .ListenerPort != 0 && r .Spec .TcpsListenerPort != 0 && r .Spec .ListenerPort == r .Spec .TcpsListenerPort {
259
+ if r .Spec .EnableTCPS && r . Spec . ListenerPort != 0 && r .Spec .TcpsListenerPort != 0 && r .Spec .ListenerPort == r .Spec .TcpsListenerPort {
253
260
allErrs = append (allErrs ,
254
261
field .Invalid (field .NewPath ("spec" ).Child ("tcpsListenerPort" ), r .Spec .TcpsListenerPort ,
255
262
"listenerPort and tcpsListenerPort can not be equal." ))
256
263
}
257
- if r .Spec .EnableTCPS && r .Spec .TcpsListenerPort == 0 && r .Spec .ListenerPort == 1522 {
258
- allErrs = append (allErrs ,
259
- field .Invalid (field .NewPath ("spec" ).Child ("listenerPort" ), r .Spec .ListenerPort ,
260
- "listenerPort can not be 1522 as the default port for tcpsListenerPort is 1522." ))
261
- }
262
264
263
265
// Certificate Renew Duration Validation
264
- if r .Spec .TcpsCertRenewInterval != "" {
266
+ if r .Spec .EnableTCPS && r . Spec . TcpsCertRenewInterval != "" {
265
267
duration , err := time .ParseDuration (r .Spec .TcpsCertRenewInterval )
266
268
if err != nil {
267
269
allErrs = append (allErrs ,
0 commit comments