mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-20 16:01:36 +02:00
feat: docker over tls (#178)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user