summaryrefslogtreecommitdiff
path: root/config.go
blob: 33c4e9fbe3e717fd650d64b6364c6360713b7e0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"log"
)

type CompCfg struct {
	Name string `yaml:"Name"`
	URL  string `yaml:"URL"`
}

type SuiteCfg struct {
	Name       string    `yaml:"Name"`
	Components []CompCfg `yaml:"Components"`
}

type ReleaseCfg struct {
	Release      string     `yaml:"Release"`
	RepoURL      string     `yaml:"RepoURL"`
	ReleaseIndex string     `yaml:"ReleaseIndex"`
	Suites       []SuiteCfg `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
}