diff --git a/interface.go b/interface.go index 4d450d8316..f919612163 100644 --- a/interface.go +++ b/interface.go @@ -127,6 +127,7 @@ type SystemAPIClient interface { Info(ctx context.Context) (types.Info, error) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) DiskUsage(ctx context.Context) (types.DiskUsage, error) + Ping(ctx context.Context) (bool, error) } // VolumeAPIClient defines API client methods for the volumes diff --git a/interface_experimental.go b/interface_experimental.go index 1ddc517c9a..ddb9f79b5a 100644 --- a/interface_experimental.go +++ b/interface_experimental.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( @@ -7,9 +5,7 @@ import ( "golang.org/x/net/context" ) -// APIClient is an interface that clients that talk with a docker server must implement. -type APIClient interface { - CommonAPIClient +type apiClientExperimental interface { CheckpointAPIClient PluginAPIClient } @@ -32,6 +28,3 @@ type PluginAPIClient interface { PluginSet(ctx context.Context, name string, args []string) error PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) } - -// Ensure that Client always implements APIClient. -var _ APIClient = &Client{} diff --git a/interface_stable.go b/interface_stable.go index 496f522d51..cc90a3cbb9 100644 --- a/interface_stable.go +++ b/interface_stable.go @@ -1,10 +1,9 @@ -// +build !experimental - package client // APIClient is an interface that clients that talk with a docker server must implement. type APIClient interface { CommonAPIClient + apiClientExperimental } // Ensure that Client always implements APIClient. diff --git a/ping.go b/ping.go new file mode 100644 index 0000000000..5e99e1bba1 --- /dev/null +++ b/ping.go @@ -0,0 +1,19 @@ +package client + +import "golang.org/x/net/context" + +// Ping pings the server and return the value of the "Docker-Experimental" header +func (cli *Client) Ping(ctx context.Context) (bool, error) { + serverResp, err := cli.get(ctx, "/_ping", nil, nil) + if err != nil { + return false, err + } + defer ensureReaderClosed(serverResp) + + exp := serverResp.header.Get("Docker-Experimental") + if exp != "true" { + return false, nil + } + + return true, nil +} diff --git a/plugin_disable.go b/plugin_disable.go index 893fc6e823..51e4565125 100644 --- a/plugin_disable.go +++ b/plugin_disable.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_disable_test.go b/plugin_disable_test.go index 7b50b25730..2818008ab9 100644 --- a/plugin_disable_test.go +++ b/plugin_disable_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_enable.go b/plugin_enable.go index 84422abc79..8109814ddb 100644 --- a/plugin_enable.go +++ b/plugin_enable.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_enable_test.go b/plugin_enable_test.go index a2b57be4c2..d919914e75 100644 --- a/plugin_enable_test.go +++ b/plugin_enable_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_inspect.go b/plugin_inspect.go index 7ba8db57a8..e9474b5a98 100644 --- a/plugin_inspect.go +++ b/plugin_inspect.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_inspect_test.go b/plugin_inspect_test.go index df4ca9c841..fae407eb9b 100644 --- a/plugin_inspect_test.go +++ b/plugin_inspect_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_install.go b/plugin_install.go index 9ee32eea92..636c95364d 100644 --- a/plugin_install.go +++ b/plugin_install.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_list.go b/plugin_list.go index 48b470247b..88c480a3e1 100644 --- a/plugin_list.go +++ b/plugin_list.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_list_test.go b/plugin_list_test.go index 95c51595ca..173e4b87f5 100644 --- a/plugin_list_test.go +++ b/plugin_list_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_push.go b/plugin_push.go index 3afea5ed79..d83bbdc358 100644 --- a/plugin_push.go +++ b/plugin_push.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_push_test.go b/plugin_push_test.go index ed685694ec..efdbdc6db1 100644 --- a/plugin_push_test.go +++ b/plugin_push_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_remove.go b/plugin_remove.go index 1483f2854d..b017e4d348 100644 --- a/plugin_remove.go +++ b/plugin_remove.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_remove_test.go b/plugin_remove_test.go index fc789fd04d..a15f1661f6 100644 --- a/plugin_remove_test.go +++ b/plugin_remove_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_set.go b/plugin_set.go index fb40f38b22..3260d2a90d 100644 --- a/plugin_set.go +++ b/plugin_set.go @@ -1,5 +1,3 @@ -// +build experimental - package client import ( diff --git a/plugin_set_test.go b/plugin_set_test.go index fa1cde044e..2450254463 100644 --- a/plugin_set_test.go +++ b/plugin_set_test.go @@ -1,5 +1,3 @@ -// +build experimental - package client import (