mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Config Tweaks
Using viper for config management. Added configuration endpoint.
This commit is contained in:
47
pkg/manager/config/config.go
Normal file
47
pkg/manager/config/config.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user