You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
613 B
38 lines
613 B
package main |
|
|
|
import ( |
|
"fmt" |
|
"io/ioutil" |
|
"log" |
|
|
|
"gopkg.in/yaml.v2" |
|
) |
|
|
|
type PortalConfig struct { |
|
Command string |
|
Host []string `yaml:",flow"` |
|
} |
|
|
|
type Config struct { |
|
Portals map[string]*PortalConfig |
|
} |
|
|
|
var config = &Config{} |
|
|
|
func readConfig(configPath string) error { |
|
configData, err := ioutil.ReadFile(configPath) |
|
if err != nil { |
|
return fmt.Errorf("failed to read file: %s", err) |
|
} |
|
|
|
err = yaml.Unmarshal(configData, config) |
|
if err != nil { |
|
return fmt.Errorf("failed to parse file: %s", err) |
|
} |
|
|
|
if len(config.Portals) == 0 { |
|
log.Println("Warning: No portals are defined") |
|
} |
|
|
|
return nil |
|
}
|
|
|