mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-11 03:06:51 +02:00
refactor, fix reload error when using agents, and other small improvements
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/yusing/go-proxy/agent/pkg/agent"
|
||||
config "github.com/yusing/go-proxy/internal/config/types"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
U "github.com/yusing/go-proxy/internal/utils"
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||
@@ -82,7 +83,11 @@ func FromDocker(c *types.Container, dockerHost string) (res *Container) {
|
||||
}
|
||||
|
||||
if agent.IsDockerHostAgent(dockerHost) {
|
||||
res.Agent, _ = agent.GetAgentFromDockerHost(dockerHost)
|
||||
var ok bool
|
||||
res.Agent, ok = config.GetInstance().GetAgent(dockerHost)
|
||||
if !ok {
|
||||
logging.Error().Msgf("agent %q not found", dockerHost)
|
||||
}
|
||||
}
|
||||
|
||||
res.setPrivateHostname(helper)
|
||||
|
||||
Reference in New Issue
Block a user