Files
acc-server-manager/local/utl/configs/configs.go
Fran Jurmanović 747adc77a5
Some checks failed
Release and Deploy / deploy (push) Has been skipped
Release and Deploy / build (push) Failing after 6m7s
version bump
2026-03-22 12:24:54 +01:00

46 lines
947 B
Go

package configs
import (
"log"
"os"
"github.com/joho/godotenv"
)
var (
Version = "0.12.3"
Prefix = "v1"
Secret string
SecretCode string
EncryptionKey string
AccessKey string
)
func Init() {
godotenv.Load()
Secret = getEnvRequired("APP_SECRET")
SecretCode = getEnvRequired("APP_SECRET_CODE")
EncryptionKey = getEnvRequired("ENCRYPTION_KEY")
AccessKey = getEnvRequired("ACCESS_KEY")
if len(EncryptionKey) != 32 {
log.Fatal("ENCRYPTION_KEY must be exactly 32 bytes long for AES-256")
}
}
func getEnv(key, fallback string) string {
if value, exists := os.LookupEnv(key); exists {
return value
}
log.Printf("Environment variable %s not set, using fallback.", key)
return fallback
}
func getEnvRequired(key string) string {
if value, exists := os.LookupEnv(key); exists && value != "" {
return value
}
log.Fatalf("Required environment variable %s is not set or is empty", key)
return ""
}