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>
This commit is contained in:
Dave Tucker 2017-05-17 15:46:15 +01:00
Родитель 6f6ee6fd04
Коммит 6ce6ae1cd1
2 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -31,6 +31,7 @@ type CommonAPIClient interface {
SystemAPIClient
VolumeAPIClient
ClientVersion() string
DaemonHost() string
ServerVersion(ctx context.Context) (types.Version, error)
UpdateClientVersion(v string)
}