@@ -35,7 +35,7 @@ var parameterRe = regexp.MustCompile(`{[^{}]*}`)
35
35
var pgURLRe = regexp .MustCompile (`{pgurl(:[-,0-9]+|:(?i)lb)?(:[a-z0-9\-]+)?(:[0-9]+)?}` )
36
36
var pgHostRe = regexp .MustCompile (`{pghost(:[-,0-9]+|:(?i)lb)?(:[a-z0-9\-]+)?(:[0-9]+)?}` )
37
37
var pgPortRe = regexp .MustCompile (`{pgport(:[-,0-9]+)?(:[a-z0-9\-]+)?(:[0-9]+)?}` )
38
- var uiPortRe = regexp .MustCompile (`{uiport(:[-,0-9]+)}` )
38
+ var uiPortRe = regexp .MustCompile (`{uiport(:[-,0-9]+)?(:[a-z0-9\-]+)?(:[0-9]+)? }` )
39
39
var ipAddressRe = regexp .MustCompile (`{ip(:\d+([-,]\d+)?)(:public|:private)?}` )
40
40
var hostnameRe = regexp .MustCompile (`{hostname(:\d+([-,]\d+)?)}` )
41
41
var storeDirRe = regexp .MustCompile (`{store-dir(:[0-9]+)?}` )
@@ -54,8 +54,8 @@ type expander struct {
54
54
55
55
pgURLs map [string ]map [Node ]string
56
56
pgHosts map [Node ]string
57
- pgPorts map [Node ]string
58
- uiPorts map [Node ]string
57
+ pgPorts map [string ] map [ Node ]string
58
+ uiPorts map [string ] map [ Node ]string
59
59
publicIPs map [Node ]string
60
60
privateIPs map [Node ]string
61
61
hostnames map [Node ]string
@@ -246,40 +246,54 @@ func (e *expander) maybeExpandPgPort(
246
246
if err != nil {
247
247
return "" , false , err
248
248
}
249
-
250
249
if e .pgPorts == nil {
251
- e .pgPorts = make (map [Node ]string , len (c .VMs ))
250
+ e .pgPorts = make (map [string ]map [Node ]string )
251
+ }
252
+
253
+ if e .pgPorts [virtualClusterName ] == nil {
254
+ e .pgPorts [virtualClusterName ] = make (map [Node ]string )
252
255
for _ , node := range allNodes (len (c .VMs )) {
253
256
desc , err := c .ServiceDescriptor (ctx , node , virtualClusterName , ServiceTypeSQL , sqlInstance )
254
257
if err != nil {
255
258
return s , false , err
256
259
}
257
- e .pgPorts [node ] = fmt .Sprint (desc .Port )
260
+ e.pgPorts [virtualClusterName ][ node ] = fmt .Sprint (desc .Port )
258
261
}
259
262
}
260
263
261
- s , err = e .maybeExpandMap (c , e .pgPorts , m [1 ])
264
+ s , err = e .maybeExpandMap (c , e .pgPorts [ virtualClusterName ] , m [1 ])
262
265
return s , err == nil , err
263
266
}
264
267
265
268
// maybeExpandPgURL is an expanderFunc for {uiport:<nodeSpec>}
266
269
func (e * expander ) maybeExpandUIPort (
267
- ctx context.Context , l * logger.Logger , c * SyncedCluster , _ ExpanderConfig , s string ,
270
+ ctx context.Context , l * logger.Logger , c * SyncedCluster , cfg ExpanderConfig , s string ,
268
271
) (string , bool , error ) {
269
272
m := uiPortRe .FindStringSubmatch (s )
270
273
if m == nil {
271
274
return s , false , nil
272
275
}
276
+ virtualClusterName , sqlInstance , err := extractVirtualClusterInfo (m [2 :], cfg .DefaultVirtualCluster )
277
+ if err != nil {
278
+ return "" , false , err
279
+ }
273
280
274
281
if e .uiPorts == nil {
275
- e .uiPorts = make (map [Node ]string , len (c .VMs ))
282
+ e .uiPorts = make (map [string ]map [Node ]string )
283
+ }
284
+
285
+ if e .uiPorts [virtualClusterName ] == nil {
286
+ e .uiPorts [virtualClusterName ] = make (map [Node ]string )
276
287
for _ , node := range allNodes (len (c .VMs )) {
277
- // TODO(herko): Add support for separate-process services.
278
- e .uiPorts [node ] = fmt .Sprint (c .NodeUIPort (ctx , node , "" /* virtualClusterName */ , 0 /* sqlInstance */ ))
288
+ desc , err := c .ServiceDescriptor (ctx , node , virtualClusterName , ServiceTypeUI , sqlInstance )
289
+ if err != nil {
290
+ return s , false , err
291
+ }
292
+ e.uiPorts [virtualClusterName ][node ] = fmt .Sprint (desc .Port )
279
293
}
280
294
}
281
295
282
- s , err : = e .maybeExpandMap (c , e .uiPorts , m [1 ])
296
+ s , err = e .maybeExpandMap (c , e .uiPorts [ virtualClusterName ] , m [1 ])
283
297
return s , err == nil , err
284
298
}
285
299
0 commit comments