diff --git a/config.go b/config.go index 43d9ca8..9077636 100644 --- a/config.go +++ b/config.go @@ -1,12 +1,31 @@ package main +import ( + "io/ioutil" + + "gopkg.in/yaml.v2" +) + type Configuration struct { Username string Password string - Port int + Port string Hosts []string } -func initializeConfig() { +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) + } + + return config } diff --git a/main.go b/main.go index 44ee7ea..0011fa9 100644 --- a/main.go +++ b/main.go @@ -3,5 +3,11 @@ package main import "fmt" func main() { - fmt.Println("Hello!") + //fmt.Println("Hello!") + + //var config Configuration + + config := initializeConfig("config.yaml") + fmt.Println(config.Username) + } diff --git a/ssh.go b/ssh.go index a9dd39b..56bdd73 100644 --- a/ssh.go +++ b/ssh.go @@ -1,6 +1,6 @@ package main type sshConnection struct { - Username string - Password []string + Username Configuration + Password Configuration }