mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-27 23:46:39 +01:00
* feat: uses --hostname as the label for localhost. see #2394 * fixes tests
This commit is contained in:
8
main.go
8
main.go
@@ -73,7 +73,7 @@ func main() {
|
||||
|
||||
log.Infof("Dozzle version %s", version)
|
||||
|
||||
clients := createClients(args, docker.NewClientWithFilters, docker.NewClientWithTlsAndFilter)
|
||||
clients := createClients(args, docker.NewClientWithFilters, docker.NewClientWithTlsAndFilter, args.Hostname)
|
||||
|
||||
if len(clients) == 0 {
|
||||
log.Fatal("Could not connect to any Docker Engines")
|
||||
@@ -132,10 +132,14 @@ func doStartEvent(arg args) {
|
||||
|
||||
func createClients(args args,
|
||||
localClientFactory func(map[string][]string) (*docker.Client, error),
|
||||
remoteClientFactory func(map[string][]string, docker.Host) (*docker.Client, error)) map[string]web.DockerClient {
|
||||
remoteClientFactory func(map[string][]string, docker.Host) (*docker.Client, error),
|
||||
hostname string) map[string]web.DockerClient {
|
||||
clients := make(map[string]web.DockerClient)
|
||||
|
||||
if localClient := createLocalClient(args, localClientFactory); localClient != nil {
|
||||
if hostname != "" {
|
||||
localClient.Host().Name = hostname
|
||||
}
|
||||
clients[localClient.Host().ID] = localClient
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ func Test_valid_remote(t *testing.T) {
|
||||
RemoteHost: []string{"tcp://test:2375"},
|
||||
}
|
||||
|
||||
clients := createClients(args, fakeLocalClientFactory, fakeRemoteClientFactory)
|
||||
clients := createClients(args, fakeLocalClientFactory, fakeRemoteClientFactory, "")
|
||||
|
||||
assert.Equal(t, 1, len(clients))
|
||||
assert.Contains(t, clients, "test")
|
||||
@@ -106,7 +106,7 @@ func Test_valid_remote_and_local(t *testing.T) {
|
||||
RemoteHost: []string{"tcp://test:2375"},
|
||||
}
|
||||
|
||||
clients := createClients(args, fakeLocalClientFactory, fakeRemoteClientFactory)
|
||||
clients := createClients(args, fakeLocalClientFactory, fakeRemoteClientFactory, "")
|
||||
|
||||
assert.Equal(t, 2, len(clients))
|
||||
assert.Contains(t, clients, "test")
|
||||
@@ -133,7 +133,7 @@ func Test_no_clients(t *testing.T) {
|
||||
|
||||
args := args{}
|
||||
|
||||
clients := createClients(args, fakeLocalClientFactory, fakeRemoteClientFactory)
|
||||
clients := createClients(args, fakeLocalClientFactory, fakeRemoteClientFactory, "")
|
||||
|
||||
assert.Equal(t, 0, len(clients))
|
||||
local.AssertExpectations(t)
|
||||
|
||||
Reference in New Issue
Block a user