aboutsummaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
authorGravatar Grayson Koonce <grayson.koonce@gmail.com> 2016-09-30 15:34:03 -0700
committerGravatar GitHub <noreply@github.com> 2016-09-30 15:34:03 -0700
commitcba441714f357b9b25d5c0cacbfb2e376bbbe679 (patch)
tree2db58d65d94946f0c5ed6b07162bdcb648a255ca /parse.go
parent4754d5ec7e5d162585f2ebdb259132330e9fdf55 (diff)
downloadsally-cba441714f357b9b25d5c0cacbfb2e376bbbe679.tar.gz
sally-cba441714f357b9b25d5c0cacbfb2e376bbbe679.tar.zst
sally-cba441714f357b9b25d5c0cacbfb2e376bbbe679.zip
Starting point (#1)
Diffstat (limited to '')
-rw-r--r--parse.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/parse.go b/parse.go
new file mode 100644
index 0000000..5071f37
--- /dev/null
+++ b/parse.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
+}