mirror of
https://github.com/zix99/traefik-lazyload.git
synced 2025-12-24 06:28:31 +01:00
Abstract to host
This commit is contained in:
@@ -7,14 +7,13 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
type Discovery struct {
|
||||
client *client.Client
|
||||
client Host
|
||||
}
|
||||
|
||||
func NewDiscovery(client *client.Client) *Discovery {
|
||||
func NewDiscovery(client Host) *Discovery {
|
||||
return &Discovery{client}
|
||||
}
|
||||
|
||||
|
||||
19
pkg/containers/intf.go
Normal file
19
pkg/containers/intf.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package containers
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
||||
type Host interface {
|
||||
ContainerList(ctx context.Context, clo types.ContainerListOptions) ([]types.Container, error)
|
||||
|
||||
ContainerStart(ctx context.Context, id string, opt types.ContainerStartOptions) error
|
||||
ContainerStop(ctx context.Context, id string, opt container.StopOptions) error
|
||||
|
||||
ContainerStatsOneShot(ctx context.Context, id string) (types.ContainerStats, error)
|
||||
|
||||
Close() error
|
||||
}
|
||||
@@ -20,7 +20,7 @@ type Core struct {
|
||||
mux sync.Mutex
|
||||
term chan bool
|
||||
|
||||
client *client.Client
|
||||
client containers.Host
|
||||
discovery *containers.Discovery
|
||||
|
||||
active map[string]*ContainerState // cid -> state
|
||||
|
||||
Reference in New Issue
Block a user