rm code now made by autogenpb
This commit is contained in:
parent
c82997ed61
commit
e78fc1235e
|
@ -1,166 +0,0 @@
|
||||||
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
|
||||||
// This file was autogenerated with autogenpb 0.0.61 2025/02/23_0116_UTC
|
|
||||||
// go install go.wit.com/apps/autogenpb@latest
|
|
||||||
//
|
|
||||||
// define which structs (messages) you want to use in the .proto file
|
|
||||||
// Then sort.pb.go and marshal.pb.go files are autogenerated
|
|
||||||
//
|
|
||||||
// autogenpb uses it and has an example .proto file with instructions
|
|
||||||
//
|
|
||||||
|
|
||||||
package virtpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"go.wit.com/lib/protobuf/guipb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (mt *DropletsTable) NewUuid() {
|
|
||||||
mt.pb.Uuid = uuid.New().String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *HypervisorsTable) NewUuid() {
|
|
||||||
mt.pb.Uuid = uuid.New().String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *EventsTable) NewUuid() {
|
|
||||||
mt.pb.Uuid = uuid.New().String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *HypervisorsTable) Update() {
|
|
||||||
for _, name := range mt.pb.Order {
|
|
||||||
if mt.updateTimeFunc(name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mt.parent.UpdateTable(mt.pb)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *HypervisorsTable) updateTimeFunc(name string) bool {
|
|
||||||
log.Info("LOOKING FOR TIME row", name)
|
|
||||||
var found *guipb.TimeRow
|
|
||||||
for i, r := range mt.pb.TimeRows {
|
|
||||||
// log.Info("could use", i, r.Header.Name, "for name =", name)
|
|
||||||
if r.Header.Name == name {
|
|
||||||
log.Info("found row", i, r.Header.Name)
|
|
||||||
found = r
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if found == nil {
|
|
||||||
log.Info("did not find time row", name)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, sf := range mt.timeFuncs {
|
|
||||||
if sf.title != name {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// log.Info("updateTimeFunc() has row len =", len(mt.x.Droplets))
|
|
||||||
// log.Info("virtpb: starting", name, found.Vals)
|
|
||||||
for i, _ := range found.Vals {
|
|
||||||
newt := sf.f(mt.x.Hypervisors[i])
|
|
||||||
found.Vals[i] = timestamppb.New(newt) // convert to protobuf time
|
|
||||||
}
|
|
||||||
// log.Info("virtpb: ending", name, found.Vals)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *DropletsTable) Update() {
|
|
||||||
// log.Info("now what?")
|
|
||||||
for _, name := range mt.pb.Order {
|
|
||||||
// log.Info("virtpb: trying to update row()", name)
|
|
||||||
if mt.updateStringFunc(name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if mt.updateTimeFunc(name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if mt.updateIntFunc(name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
// mt.dumpStringFunc("Hostname")
|
|
||||||
mt.parent.UpdateTable(mt.pb)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *DropletsTable) dumpStringFunc(name string) {
|
|
||||||
for i, r := range mt.pb.StringRows {
|
|
||||||
// log.Info("could use", i, r.Header.Name, "for name =", name)
|
|
||||||
if r.Header.Name == name {
|
|
||||||
log.Info("dump Strings row", i, r.Header.Name, r.Vals)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *DropletsTable) updateStringFunc(name string) bool {
|
|
||||||
// log.Info("LOOKING FOR STRING row", name)
|
|
||||||
var found *guipb.StringRow
|
|
||||||
for _, r := range mt.pb.StringRows {
|
|
||||||
// log.Info("could use", i, r.Header.Name, "for name =", name)
|
|
||||||
if r.Header.Name == name {
|
|
||||||
// log.Info("found row", i, r.Header.Name)
|
|
||||||
found = r
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if found == nil {
|
|
||||||
log.Info("did not find string row", name)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, sf := range mt.stringFuncs {
|
|
||||||
if sf.title != name {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// log.Printf("updateStringFunc() %s len (%d)\n", name, len(mt.x.Droplets))
|
|
||||||
// log.Info("virtpb: starting", name, found.Vals)
|
|
||||||
for i, _ := range found.Vals {
|
|
||||||
tmp := sf.f(mt.x.Droplets[i])
|
|
||||||
if tmp == "www.wit.com" {
|
|
||||||
log.Info("virtpb: FOUND WWW", i)
|
|
||||||
tmp = "new.www"
|
|
||||||
}
|
|
||||||
found.Vals[i] = tmp
|
|
||||||
}
|
|
||||||
// log.Info("virtpb: ending", name, found.Vals)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *DropletsTable) updateTimeFunc(name string) bool {
|
|
||||||
log.Info("LOOKING FOR TIME row", name)
|
|
||||||
var found *guipb.TimeRow
|
|
||||||
for i, r := range mt.pb.TimeRows {
|
|
||||||
// log.Info("could use", i, r.Header.Name, "for name =", name)
|
|
||||||
if r.Header.Name == name {
|
|
||||||
log.Info("found row", i, r.Header.Name)
|
|
||||||
found = r
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if found == nil {
|
|
||||||
log.Info("did not find time row", name)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, sf := range mt.timeFuncs {
|
|
||||||
if sf.title != name {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// log.Info("updateTimeFunc() has row len =", len(mt.x.Droplets))
|
|
||||||
// log.Info("virtpb: starting", name, found.Vals)
|
|
||||||
for i, _ := range found.Vals {
|
|
||||||
newt := sf.f(mt.x.Droplets[i])
|
|
||||||
found.Vals[i] = timestamppb.New(newt) // convert to protobuf time
|
|
||||||
}
|
|
||||||
// log.Info("virtpb: ending", name, found.Vals)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
Loading…
Reference in New Issue