From ef32a06292873c4e8942cef07837a948ff71fa5a Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 26 Oct 2024 08:54:48 -0500 Subject: virtigo compiles Signed-off-by: Jeff Carr --- config.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'config.go') diff --git a/config.go b/config.go index 57fa319..01a397d 100644 --- a/config.go +++ b/config.go @@ -71,6 +71,41 @@ func (c *Cluster) ConfigSave() error { return nil } +func (c *Cluster) ConfigLoadOld() error { + if c == nil { + return errors.New("It's not safe to run ConfigLoad() on a nil cluster") + } + + // load the cluster config file + if data, err := loadFile("virtigo.json"); err == nil { + if err = protojson.Unmarshal(data, c); err != nil { + fmt.Println("broken cluster.json config file") + fmt.Println(err) + return errors.New("cluster.json file is broken") + } + } else { + return err + } + + var e *Events + e = new(Events) + // load the events config file + if data, err := loadFile("events.json"); err == nil { + if err = protojson.Unmarshal(data, e); err != nil { + fmt.Println("broken events.json config file") + return err + } + } else { + return err + } + // copy them over. is this needed? does the memory free otherwise? + for _, a := range e.Events { + c.Events = append(c.Events, a) + } + return nil +} + + func (c *Cluster) ConfigLoad() error { if c == nil { return errors.New("It's not safe to run ConfigLoad() on a nil cluster") @@ -185,6 +220,7 @@ func ConfigWriteTEXT(a any, filename string) error { return nil } +/* func WriteConfig(d *Droplets, h *Hypervisors, e *Events) bool { if !d.WriteConfigJSON() { return false @@ -279,6 +315,7 @@ func (d *Droplets) WriteConfigTEXT() bool { fmt.Println("Write:", fullname, "OK") return true } +*/ // human readable JSON func (c *Cluster) FormatJSON() string { -- cgit v1.2.3