diff options
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/config.go b/config.go new file mode 100644 index 0000000..c71d287 --- /dev/null +++ b/config.go @@ -0,0 +1,43 @@ +package main + +import ( + "gopkg.in/yaml.v2" + "io/ioutil" + "log" +) + +type CompCfg struct { + Name string `yaml:"Name"` + URL string `yaml:"URL"` +} + +type Suite struct { + Name string `yaml:"Name"` + Components []CompCfg `yaml:"Components"` +} + +type ReleaseCfg struct { + Release string `yaml:"Release"` + RepoURL string `yaml:"RepoURL"` + Suites []Suite `yaml:"Suites"` +} + +type PkgwebCfg struct { + PkgSets []ReleaseCfg `yaml:"PkgSets"` +} + +func readConfig(fname string) *PkgwebCfg { + + data, err := ioutil.ReadFile(fname) + if err != nil { + log.Fatal("Error while reading file: ", err) + } + + cfg := new(PkgwebCfg) + + err = yaml.Unmarshal(data, cfg) + if err != nil { + log.Fatal("Error while reading configuration: ", err) + } + return cfg +} |