From 8698d11a3d05bec7bc3a6132d82d2970b0bb149d Mon Sep 17 00:00:00 2001 From: zyxkad Date: Sat, 17 Aug 2024 16:55:32 -0600 Subject: [PATCH] fix nil pointer config --- main.go | 8 +++----- runner.go | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index e8ac129..0fdae27 100644 --- a/main.go +++ b/main.go @@ -98,17 +98,15 @@ func main() { defer log.RecordPanic() log.StartFlushLogFile() - r := NewRunner() - ctx, cancel := context.WithCancel(context.Background()) - if config, err := readAndRewriteConfig(); err != nil { + config, err := readAndRewriteConfig() + if err != nil { log.Errorf("Config error: %s", err) os.Exit(1) - } else { - r.Config = config } + r := NewRunner(cfg) r.SetupLogger(ctx) log.TrInfof("program.starting", build.ClusterVersion, build.BuildVersion) diff --git a/runner.go b/runner.go index 9d60979..58cfafe 100644 --- a/runner.go +++ b/runner.go @@ -93,9 +93,10 @@ type Runner struct { tunnelCancel context.CancelFunc } -func NewRunner() *Runner { +func NewRunner(cfg *config.Config) *Runner { r := new(Runner) + r.Config = cfg r.configHandler = &ConfigHandler{r: r} var dialer *net.Dialer