display golang build version & git commit rev
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
daca095873
commit
1c7a68770d
9
Makefile
9
Makefile
|
@ -1,12 +1,13 @@
|
||||||
GOVER = $(shell go version)
|
GITCOMMIT = $(shell git rev-list -1 HEAD)
|
||||||
|
GOVERSION = $(shell go version | cut -d' ' -f 3)
|
||||||
|
|
||||||
run:
|
run:
|
||||||
@echo your version of go must be greater than 2.10. Your version is ${GOVER}
|
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
|
||||||
go build
|
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT}"
|
||||||
./cloud-control-panel
|
./cloud-control-panel
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
go build
|
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}'"
|
||||||
./cloud-control-panel --debugging
|
./cloud-control-panel --debugging
|
||||||
|
|
||||||
nogui:
|
nogui:
|
||||||
|
|
|
@ -67,9 +67,9 @@ func ReadReceivedData(data *pb.Event, mh *gui.TableData) {
|
||||||
log.Println("ReadReceivedData() Event vms=", vms)
|
log.Println("ReadReceivedData() Event vms=", vms)
|
||||||
for row, item := range vms {
|
for row, item := range vms {
|
||||||
if (row % 2) == 1 {
|
if (row % 2) == 1 {
|
||||||
mh.Rows[row].HumanData[0].Color = color.RGBA{0, 0, 0, 42} // makes the background of each other row grey
|
mh.Rows[row].HumanData[0].Color = color.RGBA{100, 100, 100, 142} // makes the background of each other row grey
|
||||||
} else {
|
} else {
|
||||||
mh.Rows[row].HumanData[0].Color = color.RGBA{0, 0, 0, 0}
|
mh.Rows[row].HumanData[0].Color = color.RGBA{0, 0, 0, 142}
|
||||||
}
|
}
|
||||||
mh.Rows[row].HumanData[1].Text = item.Name
|
mh.Rows[row].HumanData[1].Text = item.Name
|
||||||
mh.Rows[row].HumanData[1].Color = color.RGBA{0, 0, 0, 0}
|
mh.Rows[row].HumanData[1].Color = color.RGBA{0, 0, 0, 0}
|
||||||
|
|
244
infoTabUI.go
244
infoTabUI.go
|
@ -1,244 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import "log"
|
|
||||||
import "time"
|
|
||||||
import "fmt"
|
|
||||||
import "runtime/debug"
|
|
||||||
import "runtime"
|
|
||||||
|
|
||||||
import "github.com/gookit/config"
|
|
||||||
|
|
||||||
import "github.com/andlabs/ui"
|
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
|
||||||
import "git.wit.com/wit/gui"
|
|
||||||
|
|
||||||
import pb "git.wit.com/wit/witProtobuf"
|
|
||||||
|
|
||||||
// import "github.com/davecgh/go-spew/spew"
|
|
||||||
|
|
||||||
var cloudwin *ui.Window
|
|
||||||
var cloudtab *ui.Tab
|
|
||||||
var tabcount int
|
|
||||||
|
|
||||||
func makeCloudInfoBox() ui.Control {
|
|
||||||
hbox := ui.NewHorizontalBox()
|
|
||||||
hbox.SetPadded(true)
|
|
||||||
|
|
||||||
vbox := ui.NewVerticalBox()
|
|
||||||
vbox.SetPadded(true)
|
|
||||||
hbox.Append(vbox, false)
|
|
||||||
|
|
||||||
vbox.Append(ui.NewColorButton(), false)
|
|
||||||
|
|
||||||
addXbutton := ui.NewButton("Show bmath's Account")
|
|
||||||
addXbutton.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("gorillaSendProtobuf()")
|
|
||||||
gorillaSendProtobuf()
|
|
||||||
})
|
|
||||||
vbox.Append(addXbutton, false)
|
|
||||||
|
|
||||||
addButton := ui.NewButton("Add Account")
|
|
||||||
addButton.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("Not Implemented Yet. Try adding --debugging")
|
|
||||||
})
|
|
||||||
vbox.Append(addButton, false)
|
|
||||||
|
|
||||||
if (config.String("debugging") == "true") {
|
|
||||||
addDebuggingButtons(vbox)
|
|
||||||
}
|
|
||||||
|
|
||||||
hbox.Append(ui.NewVerticalSeparator(), false)
|
|
||||||
|
|
||||||
vbox = ui.NewVerticalBox()
|
|
||||||
vbox.SetPadded(true)
|
|
||||||
hbox.Append(vbox, true)
|
|
||||||
|
|
||||||
grid := ui.NewGrid()
|
|
||||||
grid.SetPadded(true)
|
|
||||||
vbox.Append(grid, false)
|
|
||||||
|
|
||||||
msggrid := ui.NewGrid()
|
|
||||||
msggrid.SetPadded(true)
|
|
||||||
|
|
||||||
entryForm := ui.NewForm()
|
|
||||||
entryForm.SetPadded(true)
|
|
||||||
vbox.Append(entryForm, false)
|
|
||||||
|
|
||||||
hostnameEntry := ui.NewEntry()
|
|
||||||
entryForm.Append("hostname:", hostnameEntry, false)
|
|
||||||
hostnameEntry.SetText("librem15.lab.wit.com")
|
|
||||||
|
|
||||||
IPv6entry := ui.NewEntry()
|
|
||||||
entryForm.Append("IPv6:", IPv6entry, false)
|
|
||||||
IPv6entry.SetText("2604:bbc0:3:3:0:10:0:1003")
|
|
||||||
|
|
||||||
return hbox
|
|
||||||
}
|
|
||||||
|
|
||||||
// can not pass any args to this (?)
|
|
||||||
func setupCloudUI() {
|
|
||||||
cloudwin = ui.NewWindow("Cloud Control Panel", config.Int("width"), config.Int("height"), false)
|
|
||||||
cloudwin.OnClosing(func(*ui.Window) bool {
|
|
||||||
ui.Quit()
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
ui.OnShouldQuit(func() bool {
|
|
||||||
cloudwin.Destroy()
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
cloudtab = ui.NewTab()
|
|
||||||
cloudwin.SetChild(cloudtab)
|
|
||||||
cloudwin.SetMargined(true)
|
|
||||||
|
|
||||||
tabcount = 0
|
|
||||||
cloudtab.Append("Cloud Info", makeCloudInfoBox())
|
|
||||||
cloudtab.SetMargined(tabcount, true)
|
|
||||||
|
|
||||||
cloudwin.Show()
|
|
||||||
}
|
|
||||||
|
|
||||||
func addTableTab() {
|
|
||||||
var parts []gui.TableColumnData
|
|
||||||
|
|
||||||
for key, foo := range []string{"BG", "TEXTCOLOR", "BUTTON", "TEXTCOLOR", "TEXTCOLOR", "TEXT", "BUTTON", "TEXT", "BUTTON"} {
|
|
||||||
log.Println(key, foo)
|
|
||||||
|
|
||||||
var b gui.TableColumnData
|
|
||||||
b.CellType = foo
|
|
||||||
b.Heading = fmt.Sprintf("heading%d", key)
|
|
||||||
parts = append(parts, b)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("Sleep for 2 seconds, then try to add new tabs")
|
|
||||||
time.Sleep(1 * 1000 * 1000 * 1000)
|
|
||||||
gui.AddTableTab(cloudtab, 1, "test seven", 7, parts)
|
|
||||||
}
|
|
||||||
|
|
||||||
func addVmsTab(count int) *gui.TableData {
|
|
||||||
var parts []gui.TableColumnData
|
|
||||||
|
|
||||||
human := 0
|
|
||||||
|
|
||||||
tmp := gui.TableColumnData{}
|
|
||||||
tmp.CellType = "BG"
|
|
||||||
tmp.Heading = "background"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
tmp = gui.TableColumnData{}
|
|
||||||
tmp.CellType = "TEXTCOLOR"
|
|
||||||
tmp.Heading = "name"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
tmp = gui.TableColumnData{}
|
|
||||||
tmp.CellType = "TEXTCOLOR"
|
|
||||||
tmp.Heading = "hostname"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
tmp = gui.TableColumnData{}
|
|
||||||
tmp.CellType = "TEXTCOLOR"
|
|
||||||
tmp.Heading = "IPv6"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
tmp = gui.TableColumnData{}
|
|
||||||
tmp.CellType = "TEXTCOLOR"
|
|
||||||
tmp.Heading = "cpus"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
tmp = gui.TableColumnData{}
|
|
||||||
tmp.CellType = "TEXTCOLOR"
|
|
||||||
tmp.Heading = "memory"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
tmp = gui.TableColumnData{}
|
|
||||||
tmp.CellType = "BUTTON"
|
|
||||||
tmp.Heading = "Details"
|
|
||||||
tmp.Index = human
|
|
||||||
parts = append(parts, tmp)
|
|
||||||
human += 1
|
|
||||||
|
|
||||||
mh := gui.AddTableTab(cloudtab, 1, "Virtual Machines", count, parts)
|
|
||||||
return mh
|
|
||||||
}
|
|
||||||
|
|
||||||
func addDebuggingButtons(vbox *ui.Box) {
|
|
||||||
vbox.Append(ui.NewLabel("Debugging:"), false)
|
|
||||||
|
|
||||||
// ATTEMPT TO ADD THE TABLE HERE
|
|
||||||
add2button := ui.NewButton("Add a Test Table")
|
|
||||||
add2button.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("send over socket")
|
|
||||||
addTableTab()
|
|
||||||
})
|
|
||||||
vbox.Append(add2button, false)
|
|
||||||
// ATTEMPT TO ADD THE TABLE HERE END
|
|
||||||
|
|
||||||
// hbox.Append(ui.NewVerticalSeparator(), false)
|
|
||||||
|
|
||||||
// Send a test protobuf Event to localhost
|
|
||||||
add3button := ui.NewButton("Add buf to chann")
|
|
||||||
add3button.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("add protobuf event to the channel")
|
|
||||||
addSampleEvent()
|
|
||||||
})
|
|
||||||
vbox.Append(add3button, false)
|
|
||||||
|
|
||||||
add4button := ui.NewButton("Add Demo Event")
|
|
||||||
add4button.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("add demo protobuf event to the channel")
|
|
||||||
msg := pb.CreateSampleEvent()
|
|
||||||
msg.Name = "generated in addSampleEvent()"
|
|
||||||
msg.Type = pb.Event_DEMO
|
|
||||||
addEvent(msg)
|
|
||||||
})
|
|
||||||
vbox.Append(add4button, false)
|
|
||||||
|
|
||||||
add4abutton := ui.NewButton("Close Demo GUI")
|
|
||||||
add4abutton.OnClicked(func(*ui.Button) {
|
|
||||||
gui.CloseDemoUI()
|
|
||||||
})
|
|
||||||
vbox.Append(add4abutton, false)
|
|
||||||
|
|
||||||
// Send a protobuf Event over the WIT socket
|
|
||||||
add5button := ui.NewButton("Send protobuf to localhost")
|
|
||||||
add5button.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("sent a Marshal'd protobuf to a localhost socket")
|
|
||||||
sendDataToDest()
|
|
||||||
})
|
|
||||||
vbox.Append(add5button, false)
|
|
||||||
|
|
||||||
// Send a protobuf over a gorilla websocket
|
|
||||||
add6button := ui.NewButton("gorillaSendProtobuf()")
|
|
||||||
add6button.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("gorillaSendProtobuf()")
|
|
||||||
gorillaSendProtobuf()
|
|
||||||
})
|
|
||||||
vbox.Append(add6button, false)
|
|
||||||
|
|
||||||
// debug all the golang goroutines
|
|
||||||
add7button := ui.NewButton("debug.PrintStack()")
|
|
||||||
add7button.OnClicked(func(*ui.Button) {
|
|
||||||
log.Println("debug.PrintStack() (SHOULD BE JUST THIS goroutine)")
|
|
||||||
debug.PrintStack()
|
|
||||||
|
|
||||||
log.Println("ATTEMPT FULL STACK DUMP")
|
|
||||||
log.Println("ATTEMPT FULL STACK DUMP")
|
|
||||||
log.Println("ATTEMPT FULL STACK DUMP")
|
|
||||||
buf := make([]byte, 1<<16)
|
|
||||||
runtime.Stack(buf, true)
|
|
||||||
fmt.Printf("%s", buf)
|
|
||||||
})
|
|
||||||
vbox.Append(add7button, false)
|
|
||||||
}
|
|
11
main.go
11
main.go
|
@ -9,6 +9,9 @@ import "github.com/gookit/config"
|
||||||
|
|
||||||
import "git.wit.com/wit/gui"
|
import "git.wit.com/wit/gui"
|
||||||
|
|
||||||
|
var GITCOMMIT string // this is passed in as an ldflag
|
||||||
|
var GOVERSION string // this is passed in as an ldflag
|
||||||
|
|
||||||
// import "github.com/davecgh/go-spew/spew"
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
// reminder to use this for JSON
|
// reminder to use this for JSON
|
||||||
|
@ -62,9 +65,11 @@ func main() {
|
||||||
go gorillaDial("v000185.testing.com.customers.wprod.wit.com:9000")
|
go gorillaDial("v000185.testing.com.customers.wprod.wit.com:9000")
|
||||||
go watchGUI()
|
go watchGUI()
|
||||||
|
|
||||||
gui.Data.Width = config.Int("width")
|
gui.Data.Width = config.Int("width")
|
||||||
gui.Data.Height = config.Int("height")
|
gui.Data.Height = config.Int("height")
|
||||||
|
gui.Data.Version = "v0.4 "
|
||||||
|
gui.Data.GitCommit = GITCOMMIT
|
||||||
|
gui.Data.GoVersion = GOVERSION
|
||||||
gui.Data.ButtonClickNew = buttonClickNew
|
gui.Data.ButtonClickNew = buttonClickNew
|
||||||
|
|
||||||
// make this the main loop in an attempt to figure out the crashes
|
// make this the main loop in an attempt to figure out the crashes
|
||||||
|
|
Loading…
Reference in New Issue