refactor, fix reload error when using agents, and other small improvements

This commit is contained in:
yusing
2025-02-11 12:15:51 +08:00
parent b1f72620dc
commit 429a77de8e
10 changed files with 139 additions and 105 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/http"
"runtime/debug"
"sync"
"github.com/docker/cli/cli/connhelper"
@@ -11,6 +12,7 @@ import (
"github.com/rs/zerolog"
"github.com/yusing/go-proxy/agent/pkg/agent"
"github.com/yusing/go-proxy/internal/common"
config "github.com/yusing/go-proxy/internal/config/types"
"github.com/yusing/go-proxy/internal/logging"
"github.com/yusing/go-proxy/internal/task"
U "github.com/yusing/go-proxy/internal/utils"
@@ -84,9 +86,9 @@ func ConnectClient(host string) (*SharedClient, error) {
var opt []client.Opt
if agent.IsDockerHostAgent(host) {
cfg, ok := agent.GetAgentFromDockerHost(host)
cfg, ok := config.GetInstance().GetAgent(host)
if !ok {
return nil, fmt.Errorf("agent not found for host: %s", host)
return nil, fmt.Errorf("agent %q not found\n%s", host, debug.Stack())
}
opt = []client.Opt{
client.WithHost(agent.DockerHost),