package main import ( "log" "os" ) type config struct { addr string storePath string ca string crt string crtKey string } // TODO: Maybe use viper? func loadConfigFromEnv() *config { res := config{} if addr, ok := os.LookupEnv("SECRETS_SERVER_ADDR"); !ok || addr == "" { log.Fatal("SECRETS_SERVER_ADDR is required") } else { res.addr = addr } if storePath, ok := os.LookupEnv("SECRETS_SERVER_STORE_PATH"); !ok || storePath == "" { log.Fatal("SECRETS_SERVER_STORE_PATH is required") } else { res.storePath = storePath } if ca, ok := os.LookupEnv("SECRETS_SERVER_CA"); !ok || ca == "" { log.Fatal("SECRETS_SERVER_CA is required") } else { res.ca = ca } if crt, ok := os.LookupEnv("SECRETS_SERVER_CRT"); !ok || crt == "" { log.Fatal("SECRETS_SERVER_CRT is required") } else { res.crt = crt } if crtKey, ok := os.LookupEnv("SECRETS_SERVER_CRT_KEY"); !ok || crtKey == "" { log.Fatal("SECRETS_SERVER_CRT_KEY is required") } else { res.crtKey = crtKey } return &res }