dospin/settings.go

47 lines
897 B
Go
Raw Normal View History

2016-02-26 17:35:57 -06:00
/*
2017-01-25 17:59:25 -06:00
Copyright 2016-2017 gtalent2@gmail.com
2016-02-26 17:35:57 -06:00
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 {
2017-01-26 20:04:33 -06:00
ApiToken string
Servers map[string]Server
2016-02-14 23:38:28 -06:00
}
2016-02-28 01:03:16 -06:00
type Server struct {
Ports []int
UsePublicIP bool
InitialSize string
Size string
Region string
UsePersistentImage bool
ImageSlug string
UserData string
SshKeys []string
Volumes []string
2016-02-14 23:38:28 -06:00
}
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
}