@@ -29,12 +29,12 @@ import (
29
29
)
30
30
31
31
var (
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"
38
38
// DefaultMaxUnavailable is the default max unavailable nodes during a rollout
39
39
DefaultMaxUnavailable int32 = 1
40
40
)
@@ -59,16 +59,28 @@ func (r *CrdbCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
59
59
func (r * CrdbCluster ) Default () {
60
60
webhookLog .Info ("default" , "name" , r .Name )
61
61
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
64
68
}
65
69
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
68
76
}
69
77
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
72
84
}
73
85
74
86
if r .Spec .MaxUnavailable == nil && r .Spec .MinAvailable == nil {
0 commit comments