-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (36 loc) · 762 Bytes
/
main.go
File metadata and controls
45 lines (36 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"os"
"github.com/alecthomas/kong"
)
var (
cli struct {
Select struct {
} `cmd:"select" default:"withargs" help:"Select active Kubernetes Context."`
Update struct {
} `cmd:"update" help:"Create contexts for all Namespaces in configured clusters."`
}
)
func main() {
ctx := kong.Parse(&cli)
if err := execCmd(ctx.Command()); err != nil {
fmt.Println("ERR:", err)
os.Exit(1)
}
}
func execCmd(cmd string) error {
conf, err := ReadKubeConfig()
if err != nil {
fmt.Println("ERROR reading kube config:", err.Error())
os.Exit(1)
}
switch cmd {
case "select":
return cmdSelectContext(conf)
case "update":
return cmdUpdateConfigFile(conf)
default:
return fmt.Errorf("unknown command %q", cmd)
}
}