From 189c8706304203e8eaa801c2ad225aef80911002 Mon Sep 17 00:00:00 2001 From: yusing Date: Sun, 2 Mar 2025 21:59:32 +0800 Subject: [PATCH] fix docker client panic introduced in last patch --- internal/watcher/docker_watcher.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/watcher/docker_watcher.go b/internal/watcher/docker_watcher.go index 331d465..4cac0d8 100644 --- a/internal/watcher/docker_watcher.go +++ b/internal/watcher/docker_watcher.go @@ -6,7 +6,7 @@ import ( docker_events "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" - D "github.com/yusing/go-proxy/internal/docker" + "github.com/yusing/go-proxy/internal/docker" E "github.com/yusing/go-proxy/internal/error" "github.com/yusing/go-proxy/internal/watcher/events" ) @@ -14,7 +14,7 @@ import ( type ( DockerWatcher struct { host string - client *D.SharedClient + client *docker.SharedClient } DockerListOptions = docker_events.ListOptions ) @@ -66,6 +66,13 @@ func (w DockerWatcher) EventsWithOptions(ctx context.Context, options DockerList w.client.Close() }() + client, err := docker.ConnectClient(w.host) + if err != nil { + errCh <- E.From(err) + return + } + w.client = client + cEventCh, cErrCh := w.client.Events(ctx, options) for {