Browse code

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 <dt@docker.com>

Dave Tucker authored on 2017/05/17 23:46:15
Showing 2 changed files
... ...
@@ -247,6 +247,12 @@ func (cli *Client) UpdateClientVersion(v string) {
247 247
 
248 248
 }
249 249
 
250
+// DaemonHost returns the host associated with this instance of the Client.
251
+// This operation doesn't acquire a mutex.
252
+func (cli *Client) DaemonHost() string {
253
+	return cli.host
254
+}
255
+
250 256
 // ParseHost verifies that the given host strings is valid.
251 257
 func ParseHost(host string) (string, string, string, error) {
252 258
 	protoAddrParts := strings.SplitN(host, "://", 2)
... ...
@@ -31,6 +31,7 @@ type CommonAPIClient interface {
31 31
 	SystemAPIClient
32 32
 	VolumeAPIClient
33 33
 	ClientVersion() string
34
+	DaemonHost() string
34 35
 	ServerVersion(ctx context.Context) (types.Version, error)
35 36
 	UpdateClientVersion(v string)
36 37
 }