diff options
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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 { |
