config: prefix environment variables with BESZEL_AGENT_ (#502)

This commit is contained in:
Henry Dollman
2025-01-29 20:13:07 -05:00
parent 7170b24160
commit 120aff0d18
5 changed files with 26 additions and 16 deletions

View File

@@ -22,11 +22,12 @@ func main() {
}
// Try to get the key from the KEY environment variable.
pubKey := []byte(os.Getenv("KEY"))
key, _ := agent.GetEnv("KEY")
pubKey := []byte(key)
// If KEY is not set, try to read the key from the file specified by KEY_FILE.
if len(pubKey) == 0 {
keyFile, exists := os.LookupEnv("KEY_FILE")
keyFile, exists := agent.GetEnv("KEY_FILE")
if !exists {
log.Fatal("Must set KEY or KEY_FILE environment variable")
}
@@ -38,7 +39,8 @@ func main() {
}
addr := ":45876"
if portEnvVar, exists := os.LookupEnv("PORT"); exists {
// TODO: change env var to ADDR
if portEnvVar, exists := agent.GetEnv("PORT"); exists {
// allow passing an address in the form of "127.0.0.1:45876"
if !strings.Contains(portEnvVar, ":") {
portEnvVar = ":" + portEnvVar