Skip to content

Commit 845e5d9

Browse files
committed
Drop ID from RemoteCVDLocator, and use group and instance name
1 parent d68dfb7 commit 845e5d9

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

pkg/cli/cli.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ func hostOutput(h *RemoteHost) string {
335335

336336
func cvdOutput(h *RemoteHost, c *RemoteCVD) []string {
337337
return []string{
338-
c.ID,
338+
fmt.Sprintf("%s/%s", c.Group, c.Name),
339339
"Status: " + c.Status,
340340
"ADB: " + adbStateStr(c),
341341
"Displays: " + fmt.Sprintf("%v", c.Displays),
342-
"Logs: " + fmt.Sprintf("%s/cvds/%s/logs/", h.ServiceURL, c.ID),
342+
"Logs: " + fmt.Sprintf("%s/cvds/%s/%s/logs/", h.ServiceURL, c.Group, c.Name),
343343
}
344344
}
345345

@@ -1190,7 +1190,7 @@ func promptSingleGroupNameSelection(c *command, srvClient client.Client, control
11901190
cvds := flattenCVDs(hosts)
11911191
names := []string{}
11921192
for _, e := range cvds {
1193-
names = append(names, e.Group())
1193+
names = append(names, e.Group)
11941194
}
11951195
sel, err := PromptSelectionFromSliceString(c, names, Single)
11961196
if err != nil {

pkg/cli/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func NewConnController(
377377
if err != nil {
378378
return nil, err
379379
}
380-
logger.Printf("Connecting to %s in host %s", cvd.ID, cvd.Host)
380+
logger.Printf("Connecting to instance %s of group %s in host %s", cvd.Name, cvd.Group, cvd.Host)
381381
f, err := NewForwarder(logger)
382382
if err != nil {
383383
return nil, fmt.Errorf("failed to instantiate ADB forwarder for %q: %w", cvd.WebRTCDeviceID, err)

pkg/cli/cvd.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,14 @@ import (
3838
)
3939

4040
type RemoteCVDLocator struct {
41-
Host string `json:"host"`
42-
// Identifier within the whole fleet.
43-
ID string `json:"id"`
41+
Host string `json:"host"`
42+
Group string `json:"group"`
43+
Name string `json:"name"`
4444
// `WebRTCDeviceID` is the identifier used for setting up the adb connections. It
4545
// contains the group name and the device name, eg: "cvd-1_1".
4646
WebRTCDeviceID string `json:"webrtc_device_id"`
4747
}
4848

49-
func (l *RemoteCVDLocator) Group() string {
50-
return strings.Split(l.ID, "/")[0]
51-
}
52-
5349
type RemoteCVD struct {
5450
RemoteCVDLocator
5551
Status string
@@ -67,7 +63,8 @@ func NewRemoteCVD(host string, cvd *hoapi.CVD) *RemoteCVD {
6763
return &RemoteCVD{
6864
RemoteCVDLocator: RemoteCVDLocator{
6965
Host: host,
70-
ID: cvd.ID(),
66+
Group: cvd.Group,
67+
Name: cvd.Name,
7168
WebRTCDeviceID: cvd.WebRTCDeviceID,
7269
},
7370
Status: cvd.Status,

0 commit comments

Comments
 (0)