diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-01-13 01:22:02 +0000 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-01-13 01:22:02 +0000 |
commit | b47d3326f6175a3fb0b997a20b3b1daa3dc9156f (patch) | |
tree | a1046ef9d37a3ae5ce9332c5dfd6ace51d8f5274 /config.go | |
parent | 4d5afdc2a6dfbb985fe9030cad7b0b8c3fc74819 (diff) |
added yaml config file
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 +} |