Config Tweaks

Using viper for config management.  Added configuration endpoint.
This commit is contained in:
Stash Dev
2019-03-23 07:56:59 -07:00
parent b69739dcc4
commit dd22d88d07
45 changed files with 940 additions and 642 deletions

View File

@@ -0,0 +1,47 @@
package config
import (
"github.com/spf13/viper"
)
const Stash = "stash"
const Cache = "cache"
const Generated = "generated"
const Metadata = "metadata"
const Downloads = "downloads"
const Database = "database"
func Set(key string, value interface{}) {
viper.Set(key, value)
}
func Write() error {
return viper.WriteConfig()
}
func GetStashPaths() []string {
return viper.GetStringSlice(Stash)
}
func GetCachePath() string {
return viper.GetString(Cache)
}
func GetGeneratedPath() string {
return viper.GetString(Generated)
}
func GetMetadataPath() string {
return viper.GetString(Metadata)
}
func GetDatabasePath() string {
return viper.GetString(Database)
}
func IsValid() bool {
setPaths := viper.IsSet(Stash) && viper.IsSet(Cache) && viper.IsSet(Generated) && viper.IsSet(Metadata)
// TODO: check valid paths
return setPaths
}