feat: docker over tls (#178)

This commit is contained in:
Yuzerion
2025-12-23 12:01:11 +08:00
committed by yusing
parent 9acb9fa50f
commit 8340d93ab7
25 changed files with 312 additions and 85 deletions

View File

@@ -10,12 +10,15 @@ import (
"github.com/docker/docker/client"
"github.com/rs/zerolog/log"
"github.com/yusing/godoxy/internal/docker"
"github.com/yusing/godoxy/internal/types"
"github.com/yusing/godoxy/internal/watcher/events"
gperr "github.com/yusing/goutils/errs"
)
type (
DockerWatcher string
DockerWatcher struct {
cfg types.DockerProviderConfig
}
DockerListOptions = dockerEvents.ListOptions
)
@@ -55,8 +58,10 @@ func DockerFilterContainerNameID(nameOrID string) filters.KeyValuePair {
return filters.Arg("container", nameOrID)
}
func NewDockerWatcher(host string) DockerWatcher {
return DockerWatcher(host)
func NewDockerWatcher(dockerCfg types.DockerProviderConfig) DockerWatcher {
return DockerWatcher{
cfg: dockerCfg,
}
}
func (w DockerWatcher) Events(ctx context.Context) (<-chan Event, <-chan gperr.Error) {
@@ -68,7 +73,7 @@ func (w DockerWatcher) EventsWithOptions(ctx context.Context, options DockerList
errCh := make(chan gperr.Error)
go func() {
client, err := docker.NewClient(string(w))
client, err := docker.NewClient(w.cfg)
if err != nil {
errCh <- gperr.Wrap(err, "docker watcher: failed to initialize client")
return

View File

@@ -61,7 +61,7 @@ func NewMonitor(r types.Route) types.HealthMonCheck {
}
if r.IsDocker() {
cont := r.ContainerInfo()
client, err := docker.NewClient(cont.DockerHost)
client, err := docker.NewClient(cont.DockerCfg)
if err != nil {
return mon
}