base code for libvirt connections

This commit is contained in:
2021-09-09 03:28:05 +02:00
parent 7b9c7c57ef
commit c2d111a928
8 changed files with 120 additions and 1 deletions

28
src/conf.go Normal file
View File

@@ -0,0 +1,28 @@
package overlord
import (
"encoding/json"
"flag"
"log"
"os"
)
type Config struct {
LibvirtHosts []string
PrivateKey string
ConfFilePath string
LogFilePath string
}
func (conf *Config) ReadConfig() {
flag.StringVar(&conf.ConfFilePath, "c", "lord.json", "Config file path.")
flag.StringVar(&conf.LogFilePath, "l", "", "Log file path.")
flag.Parse()
file, err := os.Open(conf.ConfFilePath)
if err != nil {
log.Printf("Error opening config file! %s", err)
} else {
defer file.Close()
json.NewDecoder(file).Decode(&conf)
}
}