Skip to content

Commit 77e1436

Browse files
committed
Add tools code-server
1 parent bf119d6 commit 77e1436

File tree

7 files changed

+528
-31
lines changed

7 files changed

+528
-31
lines changed

cmd/options.go

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,37 @@ func GetOptions() *Options {
8989
Port: 14789,
9090
DeletionPrefix: "vx-",
9191
},
92+
ToolsCodeServer: &ToolsCodeServerOptions{
93+
Image: "ghcr.io/kaelemc/clab-code-server:latest",
94+
Name: "clab-code-server",
95+
Host: "localhost",
96+
LogLevel: "debug",
97+
OutputFormat: "table",
98+
},
9299
}
93100
}
94101

95102
return optionsInstance
96103
}
97104

98105
type Options struct {
99-
Global *GlobalOptions
100-
Filter *FilterOptions
101-
Deploy *DeployOptions
102-
Destroy *DestroyOptions
103-
Config *ConfigOptions
104-
Exec *ExecOptions
105-
Inspect *InspectOptions
106-
Graph *GraphOptions
107-
ToolsAPI *ToolsApiOptions
108-
ToolsCert *ToolsCertOptions
109-
ToolsTxOffload *ToolsDisableTxOffloadOptions
110-
ToolsGoTTY *ToolsGoTTYOptions
111-
ToolsNetem *ToolsNetemOptions
112-
ToolsSSHX *ToolsSSHXOptions
113-
ToolsVeth *ToolsVethOptions
114-
ToolsVxlan *ToolsVxlanOptions
106+
Global *GlobalOptions
107+
Filter *FilterOptions
108+
Deploy *DeployOptions
109+
Destroy *DestroyOptions
110+
Config *ConfigOptions
111+
Exec *ExecOptions
112+
Inspect *InspectOptions
113+
Graph *GraphOptions
114+
ToolsAPI *ToolsApiOptions
115+
ToolsCert *ToolsCertOptions
116+
ToolsTxOffload *ToolsDisableTxOffloadOptions
117+
ToolsGoTTY *ToolsGoTTYOptions
118+
ToolsNetem *ToolsNetemOptions
119+
ToolsSSHX *ToolsSSHXOptions
120+
ToolsVeth *ToolsVethOptions
121+
ToolsVxlan *ToolsVxlanOptions
122+
ToolsCodeServer *ToolsCodeServerOptions
115123
}
116124

117125
type GlobalOptions struct {
@@ -269,3 +277,14 @@ type ToolsVxlanOptions struct {
269277
ParentDevice string
270278
DeletionPrefix string
271279
}
280+
281+
type ToolsCodeServerOptions struct {
282+
Image string
283+
Name string
284+
Port uint
285+
Host string
286+
LogLevel string
287+
OutputFormat string
288+
LabsDirectory string
289+
Owner string
290+
}

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

@@ -80,3 +82,17 @@ func createLabelsMap(topo, labName, containerName, owner, toolType string) map[s
8082

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

cmd/tools_api_start.go

Lines changed: 0 additions & 15 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"
@@ -82,20 +81,6 @@ func (*APIServerNode) GetEndpoints() []clablinks.Endpoint {
8281
return nil
8382
}
8483

85-
// getclabBinaryPath determine the binary path of the running executable.
86-
func getclabBinaryPath() (string, error) {
87-
exePath, err := os.Executable()
88-
if err != nil {
89-
return "", err
90-
}
91-
92-
absPath, err := filepath.EvalSymlinks(exePath)
93-
if err != nil {
94-
return "", err
95-
}
96-
return absPath, nil
97-
}
98-
9984
// createLabels creates container labels.
10085
func createAPIServerLabels(containerName, owner string, port uint, labsDir, host, runtimeType string) map[string]string {
10186
labels := map[string]string{

0 commit comments

Comments
 (0)