Created
October 25, 2015 15:29
-
-
Save xorl/1d3d23bcaaeb8fb03fb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
//"flag" | |
"fmt" | |
"gopkg.in/yaml.v2" | |
"io/ioutil" | |
"os" | |
"path/filepath" | |
) | |
type Cfg struct { | |
Params `yaml:"params"` | |
OpsParams map[string]string `yaml:"ops_params"` | |
HostName string `yaml:"hostname"` | |
Colo string `yaml:"colo"` | |
} | |
type Params struct { | |
Libvirt `yaml:"libvirt"` | |
} | |
type Libvirt struct { | |
Guests `yam:"guests"` | |
} | |
type Guests struct { | |
Hostname map[string]string | |
} | |
func visit(path string, f os.FileInfo, err error) error { | |
if !f.IsDir() { | |
yamlFile, err := ioutil.ReadFile(path) | |
if err != nil { | |
//panic(err) | |
return nil | |
} | |
var cfg Cfg | |
err = yaml.Unmarshal(yamlFile, &cfg) | |
if err != nil { | |
//panic(err) | |
return nil | |
} | |
//lifecycle := cfg.OpsParams["lifecycle"] | |
//environment := cfg.OpsParams["environment"] | |
//fmt.Printf("lifecycle: %#v\n", lifecycle) | |
//fmt.Printf("environment: %#v\n", environment) | |
} | |
return nil | |
} | |
func main() { | |
root := "../../ops-config/hosts/" | |
data := filepath.Walk(root, visit) | |
fmt.Printf("filepath.Walk() returned %v\n", data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment