mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
bugfix for error scopes in config checking
This commit is contained in:
parent
8bb45c2970
commit
0316fbc607
@ -157,30 +157,19 @@ func loadConfig(){
|
||||
//If the confPath option has been set try to load and decode it
|
||||
if confPath != nil && len(*confPath) > 0 {
|
||||
file, err := os.Open(*confPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
exitOnConfigError(err)
|
||||
decodeConfig(file)
|
||||
} else {
|
||||
|
||||
// if no confPath look in the cwd
|
||||
cwd, err := os.Getwd()
|
||||
exitOnConfigError(err)
|
||||
cwd = cwd+"/config.json"
|
||||
confPath = &cwd
|
||||
if err == nil {
|
||||
file, err := os.Open(*confPath)
|
||||
if err == nil {
|
||||
decodeConfig(file)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Cannot Find configuration! Use -c parameter to point to a JSON file generated by -setup.\n\n Hint: have you run `-setup` ?")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
file, err := os.Open(*confPath)
|
||||
exitOnConfigError(err)
|
||||
decodeConfig(file)
|
||||
}
|
||||
fmt.Println("Using config file: "+ *confPath)
|
||||
|
||||
}
|
||||
|
||||
func validateConfig(){
|
||||
@ -210,6 +199,13 @@ func validatePort() {
|
||||
}
|
||||
}
|
||||
|
||||
func exitOnConfigError(err error){
|
||||
if err != nil {
|
||||
fmt.Println("Cannot Find configuration! Use -c parameter to point to a JSON file generated by -setup.\n\n Hint: have you run `-setup` ?")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func decodeConfig(file *os.File){
|
||||
|
Loading…
Reference in New Issue
Block a user