// InitConfig reads all configurations and sets them.
// Order is (first match counts):
//	1. Environment variables
//	2. Configurationfile $HOME/.secretsfs/secretsfs.yaml
//	3. Configurationfile provided by environment variable SFS_CONFIG_FILE
//	4. Configurationfile /etc/secretsfs/secretsfs.yaml
//	5. Hardcoded configurations from var configDefaults
// This function is executed in init().
//
// https://github.com/spf13/viper#reading-config-files
InitConfig reads all configurations and sets them.
Order is (first match counts):
1. Environment variables
2. Configurationfile $HOME/.secretsfs/secretsfs.yaml
3. Configurationfile provided by environment variable SFS_CONFIG_FILE
4. Configurationfile /etc/secretsfs/secretsfs.yaml
5. Hardcoded configurations from var configDefaults
This function is executed in init().

github.com/spf13/viper#reading-config-files
// InitConfig reads all configurations and sets them . // Order is ( first match counts ) : // 1 . Environment variables // 2 . Configurationfile $HOME / . secretsfs / secretsfs . yaml // 3 . Configurationfile provided by environment variable SFS_CONFIG_FILE // 4 . Configurationfile / etc / secretsfs / secretsfs . yaml // 5 . Hardcoded configurations from var configDefaults // This function is executed in init () . // // https : // github . com / spf13 / viper#reading - config - files
func InitConfig() {
	viper.SetConfigType("yaml")
	viper.ReadConfig(bytes.NewBuffer(configDefaults))
	viper.SetEnvPrefix("SFS")
	viper.AutomaticEnv()
	viper.BindEnv("store.vault.addr", "VAULT_ADDR")
	viper.SetConfigName("secretsfs")
	viper.AddConfigPath("$HOME/.secretsfs") 
	if viper.IsSet("general.configuration.configfile") {
		viper.SetConfigName(viper.GetString("general.configuration.configfile"))
	}
	viper.AddConfigPath("/etc/secretsfs/")
	if viper.IsSet("general.configuration.paths") {
		paths := viper.GetStringSlice("general.configuration.paths")
		for _, p := range paths {
			viper.AddConfigPath(p)
		}
	}
	err := viper.MergeInConfig()                                                                                       
	if err != nil && !strings.Contains(err.Error(), "Config File") && !strings.Contains(err.Error(), "Not Found in") { 
		panic(fmt.Errorf("%s\n", err))
	}
}
func InitConfig ( ) { viper . SetConfigType ( " " ) viper . ReadConfig ( bytes . NewBuffer ( configDefaults ) ) viper . SetEnvPrefix ( " " ) viper . AutomaticEnv ( ) viper . BindEnv ( " " , " " ) viper . SetConfigName ( " " ) viper . AddConfigPath ( " " ) if viper . IsSet ( " " ) { viper . SetConfigName ( viper . GetString ( " " ) ) } viper . AddConfigPath ( " " ) if viper . IsSet ( " " ) { paths := viper . GetStringSlice ( " " ) for _ , p := range paths { viper . AddConfigPath ( p ) } } err := viper . MergeInConfig ( ) if err != nil && ! strings . Contains ( err . Error ( ) , " " ) && ! strings . Contains ( err . Error ( ) , " " ) { panic ( fmt . Errorf ( " \n " , err ) ) } }
InitConfig reads all configurations and sets them.
InitConfig reads all configurations and sets them .
// read defaults first // read automatically all envs with Prefix SFS_ // also read vault addr env // needs both parameters for BindEnv, else prefix would be prefixed // read config file specific things first and overwrite if necessary // call multiple times to add many search paths // add config paths of ENV var first so it overwrites any other config? // TODO: check, whether it really works like this // read configuration from config files // Find and read the config files // Handle errors reading the config file