Let an empty IRC_LISTEN_ADDR disable the IRC listener (closes #124)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
Viper treats an environment variable set to the empty string as unset, so an empty IRC_LISTEN_ADDR fell back to the :6667 default and the IRC listener could not be disabled from the environment. The config now reads IRC_LISTEN_ADDR with os.LookupEnv as well, so an empty value disables the listener and an unset one keeps :6667. Viper's own switch for this applies to every setting, so it is not used. New config tests cover both cases, and README.md says how to disable the listener. Model: opus-5-5 Co-authored-by: clawbot <sneak+clawbot@sneak.cloud>
This commit was merged in pull request #137.
This commit is contained in:
@@ -4,6 +4,7 @@ package config
|
||||
import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
@@ -129,6 +130,13 @@ func New(
|
||||
params: ¶ms,
|
||||
}
|
||||
|
||||
// Viper counts an empty environment variable as unset, but an
|
||||
// empty IRC_LISTEN_ADDR must turn the IRC listener off.
|
||||
ircListenAddr, set := os.LookupEnv("IRC_LISTEN_ADDR")
|
||||
if set {
|
||||
cfg.IRCListenAddr = ircListenAddr
|
||||
}
|
||||
|
||||
if cfg.Debug {
|
||||
params.Logger.EnableDebugLogging()
|
||||
cfg.log = params.Logger.Get()
|
||||
|
||||
Reference in New Issue
Block a user