Change to using yml for configuration files

This commit is contained in:
Dane Everitt
2017-09-30 17:25:04 -05:00
parent 5ed3bb2a0c
commit 256c566dfe
13 changed files with 70 additions and 18 deletions

View File

@@ -10,6 +10,7 @@ func LoadConfiguration(path string) error {
viper.SetConfigFile(path)
} else {
viper.AddConfigPath("./")
viper.SetConfigType("yaml")
viper.SetConfigName("config")
}
@@ -49,7 +50,7 @@ func setDefaults() {
// ContainsAuthKey checks wether the config contains a specified authentication key
func ContainsAuthKey(key string) bool {
for _, k := range viper.GetStringSlice(AuthKeys) {
for _, k := range viper.GetStringSlice(AuthKey) {
if k == key {
return true
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
)
const configFile = "../config.example.json"
const configFile = "../config.yml.example"
func TestLoadConfiguraiton(t *testing.T) {
err := LoadConfiguration(configFile)

View File

@@ -21,7 +21,7 @@ const (
SSLGenerateLetsencrypt = "api.ssl.letsencrypt"
// SSLCertificate is a string containing the location of
// a ssl certificate to use
SSLCertificate = "api.ssl.certificate"
SSLCertificate = "api.ssl.cert"
// SSLKey is a string containing the location of the key
// for the ssl certificate
SSLKey = "api.ssl.key"
@@ -61,6 +61,6 @@ const (
// logs should be stored. They will be deleted after. If set to 0
// logs will be stored indefinitely.
LogDeleteAfterDays = "log.deleteAfterDays"
// AuthKeys contains an array of auth keys that will be replaced by something better
AuthKeys = "authkeys"
// AuthKey contains a key that will be replaced by something better
AuthKey = "authKey"
)