From 6ce6ae1cd11d888e0c8ede20926b86981cee5ce1 Mon Sep 17 00:00:00 2001
From: Dave Tucker
Date: Wed, 17 May 2017 15:46:15 +0100
Subject: [PATCH] client: Expose DaemonHost to client users
This commit exposes `Client.host` as `Client.DaemonHost()`
This allows users of the client, a CLI for example, to query the Host
that the client is attempting to contact and vary their behaviour
accordingly. For example, to allow client-side configuration of
HTTP proxy settings for a number of different docker hosts.
Signed-off-by: Dave Tucker
---
client/client.go | 6 ++++++
client/interface.go | 1 +
2 files changed, 7 insertions(+)
diff --git a/client/client.go b/client/client.go
index f8f2fc6ad5..34897b9549 100644
--- a/client/client.go
+++ b/client/client.go
@@ -247,6 +247,12 @@ func (cli *Client) UpdateClientVersion(v string) {
}
+// DaemonHost returns the host associated with this instance of the Client.
+// This operation doesn't acquire a mutex.
+func (cli *Client) DaemonHost() string {
+ return cli.host
+}
+
// ParseHost verifies that the given host strings is valid.
func ParseHost(host string) (string, string, string, error) {
protoAddrParts := strings.SplitN(host, "://", 2)
diff --git a/client/interface.go b/client/interface.go
index 678a69ddf7..d5f3a14ec3 100644
--- a/client/interface.go
+++ b/client/interface.go
@@ -31,6 +31,7 @@ type CommonAPIClient interface {
SystemAPIClient
VolumeAPIClient
ClientVersion() string
+ DaemonHost() string
ServerVersion(ctx context.Context) (types.Version, error)
UpdateClientVersion(v string)
}