Skip to content

Commit 02baa43

Browse files
committed
Display host port in inspect
1 parent 4ad8921 commit 02baa43

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

cmd/tools_code_server.go

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"fmt"
1010
"os"
11-
"strconv"
1211
"strings"
1312

1413
"github.com/charmbracelet/log"
@@ -96,8 +95,8 @@ func NewCodeServerNode(name, image, labsDir string, port uint, runtime clabrunti
9695
}
9796

9897
binds := clabtypes.Binds{
99-
clabtypes.NewBind(homeDir, "/home/coder/labs", ""),
100-
clabtypes.NewBind("/etc/group", "/etc/group", "ro"),
98+
clabtypes.NewBind(homeDir, "/labs", ""),
99+
// clabtypes.NewBind("/etc/group", "/etc/group", "ro"),
101100
}
102101

103102
// get the runtime socket path
@@ -173,13 +172,11 @@ func (*codeServerNode) GetEndpoints() []clablinks.Endpoint {
173172
// createLabels creates container labels.
174173
func createCodeServerLabels(containerName, owner string, port uint, labsDir, host string) map[string]string {
175174
labels := map[string]string{
176-
clablabels.NodeName: containerName,
177-
clablabels.NodeKind: "linux",
178-
clablabels.NodeType: "tool",
179-
clablabels.ToolType: "code-server",
180-
"clab-code-server-host": host,
181-
"clab-code-server-port": fmt.Sprintf("%d", port),
182-
"clab-labs-dir": labsDir,
175+
clablabels.NodeName: containerName,
176+
clablabels.NodeKind: "linux",
177+
clablabels.NodeType: "tool",
178+
clablabels.ToolType: "code-server",
179+
"clab-labs-dir": labsDir,
183180
}
184181

185182
// Add owner label if available
@@ -315,7 +312,7 @@ func codeServerStatus(cobraCmd *cobra.Command, o *Options) error { //nolint: fun
315312
&clabruntime.RuntimeConfig{
316313
Debug: o.Global.DebugCount > 0,
317314
Timeout: o.Global.Timeout,
318-
GracefulShutdown: o.Destroy.GracefulShutdown,
315+
GracefulShutdown: o.Global.GracefulShutdown,
319316
},
320317
),
321318
clabcore.WithDebug(o.Global.DebugCount > 0),
@@ -352,18 +349,7 @@ func codeServerStatus(cobraCmd *cobra.Command, o *Options) error { //nolint: fun
352349
name := strings.TrimPrefix(containers[idx].Names[0], "/")
353350

354351
// Get port from labels or use default
355-
port := 8080 // default
356-
if portStr, ok := containers[idx].Labels["code-server-port"]; ok {
357-
if portVal, err := strconv.Atoi(portStr); err == nil {
358-
port = portVal
359-
}
360-
}
361-
362-
// Get host from labels or use default
363-
host := "localhost" // default
364-
if hostVal, ok := containers[idx].Labels["code-server-host"]; ok {
365-
host = hostVal
366-
}
352+
port := containers[idx].Ports[0].HostPort
367353

368354
// Get labs dir from labels or use default
369355
labsDir := "~/.clab" // default
@@ -380,7 +366,6 @@ func codeServerStatus(cobraCmd *cobra.Command, o *Options) error { //nolint: fun
380366
listItems = append(listItems, codeServerListItem{
381367
Name: name,
382368
State: containers[idx].State,
383-
Host: host,
384369
Port: port,
385370
LabsDir: labsDir,
386371
Owner: owner,
@@ -401,13 +386,12 @@ func codeServerStatus(cobraCmd *cobra.Command, o *Options) error { //nolint: fun
401386
t.Style().Format.Header = text.FormatTitle
402387
t.Style().Options.SeparateRows = true
403388

404-
t.AppendHeader(table.Row{"NAME", "STATUS", "HOST", "PORT", "LABS DIR", "OWNER"})
389+
t.AppendHeader(table.Row{"NAME", "STATUS", "PORT", "LABS DIR", "OWNER"})
405390

406391
for _, item := range listItems {
407392
t.AppendRow(table.Row{
408393
item.Name,
409394
item.State,
410-
item.Host,
411395
item.Port,
412396
item.LabsDir,
413397
item.Owner,

0 commit comments

Comments
 (0)