aboutsummaryrefslogtreecommitdiffstats
path: root/worker/lib/foldermap.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker/lib/foldermap.go')
-rw-r--r--worker/lib/foldermap.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/worker/lib/foldermap.go b/worker/lib/foldermap.go
new file mode 100644
index 00000000..4fd15979
--- /dev/null
+++ b/worker/lib/foldermap.go
@@ -0,0 +1,34 @@
+package lib
+
+import (
+ "fmt"
+ "io"
+
+ "github.com/go-ini/ini"
+)
+
+func ParseFolderMap(r io.Reader) (map[string]string, []string, error) {
+ cfg, err := ini.Load(r)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ sec, err := cfg.GetSection("")
+ if err != nil {
+ return nil, nil, err
+ }
+
+ order := sec.KeyStrings()
+
+ for _, k := range order {
+ v, err := sec.GetKey(k)
+ switch {
+ case v.String() == "":
+ return nil, nil, fmt.Errorf("no value for key '%s'", k)
+ case err != nil:
+ return nil, nil, err
+ }
+ }
+
+ return sec.KeysHash(), order, nil
+}