write out json cfg file
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
70a506bc59
commit
91d2a8a19d
|
@ -1,14 +1,45 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
pb "go.wit.com/lib/protobuf/virtbuf"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var cluster *pb.Cluster
|
||||||
|
|
||||||
|
func readConfigFile() {
|
||||||
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
fullname := filepath.Join(homeDir, ".config/virtigo.json")
|
||||||
|
pfile, err := os.ReadFile(fullname)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("open config file :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = cluster.UnmarshalJSON(pfile)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("create json failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeConfigFile() {
|
||||||
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
fullname := filepath.Join(homeDir, ".config/virtigo.json")
|
||||||
|
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("open config file :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
json := cluster.FormatJSON()
|
||||||
|
fmt.Fprintln(cfgfile, json)
|
||||||
|
}
|
||||||
|
|
||||||
func readDropletFile(filename string) {
|
func readDropletFile(filename string) {
|
||||||
// fmt.Fprintln(w, "GOT TEST?")
|
// fmt.Fprintln(w, "GOT TEST?")
|
||||||
homeDir, _ := os.UserHomeDir()
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
|
Loading…
Reference in New Issue