-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.go
42 lines (37 loc) · 1.13 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"github.com/mitchellh/go-homedir"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func init() {
setDefaultConfig()
setEnvVariables()
setConfigFile()
viper.Set("BinaryArch", "darwin_amd64") // TODO: multiarch
}
func setDefaultConfig() {
viper.SetDefault("LogLevel", "debug")
viper.SetDefault("LogFile", "~/.sonatina/sonatina.log")
viper.SetDefault("EnableStacktrace", false)
viper.SetDefault("DeploymentsPath", "~/.sonatina/deployments")
viper.SetDefault("DeploymentsFilename", "deployments.json")
viper.SetDefault("ManagerConnector", "json")
viper.SetDefault("TestFilesystem", false)
viper.SetDefault("TerraformPath", "~/.sonatina/terraform")
viper.SetDefault("DefaultTerraformVersion", "0.13.5")
viper.SetDefault("DefaultFlavour", "default")
viper.SetDefault("Editor", "vi")
}
func setEnvVariables() {
viper.SetEnvPrefix("SONATINA_")
}
func setConfigFile() {
viper.SetConfigName("config")
homeConfigPath, err := homedir.Expand("~/.sonatina")
if err != nil {
logrus.WithError(err).Fatalln("couldn't expand homedir")
}
viper.AddConfigPath(homeConfigPath)
viper.AddConfigPath("/etc/sonatina")
}