mirror of https://github.com/docker/cli.git
Add HTTP client timeout.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This commit is contained in:
parent
20ded0afd9
commit
43e89b5387
|
@ -109,7 +109,7 @@ type NodeAPIClient interface {
|
|||
type PluginAPIClient interface {
|
||||
PluginList(ctx context.Context) (types.PluginsListResponse, error)
|
||||
PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error
|
||||
PluginEnable(ctx context.Context, name string) error
|
||||
PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error
|
||||
PluginDisable(ctx context.Context, name string) error
|
||||
PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) error
|
||||
PluginPush(ctx context.Context, name string, registryAuth string) error
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// PluginEnable enables a plugin
|
||||
func (cli *Client) PluginEnable(ctx context.Context, name string) error {
|
||||
resp, err := cli.post(ctx, "/plugins/"+name+"/enable", nil, nil, nil)
|
||||
func (cli *Client) PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error {
|
||||
query := url.Values{}
|
||||
query.Set("timeout", strconv.Itoa(options.Timeout))
|
||||
|
||||
resp, err := cli.post(ctx, "/plugins/"+name+"/enable", query, nil, nil)
|
||||
ensureReaderClosed(resp)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -16,7 +17,7 @@ func TestPluginEnableError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
|
||||
err := client.PluginEnable(context.Background(), "plugin_name")
|
||||
err := client.PluginEnable(context.Background(), "plugin_name", types.PluginEnableOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ func TestPluginEnable(t *testing.T) {
|
|||
}),
|
||||
}
|
||||
|
||||
err := client.PluginEnable(context.Background(), "plugin_name")
|
||||
err := client.PluginEnable(context.Background(), "plugin_name", types.PluginEnableOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types
|
|||
return nil
|
||||
}
|
||||
|
||||
return cli.PluginEnable(ctx, name)
|
||||
return cli.PluginEnable(ctx, name, types.PluginEnableOptions{Timeout: 0})
|
||||
}
|
||||
|
||||
func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) {
|
||||
|
|
Loading…
Reference in New Issue