2019-08-13 09:48:47 -05:00
|
|
|
package main
|
|
|
|
|
2019-08-13 10:01:26 -05:00
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
2019-08-13 09:48:47 -05:00
|
|
|
type Configuration struct {
|
|
|
|
Username string
|
|
|
|
Password string
|
2019-08-13 10:01:26 -05:00
|
|
|
Port string
|
2019-08-13 09:48:47 -05:00
|
|
|
Hosts []string
|
|
|
|
}
|
|
|
|
|
2019-08-13 10:01:26 -05:00
|
|
|
func initializeConfig(filename string) Configuration {
|
|
|
|
var config Configuration
|
|
|
|
source, err := ioutil.ReadFile(filename)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = yaml.Unmarshal(source, &config)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-08-13 09:48:47 -05:00
|
|
|
|
2019-08-13 10:01:26 -05:00
|
|
|
return config
|
2019-08-13 09:48:47 -05:00
|
|
|
}
|