fixed my config after totally destroying things
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e58f78eb2d
commit
1ca936e98e
33
config.go
33
config.go
|
@ -135,38 +135,33 @@ func (c *Cluster) ConfigLoad() error {
|
|||
c.Hypervisors = append(c.Hypervisors, a)
|
||||
}
|
||||
|
||||
if err := c.loadEvents(); err != nil {
|
||||
var e *Events
|
||||
e = new(Events)
|
||||
|
||||
if c.E == nil {
|
||||
c.E = new(Events)
|
||||
}
|
||||
if err := e.loadEvents(); err != nil {
|
||||
return err
|
||||
}
|
||||
// copy them over. is this needed? does the memory free otherwise?
|
||||
for _, e := range e.Events {
|
||||
c.E.Events = append(c.E.Events, e)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) loadEvents() error {
|
||||
func (e *Events) loadEvents() error {
|
||||
var data []byte
|
||||
var err error
|
||||
|
||||
if c == nil {
|
||||
fmt.Println("cluster == nil")
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
if c.E == nil {
|
||||
fmt.Println("cluster.E == nil")
|
||||
c.E = new(Events)
|
||||
}
|
||||
|
||||
if c.E == nil {
|
||||
fmt.Println("cluster.E == nil")
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
// load the events config file
|
||||
if data, err = loadFile("events.json"); err != nil {
|
||||
fmt.Println("broken events.json config file")
|
||||
return err
|
||||
}
|
||||
|
||||
err = protojson.Unmarshal(data, c.E)
|
||||
err = protojson.Unmarshal(data, e)
|
||||
if err != nil {
|
||||
fmt.Println("broken events.json config file")
|
||||
// json load failed. try loading prototext
|
||||
|
@ -175,7 +170,7 @@ func (c *Cluster) loadEvents() error {
|
|||
fmt.Println(err)
|
||||
return errors.New("events.text file is broken")
|
||||
}
|
||||
if err = prototext.Unmarshal(data, c.E); err != nil {
|
||||
if err = prototext.Unmarshal(data, e); err != nil {
|
||||
fmt.Println("broken events.text config file")
|
||||
fmt.Println(err)
|
||||
return errors.New("events.text file is broken")
|
||||
|
|
Loading…
Reference in New Issue