1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-27 07:31:46 +01:00

feat: removes localhost as a required client. fixes #2259 (#2263)

* feat: removes localhost as a required connection

* refactors code

* fixes tests

* adds more tests

* adds more tests

* refactors

* cleans up logs
This commit is contained in:
Amir Raminfar
2023-06-20 10:43:47 -07:00
committed by GitHub
parent 3aa874e399
commit 31063fa1b4
6 changed files with 255 additions and 82 deletions

View File

@@ -71,7 +71,7 @@ type Client interface {
}
// NewClientWithFilters creates a new instance of Client with docker filters
func NewClientWithFilters(f map[string][]string) Client {
func NewClientWithFilters(f map[string][]string) (Client, error) {
filterArgs := filters.NewArgs()
for key, values := range f {
for _, value := range values {
@@ -84,13 +84,13 @@ func NewClientWithFilters(f map[string][]string) Client {
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
log.Fatal(err)
return nil, err
}
return &dockerClient{cli, filterArgs}
return &dockerClient{cli, filterArgs}, nil
}
func NewClientWithTlsAndFilter(f map[string][]string, connection string) Client {
func NewClientWithTlsAndFilter(f map[string][]string, connection string) (Client, error) {
filterArgs := filters.NewArgs()
for key, values := range f {
for _, value := range values {
@@ -102,7 +102,7 @@ func NewClientWithTlsAndFilter(f map[string][]string, connection string) Client
remoteUrl, err := url.Parse(connection)
if err != nil {
log.Fatal(err)
return nil, err
}
if remoteUrl.Scheme != "tcp" {
@@ -136,10 +136,10 @@ func NewClientWithTlsAndFilter(f map[string][]string, connection string) Client
cli, err := client.NewClientWithOpts(opts...)
if err != nil {
log.Fatal(err)
return nil, err
}
return &dockerClient{cli, filterArgs}
return &dockerClient{cli, filterArgs}, nil
}
func (d *dockerClient) FindContainer(id string) (Container, error) {