From ac8374fd17e30fca9a7773a2a6f690a7ea4d2ec9 Mon Sep 17 00:00:00 2001 From: Grayson Koonce Date: Wed, 12 Oct 2016 11:04:26 -0700 Subject: Rework as HTTP server (#15) --- config.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 config.go (limited to 'config.go') diff --git a/config.go b/config.go new file mode 100644 index 0000000..5071f37 --- /dev/null +++ b/config.go @@ -0,0 +1,34 @@ +package main + +import ( + "io/ioutil" + + "gopkg.in/yaml.v2" +) + +// Config represents the structure of the yaml file +type Config struct { + URL string `yaml:"url"` + Packages map[string]Package `yaml:"packages"` +} + +// Package details the options available for each repo +type Package struct { + Repo string `yaml:"repo"` +} + +// Parse takes a path to a yaml file and produces a parsed Config +func Parse(path string) (Config, error) { + var c Config + + data, err := ioutil.ReadFile(path) + if err != nil { + return c, err + } + + if err := yaml.Unmarshal(data, &c); err != nil { + return c, err + } + + return c, err +} -- cgit v1.2.3