@@ -243,25 +243,27 @@ func (r *SingleInstanceDatabase) ValidateCreate() error {
243243 field .Invalid (field .NewPath ("spec" ).Child ("listenerPort" ), r .Spec .ListenerPort ,
244244 "listenerPort should be in 30000-32767 range." ))
245245 }
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 ) {
247247 allErrs = append (allErrs ,
248248 field .Invalid (field .NewPath ("spec" ).Child ("tcpsListenerPort" ), r .Spec .TcpsListenerPort ,
249249 "tcpsListenerPort should be in 30000-32767 range." ))
250250 }
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+ }
251258 }
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 {
253260 allErrs = append (allErrs ,
254261 field .Invalid (field .NewPath ("spec" ).Child ("tcpsListenerPort" ), r .Spec .TcpsListenerPort ,
255262 "listenerPort and tcpsListenerPort can not be equal." ))
256263 }
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- }
262264
263265 // Certificate Renew Duration Validation
264- if r .Spec .TcpsCertRenewInterval != "" {
266+ if r .Spec .EnableTCPS && r . Spec . TcpsCertRenewInterval != "" {
265267 duration , err := time .ParseDuration (r .Spec .TcpsCertRenewInterval )
266268 if err != nil {
267269 allErrs = append (allErrs ,
0 commit comments