package utils

import (
	"github.com/spf13/viper"
)

func DevConfig() (Port, DBname, Password, Username, Host, key, secret string) {

	viper.SetConfigName("config") // config file name without extension
	viper.SetConfigType("yaml")
	viper.AddConfigPath(".")

	err := viper.ReadInConfig()
	if err != nil {
		Logger.Fatalf("fatal error config file: default \n %v", err)
	}

	dbname := viper.GetString("DEV.DATABASE_NAME")
	dbpassword := viper.GetString("DEV.DATABASE_PASSWORD")
	dbusername := viper.GetString("DEV.DATABASE_USERNAME")
	dbport := viper.GetString("DEV.DATABASE_PORT")
	dbhost := viper.GetString("DEV.DATABASE_SERVER_HOST")
	contextkey := viper.GetString("DEV.USER_CONTEXT_KEY")
	jwtkey := viper.GetString("DEV.JWT_SECRET_KEY")
	return dbport, dbname, dbpassword, dbusername, dbhost, contextkey, jwtkey
}

func LiveConfig() (Port, DBname, Password, Username, Host, key, secret string) {

	viper.SetConfigName("config") // config file name without extension
	viper.SetConfigType("yaml")
	viper.AddConfigPath(".")

	err := viper.ReadInConfig()
	if err != nil {
		Logger.Fatalf("fatal error config file: default \n %v", err)
	}
	dbname := viper.GetString("APP.DATABASE_NAME")
	dbpassword := viper.GetString("APP.DATABASE_PASSWORD")
	dbusername := viper.GetString("APP.DATABASE_USERNAME")
	dbport := viper.GetString("APP.DATABASE_PORT")
	dbhost := viper.GetString("APP.DATABASE_SERVER_HOST")
	contextkey := viper.GetString("APP.USER_CONTEXT_KEY")
	jwtkey := viper.GetString("APP.JWT_SECRET_KEY")
	return dbport, dbname, dbpassword, dbusername, dbhost, contextkey, jwtkey
}
