@@ -29,12 +29,12 @@ import (
2929)
3030
3131var (
32- // DefaultGRPCPort is the default port used for GRPC communication
33- DefaultGRPCPort int32 = 26258
34- // DefaultSQLPort is the default port used for SQL connections
35- DefaultSQLPort int32 = 26257
36- // DefaultHTTPPort is the default port for the Web UI
37- DefaultHTTPPort int32 = 8080
32+ // DefaultGRPCAddr is the default grpc address used for GRPC communication
33+ DefaultGRPCAddr string = ": 26258"
34+ // DefaultSQLAddr is the default sql address used for SQL connections
35+ DefaultSQLAddr string = ": 26257"
36+ // DefaultHTTPAddr is the default http address for the Web UI
37+ DefaultHTTPAddr string = ": 8080"
3838 // DefaultMaxUnavailable is the default max unavailable nodes during a rollout
3939 DefaultMaxUnavailable int32 = 1
4040)
@@ -59,16 +59,28 @@ func (r *CrdbCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
5959func (r * CrdbCluster ) Default () {
6060 webhookLog .Info ("default" , "name" , r .Name )
6161
62- if r .Spec .GRPCPort == nil {
63- r .Spec .GRPCPort = & DefaultGRPCPort
62+ if r .Spec .GRPCPort == nil && r .Spec .ListenAddr == nil {
63+ r .Spec .ListenAddr = & DefaultGRPCAddr
64+ } else if r .Spec .GRPCPort != nil && r .Spec .ListenAddr == nil {
65+ listenAddr := fmt .Sprintf (":%d" , * r .Spec .GRPCPort )
66+ r .Spec .ListenAddr = & listenAddr
67+ r .Spec .GRPCPort = nil
6468 }
6569
66- if r .Spec .SQLPort == nil {
67- r .Spec .SQLPort = & DefaultSQLPort
70+ if r .Spec .SQLPort == nil && r .Spec .SQLAddr == nil {
71+ r .Spec .SQLAddr = & DefaultSQLAddr
72+ } else if r .Spec .SQLPort != nil && r .Spec .SQLAddr == nil {
73+ sqlAddr := fmt .Sprintf (":%d" , * r .Spec .SQLPort )
74+ r .Spec .SQLAddr = & sqlAddr
75+ r .Spec .SQLPort = nil
6876 }
6977
70- if r .Spec .HTTPPort == nil {
71- r .Spec .HTTPPort = & DefaultHTTPPort
78+ if r .Spec .HTTPPort == nil && r .Spec .HTTPAddr == nil {
79+ r .Spec .HTTPAddr = & DefaultHTTPAddr
80+ } else if r .Spec .HTTPPort != nil && r .Spec .HTTPAddr == nil {
81+ httpAddr := fmt .Sprintf (":%d" , * r .Spec .HTTPPort )
82+ r .Spec .HTTPAddr = & httpAddr
83+ r .Spec .HTTPPort = nil
7284 }
7385
7486 if r .Spec .MaxUnavailable == nil && r .Spec .MinAvailable == nil {
0 commit comments