start date works on events

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-25 17:01:30 -05:00
parent 4d43c36db5
commit 9b94785cd2
3 changed files with 21 additions and 11 deletions

View File

@ -5,8 +5,10 @@ import (
"errors"
"fmt"
"time"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
pb "go.wit.com/lib/protobuf/virtbuf"
@ -71,6 +73,9 @@ func NewChangeEvent(d *pb.Droplet, fname string, origval any, newval any) *pb.Ev
e.NewVal = convertToString(newval)
e.FieldName = fname
now := time.Now()
e.Start = timestamppb.New(now)
// this also works, but it's a bit overkill
// e.NewAny = convertToAnypb(newval)

View File

@ -29,23 +29,24 @@ var ErrorParseXML error = errors.New("invalid xml")
// something is wrong somewhere and sometimes the
// protobuf json files get written out with garbage
func cfgfile() {
func cfgfile() error {
err := readConfigFile("virtigo.json")
if err == nil {
return
}
if err == ErrorParseJSON {
os.Exit(-1)
return err
}
// test last config also parses
err = readConfigFile("virtigo.json.last")
if err == nil {
log.Info("read json failed", err)
os.Exit(-1)
return err
}
if err == ErrorNoFile {
log.Info("no config file created yet", err)
os.Exit(-1)
// try parsing event log
e, err := pb.ReadEventsConfig()
if err == nil {
return err
}
me.events = e
return nil
}
func readConfigFile(filename string) error {

View File

@ -47,7 +47,11 @@ func main() {
me.events.Uuid = u.String()
me.events.Version = "dirty v1"
cfgfile()
err := cfgfile()
if err != nil {
log.Warn("reading config file failed", err)
os.Exit(-1)
}
// sanity check the droplets
checkDroplets(false)