Refactoring of code, renaming env variables name

This commit is contained in:
2024-07-30 08:59:15 +02:00
parent 05a195e1ba
commit 886773e38f
6 changed files with 35 additions and 19 deletions

View File

@@ -19,9 +19,9 @@ import (
// CreateSession creates a new AWS session
func CreateSession() (*session.Session, error) {
endPoint := os.Getenv("S3_ENDPOINT")
accessKey := os.Getenv("ACCESS_KEY")
secretKey := os.Getenv("SECRET_KEY")
endPoint := GetEnvVariable("AWS_S3_ENDPOINT", "S3_ENDPOINT")
accessKey := GetEnvVariable("AWS_ACCESS_KEY", "ACCESS_KEY")
secretKey := GetEnvVariable("AWS_SECRET_KEY", "SECRET_KEY")
region := os.Getenv("AWS_REGION")
awsDisableSsl, err := strconv.ParseBool(os.Getenv("AWS_DISABLE_SSL"))
if err != nil {

View File

@@ -178,6 +178,15 @@ func SetEnv(key, value string) {
return
}
}
func GetEnvVariable(envName, oldEnvName string) string {
value := os.Getenv(envName)
if value == "" {
value = os.Getenv(oldEnvName)
if value != "" {
fmt.Printf("%s is deprecated, please use %s instead!\n", oldEnvName, envName)
}
}
return value
}
func ShowHistory() {
}