read event config maybe works
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
2882686caf
commit
473729eb35
18
config.go
18
config.go
|
@ -29,6 +29,24 @@ func WriteConfig(d *Droplets, h *Hypervisors, e *Events) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// read in events.json
|
||||
func ReadEventsConfig() (*Events, error) {
|
||||
e := new(Events)
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "events.json")
|
||||
data, err := os.ReadFile(fullname)
|
||||
if err != nil {
|
||||
// log.Info("open config file :", err)
|
||||
return nil, err
|
||||
}
|
||||
err = e.UnmarshalJSON(data)
|
||||
if err != nil {
|
||||
// log.Info("read json failed", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// export as json
|
||||
func (e *Events) WriteConfigJSON() bool {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "events.json")
|
||||
|
|
Loading…
Reference in New Issue