Skip to content

Commit a88d923

Browse files
committed
Add tools code-server
1 parent 490c5bb commit a88d923

File tree

7 files changed

+528
-27
lines changed

7 files changed

+528
-27
lines changed

cmd/options.go

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,37 @@ func GetOptions() *Options {
9999
Port: defaultVxlanPort,
100100
DeletionPrefix: "vx-",
101101
},
102+
ToolsCodeServer: &ToolsCodeServerOptions{
103+
Image: "ghcr.io/kaelemc/clab-code-server:latest",
104+
Name: "clab-code-server",
105+
Host: "localhost",
106+
LogLevel: "debug",
107+
OutputFormat: "table",
108+
},
102109
}
103110
}
104111

105112
return optionsInstance
106113
}
107114

108115
type Options struct {
109-
Global *GlobalOptions
110-
Filter *FilterOptions
111-
Deploy *DeployOptions
112-
Destroy *DestroyOptions
113-
Config *ConfigOptions
114-
Exec *ExecOptions
115-
Inspect *InspectOptions
116-
Graph *GraphOptions
117-
ToolsAPI *ToolsApiOptions
118-
ToolsCert *ToolsCertOptions
119-
ToolsTxOffload *ToolsDisableTxOffloadOptions
120-
ToolsGoTTY *ToolsGoTTYOptions
121-
ToolsNetem *ToolsNetemOptions
122-
ToolsSSHX *ToolsSSHXOptions
123-
ToolsVeth *ToolsVethOptions
124-
ToolsVxlan *ToolsVxlanOptions
116+
Global *GlobalOptions
117+
Filter *FilterOptions
118+
Deploy *DeployOptions
119+
Destroy *DestroyOptions
120+
Config *ConfigOptions
121+
Exec *ExecOptions
122+
Inspect *InspectOptions
123+
Graph *GraphOptions
124+
ToolsAPI *ToolsApiOptions
125+
ToolsCert *ToolsCertOptions
126+
ToolsTxOffload *ToolsDisableTxOffloadOptions
127+
ToolsGoTTY *ToolsGoTTYOptions
128+
ToolsNetem *ToolsNetemOptions
129+
ToolsSSHX *ToolsSSHXOptions
130+
ToolsVeth *ToolsVethOptions
131+
ToolsVxlan *ToolsVxlanOptions
132+
ToolsCodeServer *ToolsCodeServerOptions
125133
}
126134

127135
func (o *Options) ToClabOptions() []clabcore.ClabOption {
@@ -415,3 +423,14 @@ type ToolsVxlanOptions struct {
415423
ParentDevice string
416424
DeletionPrefix string
417425
}
426+
427+
type ToolsCodeServerOptions struct {
428+
Image string
429+
Name string
430+
Port uint
431+
Host string
432+
LogLevel string
433+
OutputFormat string
434+
LabsDirectory string
435+
Owner string
436+
}

cmd/tools.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package cmd
66

77
import (
8+
"os"
89
"path/filepath"
910
"strings"
1011

@@ -22,6 +23,7 @@ func toolsSubcommandRegisterFuncs() []func(*Options) (*cobra.Command, error) {
2223
sshxCmd,
2324
vethCmd,
2425
vxlanCmd,
26+
codeServerCmd,
2527
}
2628
}
2729

@@ -81,3 +83,17 @@ func createLabelsMap(topo, labName, containerName, owner, toolType string) map[s
8183

8284
return labels
8385
}
86+
87+
// getclabBinaryPath determine the binary path of the running executable.
88+
func getclabBinaryPath() (string, error) {
89+
exePath, err := os.Executable()
90+
if err != nil {
91+
return "", err
92+
}
93+
94+
absPath, err := filepath.EvalSymlinks(exePath)
95+
if err != nil {
96+
return "", err
97+
}
98+
return absPath, nil
99+
}

cmd/tools_api_start.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package cmd
77
import (
88
"fmt"
99
"os"
10-
"path/filepath"
1110

1211
"github.com/charmbracelet/log"
1312
"github.com/spf13/cobra"
@@ -93,16 +92,6 @@ func (*APIServerNode) GetEndpoints() []clablinks.Endpoint {
9392
return nil
9493
}
9594

96-
// getclabBinaryPath determine the binary path of the running executable.
97-
func getclabBinaryPath() (string, error) {
98-
exePath, err := os.Executable()
99-
if err != nil {
100-
return "", err
101-
}
102-
103-
return filepath.EvalSymlinks(exePath)
104-
}
105-
10695
// createLabels creates container labels.
10796
func createAPIServerLabels(
10897
containerName,

0 commit comments

Comments
 (0)