diff --git a/main.go b/main.go index fd44cb7..6428b83 100644 --- a/main.go +++ b/main.go @@ -10,27 +10,6 @@ import "strings" import "github.com/gookit/config" import "github.com/andlabs/ui" -/* -import "bytes" -import "context" -import "errors" -import "fmt" -import "go/ast" -import "go/format" -import "go/printer" -import "go/token" -import "go/types" -import "io/ioutil" -import "path/filepath" -import "sort" -import "strconv" -import "unicode" -import "unicode/utf8" - -import "golang.org/x/tools/go/ast/astutil" -import "golang.org/x/tools/go/packages" -*/ - // dns // import "github.com/miekg/dns" @@ -118,6 +97,45 @@ func makeBasicControlsPage(machineType string) ui.Control { return vbox } +func getPods(machineType string) []string { + var pods []string + home, _ := homedir.Dir() + files, err := ioutil.ReadDir(home+"/wit/docs/usw2/") + if err != nil { + log.Println(err) + return pods + } + + for _, f := range files { + s := strings.Split(f.Name(), ".") + if strings.HasSuffix(f.Name(), machineType) { + fmt.Println("Adding k8s pod: ", f.Name(), s) + pods = append(pods, f.Name()) + } else { + fmt.Println("Ignoring: ", f.Name(), s) + } + } + return pods +} + +func makeButtonsPage(names []string) ui.Control { + vbox := ui.NewVerticalBox() + vbox.SetPadded(true) + + hbox := ui.NewHorizontalBox() + hbox.SetPadded(true) + vbox.Append(hbox, false) + + for _, hostname := range names { + fmt.Println("hostname=", hostname) + vbox.Append(hostnameButton(hostname), false) + } + + vbox.Append(ui.NewHorizontalSeparator(), false) + + return vbox +} + func makeGroupEntries() ui.Control { group := ui.NewGroup("Entries") group.SetMargined(true) @@ -328,6 +346,10 @@ func setupUI() { tab.Append("Ceph", makeBasicControlsPage("d")) tab.SetMargined(0, true) + getPods("j") + tab.Append("k8s Pods", makeButtonsPage(getPods(".wit.com"))) + tab.SetMargined(0, true) + tab.Append("VMs", makeNumbersPage()) tab.SetMargined(1, true)