smarter debugging
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
6a65efc40d
commit
6ac24113b5
8
Makefile
8
Makefile
|
@ -44,13 +44,15 @@ update:
|
||||||
go get -v -t -u .
|
go get -v -t -u .
|
||||||
|
|
||||||
# make the json config file human readable
|
# make the json config file human readable
|
||||||
json-make-readable:
|
config-make-readable:
|
||||||
cat ~/.config/cloud-control-panel.json |jq -r --tab
|
cat ~/.config/cloud-control-panel.json |jq -r --tab
|
||||||
|
|
||||||
json-restore:
|
config-load-testconfig:
|
||||||
|
echo loading the test config
|
||||||
cp resources/cloud-control-panel.json ~/.config/cloud-control-panel.json
|
cp resources/cloud-control-panel.json ~/.config/cloud-control-panel.json
|
||||||
|
|
||||||
json-delete:
|
config-delete:
|
||||||
|
echo deleting your current config
|
||||||
mv ~/.config/cloud-control-panel.json /tmp
|
mv ~/.config/cloud-control-panel.json /tmp
|
||||||
|
|
||||||
diff:
|
diff:
|
||||||
|
|
22
config.go
22
config.go
|
@ -5,7 +5,7 @@ package main
|
||||||
package called 'flag'. This can be used as a simple template to parse
|
package called 'flag'. This can be used as a simple template to parse
|
||||||
command line arguments in other programs.
|
command line arguments in other programs.
|
||||||
|
|
||||||
It puts everything in the 'config' package which I think is a good
|
It puts everything in a 'config' Protobuf which I think is a good
|
||||||
wrapper around the 'flags' package and doesn't need a whole mess of
|
wrapper around the 'flags' package and doesn't need a whole mess of
|
||||||
global variables
|
global variables
|
||||||
*/
|
*/
|
||||||
|
@ -42,13 +42,13 @@ func loadConfigFile() {
|
||||||
filename := ""
|
filename := ""
|
||||||
// TODO: confirm this is correct for MacOS and Windows
|
// TODO: confirm this is correct for MacOS and Windows
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
log.Println("OS: Linux")
|
log.Println("loadConfigFile() OS: Linux")
|
||||||
filename = user.HomeDir + "/.config/cloud-control-panel.json"
|
filename = user.HomeDir + "/.config/cloud-control-panel.json"
|
||||||
} else if runtime.GOOS == "windows" {
|
} else if runtime.GOOS == "windows" {
|
||||||
log.Println("OS: Windows")
|
log.Println("loadConfigFile() OS: Windows")
|
||||||
filename = user.HomeDir + "\\cloud-control-panel.json"
|
filename = user.HomeDir + "\\cloud-control-panel.json"
|
||||||
} else {
|
} else {
|
||||||
log.Println("OS: " + runtime.GOOS)
|
log.Println("loadConfigFile() OS: " + runtime.GOOS)
|
||||||
filename = user.HomeDir + "/.cloud-control-panel.json"
|
filename = user.HomeDir + "/.cloud-control-panel.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ func loadConfigFromFilename(filename string) pb.Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
// will load the default config from within the go binary
|
// will load the default config from within the go binary
|
||||||
func loadDefaultConfig() pb.Config {
|
func loadDefaultConfig() *pb.Config {
|
||||||
log.Println("TRY TO LOAD DEFAULT CONFIG")
|
log.Println("TRY TO LOAD DEFAULT CONFIG")
|
||||||
// defaultConfig, _ := packrBox.FindString("protobuf-config.json")
|
// defaultConfig, _ := packrBox.FindString("protobuf-config.json")
|
||||||
b, err := packrBox.FindString("cloud-control-panel.json")
|
b, err := packrBox.FindString("cloud-control-panel.json")
|
||||||
|
@ -183,7 +183,7 @@ func loadDefaultConfig() pb.Config {
|
||||||
log.Println("jsonpb.Unmarshal() ERROR =", err)
|
log.Println("jsonpb.Unmarshal() ERROR =", err)
|
||||||
}
|
}
|
||||||
spew.Dump(sets)
|
spew.Dump(sets)
|
||||||
return sets
|
return &sets
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -205,5 +205,13 @@ func parseConfig() {
|
||||||
log.Println("account = ", key, foo)
|
log.Println("account = ", key, foo)
|
||||||
log.Println("Accounts[key] = ", config.Accounts[key])
|
log.Println("Accounts[key] = ", config.Accounts[key])
|
||||||
}
|
}
|
||||||
// os.Exit(0)
|
if (config.Accounts == nil) {
|
||||||
|
log.Println("loadConfigFile() config.Accounts == nil")
|
||||||
|
log.Println("If debugging is on, should load default config here")
|
||||||
|
if (config.Debug) {
|
||||||
|
log.Println("Debugging is on, loading debug config")
|
||||||
|
config = loadDefaultConfig()
|
||||||
|
// onExit(fmt.Errorf("loadConfigFile() config.Accounts == nil"))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue