crap. the 'config' isn't parsing the JSON files correctly?
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
03f30a7161
commit
84fc164e7f
13
Makefile
13
Makefile
|
@ -1,15 +1,20 @@
|
|||
GITCOMMIT = $(shell git rev-list -1 HEAD)
|
||||
GOVERSION = $(shell go version | cut -d' ' -f 3)
|
||||
BUILDTIME = $(shell date -u --iso-8601=seconds)
|
||||
|
||||
# try go get github.com/ahmetb/govvv
|
||||
# this will add branch info & build RFC3339 date also
|
||||
|
||||
debug:
|
||||
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
|
||||
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}'"
|
||||
./cloud-control-panel --debugging
|
||||
|
||||
run:
|
||||
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
|
||||
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT}"
|
||||
./cloud-control-panel
|
||||
|
||||
debug:
|
||||
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}'"
|
||||
./cloud-control-panel --debugging
|
||||
|
||||
nogui:
|
||||
go build
|
||||
./cloud-control-panel -nogui
|
||||
|
|
13
config.go
13
config.go
|
@ -14,6 +14,8 @@ import "log"
|
|||
import "os"
|
||||
import "flag"
|
||||
import "fmt"
|
||||
import "runtime"
|
||||
|
||||
import "github.com/gookit/config"
|
||||
import "github.com/gookit/config/yaml"
|
||||
import "github.com/gookit/config/json"
|
||||
|
@ -73,7 +75,7 @@ func parseFlags() {
|
|||
config.Set("debugging", debugging)
|
||||
}
|
||||
|
||||
func parseConfig() {
|
||||
func parseConfig(defaultConfig string) {
|
||||
config.WithOptions(config.ParseEnv)
|
||||
parseFlags()
|
||||
|
||||
|
@ -85,6 +87,15 @@ func parseConfig() {
|
|||
config.AddDriver(yaml.Driver)
|
||||
config.AddDriver(json.Driver)
|
||||
|
||||
// TODO: figure out how to look for this file in the right
|
||||
// place under Linux, MacOS and Windows
|
||||
if runtime.GOOS == "linux" {
|
||||
log.Println("OS: Linux")
|
||||
} else if runtime.GOOS == "windows" {
|
||||
log.Println("OS: Windows")
|
||||
} else {
|
||||
log.Println("OS: " + runtime.GOOS)
|
||||
}
|
||||
config.LoadFiles("config.json")
|
||||
|
||||
for _, addr := range config.Strings("arr1") {
|
||||
|
|
22
config.json
22
config.json
|
@ -8,6 +8,28 @@
|
|||
"docker0"
|
||||
],
|
||||
"baseKey": "value2",
|
||||
"accounts": {
|
||||
"jcarr": {
|
||||
"hostname": "fire.lab.wit.com",
|
||||
"domainname": "lab.wit.com",
|
||||
"port": 3333,
|
||||
"rows": 18,
|
||||
"proto": "tcp"
|
||||
},
|
||||
"jcarr2": {
|
||||
"hostname": "fire.lab.wit.com",
|
||||
"domainname": "lab.wit.com",
|
||||
"port": 3333,
|
||||
"rows": 18,
|
||||
"proto": "tcp"
|
||||
},
|
||||
"bmath": {
|
||||
"hostname": "v000185.testing.com.customers.wprod.wit.com",
|
||||
"domainname": "testing.com.customers.wprod.wit.com",
|
||||
"port": 9000,
|
||||
"proto": "tcp"
|
||||
}
|
||||
},
|
||||
"cloud": {
|
||||
"jcarr": {
|
||||
"hostname": "fire.lab.wit.com",
|
||||
|
|
16
main.go
16
main.go
|
@ -6,6 +6,7 @@ import "time"
|
|||
// import "fmt"
|
||||
|
||||
import "github.com/gookit/config"
|
||||
import "github.com/gobuffalo/packr"
|
||||
|
||||
import "git.wit.com/wit/gui"
|
||||
|
||||
|
@ -51,7 +52,13 @@ func onExit() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
parseConfig()
|
||||
// This puts all the files in that directory in the binary
|
||||
// This directory includes the default config file if there is not already one
|
||||
box := packr.NewBox("./resources")
|
||||
defaultConfig, _ := box.FindString("cloud.json")
|
||||
|
||||
// This will parse the command line and config file
|
||||
parseConfig(defaultConfig)
|
||||
|
||||
// only test the socket code if no GUI
|
||||
if (config.String("nogui") == "true") {
|
||||
|
@ -67,7 +74,7 @@ func main() {
|
|||
|
||||
gui.Data.Width = config.Int("width")
|
||||
gui.Data.Height = config.Int("height")
|
||||
gui.Data.Version = "v0.4 "
|
||||
gui.Data.Version = "v0.4"
|
||||
gui.Data.GitCommit = GITCOMMIT
|
||||
gui.Data.GoVersion = GOVERSION
|
||||
gui.Data.ButtonClickNew = buttonClickNew
|
||||
|
@ -85,6 +92,11 @@ func buttonClickNew(b *gui.ButtonMap) {
|
|||
if (b.Note == "BACK") {
|
||||
gui.Data.State = "splash"
|
||||
}
|
||||
if (b.Note == "ADD") {
|
||||
log.Println("\tSHOULD ADD ACCOUNT HERE")
|
||||
log.Println("\tSHOULD ADD ACCOUNT HERE")
|
||||
log.Println("\tSHOULD ADD ACCOUNT HERE")
|
||||
}
|
||||
if (b.Note == "BMATH") {
|
||||
log.Println("\tTRIGGER BMATH HERE")
|
||||
log.Println("\tTRIGGER BMATH HERE")
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"BUILDDEBUG": "",
|
||||
"MAIL": "/var/mail/jcarr",
|
||||
"USER": "jcarr",
|
||||
"arr1": [
|
||||
"lo",
|
||||
"wifi0",
|
||||
"docker0"
|
||||
],
|
||||
"baseKey": "value2",
|
||||
"accounts": {
|
||||
"jcarr": {
|
||||
"hostname": "fire.lab.wit.com",
|
||||
"port": 3333,
|
||||
"rows": 18,
|
||||
"proto": "tcp"
|
||||
},
|
||||
"bmath": {
|
||||
"hostname": "v000185.testing.com.customers.wprod.wit.com",
|
||||
"domainname": "testing.com.customers.wprod.wit.com",
|
||||
"port": 9000,
|
||||
"proto": "tcp"
|
||||
}
|
||||
},
|
||||
"cloud": {
|
||||
"jcarr": {
|
||||
"hostname": "fire.lab.wit.com",
|
||||
"port": 3333,
|
||||
"rows": 18,
|
||||
"proto": "tcp"
|
||||
},
|
||||
"v000185": {
|
||||
"hostname": "v000185.testing.com.customers.wprod.wit.com",
|
||||
"port": 3333,
|
||||
"rows": 567,
|
||||
"proto": "tcp"
|
||||
}
|
||||
},
|
||||
"debug": false,
|
||||
"envKey1": "${NotExist|defValue}",
|
||||
"height": 600,
|
||||
"width": 800,
|
||||
"hostname": "localhost",
|
||||
"map1": {
|
||||
"key1": {
|
||||
"jwc1": "jcarr1",
|
||||
"jwc2": "jcarr2"
|
||||
},
|
||||
"key2": "val20"
|
||||
},
|
||||
"name": "app2",
|
||||
"shell": "${SHELL}"
|
||||
}
|
Loading…
Reference in New Issue