summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-25 17:01:48 -0500
committerJeff Carr <[email protected]>2024-10-25 17:01:48 -0500
commit473729eb35969597cd4e98d8efb56fef8ee88427 (patch)
tree54d0bdb5711dd2f36cd29b98c8b1d19a63472f10 /config.go
parent2882686cafcfee508bd663ce1566cc418f4b3564 (diff)
read event config maybe works
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'config.go')
-rw-r--r--config.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/config.go b/config.go
index 1a1651c..840959b 100644
--- a/config.go
+++ b/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")