dospin/settings.go

45 lines
780 B
Go
Raw Normal View History

2016-02-26 17:35:57 -06:00
/*
Copyright 2016 gtalent2@gmail.com
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
2016-02-14 23:38:28 -06:00
package main
import (
"encoding/json"
"io/ioutil"
)
2016-02-15 00:18:56 -06:00
type Settings struct {
2016-02-27 16:10:44 -06:00
ApiToken string
Services map[string]Service
LogicalServers map[string]LogicalServer
2016-02-14 23:38:28 -06:00
}
2016-02-27 16:10:44 -06:00
type Service struct {
Port int
LogicalServer string
}
type LogicalServer struct {
2016-02-14 23:38:28 -06:00
Size string
Region string
}
2016-02-15 00:18:56 -06:00
func loadSettings(path string) (Settings, error) {
var s Settings
2016-02-14 23:38:28 -06:00
data, err := ioutil.ReadFile(path)
if err != nil {
return s, err
}
err = json.Unmarshal(data, &s)
if err != nil {
return s, err
}
return s, err
}