deprecate old experiment
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
7a0925041e
commit
954e555ac7
39
config.go
39
config.go
|
@ -12,68 +12,81 @@ import (
|
|||
"google.golang.org/protobuf/encoding/prototext"
|
||||
)
|
||||
|
||||
func WriteConfig(d *Droplets, h *Hypervisors, e *Events) {
|
||||
d.WriteConfigJSON()
|
||||
d.WriteConfigTEXT()
|
||||
func WriteConfig(d *Droplets, h *Hypervisors, e *Events) bool {
|
||||
if !d.WriteConfigJSON() {
|
||||
return false
|
||||
}
|
||||
if !d.WriteConfigTEXT() {
|
||||
return false
|
||||
}
|
||||
|
||||
e.WriteConfigJSON()
|
||||
e.WriteConfigTEXT()
|
||||
if e.WriteConfigJSON() {
|
||||
return false
|
||||
}
|
||||
if e.WriteConfigTEXT() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// export as json
|
||||
func (e *Events) WriteConfigJSON() {
|
||||
func (e *Events) WriteConfigJSON() bool {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "events.json")
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
return
|
||||
return false
|
||||
}
|
||||
text := e.FormatJSON()
|
||||
fmt.Fprintln(cfgfile, text)
|
||||
fmt.Println("Write:", fullname, "OK")
|
||||
return true
|
||||
}
|
||||
|
||||
// export as prototext
|
||||
func (e *Events) WriteConfigTEXT() {
|
||||
func (e *Events) WriteConfigTEXT() bool {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "events.text")
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
return
|
||||
return false
|
||||
}
|
||||
text := e.FormatTEXT()
|
||||
fmt.Fprintln(cfgfile, text)
|
||||
fmt.Println("Write:", fullname, "OK")
|
||||
return true
|
||||
}
|
||||
|
||||
// export as json
|
||||
func (d *Droplets) WriteConfigJSON() {
|
||||
func (d *Droplets) WriteConfigJSON() bool {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "droplets.json")
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
return
|
||||
return false
|
||||
}
|
||||
text := d.FormatJSON()
|
||||
fmt.Fprintln(cfgfile, text)
|
||||
fmt.Println("Write:", fullname, "OK")
|
||||
return true
|
||||
}
|
||||
|
||||
// export as prototext
|
||||
func (d *Droplets) WriteConfigTEXT() {
|
||||
func (d *Droplets) WriteConfigTEXT() bool {
|
||||
fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "droplets.text")
|
||||
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||
defer cfgfile.Close()
|
||||
if err != nil {
|
||||
fmt.Println("open config file :", err)
|
||||
return
|
||||
return false
|
||||
}
|
||||
text := d.FormatTEXT()
|
||||
fmt.Fprintln(cfgfile, text)
|
||||
fmt.Println("Write:", fullname, "OK")
|
||||
return true
|
||||
}
|
||||
|
||||
// human readable JSON
|
||||
|
|
|
@ -29,7 +29,7 @@ message Droplet {
|
|||
string image_url = 15; // url to the image
|
||||
|
||||
// is it possible to have custom formatting in JSON and TEXT marshal/unmarshal ?
|
||||
JunkInfo humantest = 16;
|
||||
// JunkInfo humantest = 16;
|
||||
}
|
||||
|
||||
enum DropletState {
|
||||
|
|
Loading…
Reference in New Issue