mirror of https://github.com/docker/cli.git
Merge pull request #28595 from anusha-ragunathan/plugin_timeout
Allow HTTP client timeout to be configurable on plugin enable.
This commit is contained in:
commit
7cc80114de
|
@ -109,7 +109,7 @@ type NodeAPIClient interface {
|
||||||
type PluginAPIClient interface {
|
type PluginAPIClient interface {
|
||||||
PluginList(ctx context.Context) (types.PluginsListResponse, error)
|
PluginList(ctx context.Context) (types.PluginsListResponse, error)
|
||||||
PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) 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
|
PluginDisable(ctx context.Context, name string) error
|
||||||
PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) error
|
PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) error
|
||||||
PluginPush(ctx context.Context, name string, registryAuth string) error
|
PluginPush(ctx context.Context, name string, registryAuth string) error
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PluginEnable enables a plugin
|
// PluginEnable enables a plugin
|
||||||
func (cli *Client) PluginEnable(ctx context.Context, name string) error {
|
func (cli *Client) PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error {
|
||||||
resp, err := cli.post(ctx, "/plugins/"+name+"/enable", nil, nil, nil)
|
query := url.Values{}
|
||||||
|
query.Set("timeout", strconv.Itoa(options.Timeout))
|
||||||
|
|
||||||
|
resp, err := cli.post(ctx, "/plugins/"+name+"/enable", query, nil, nil)
|
||||||
ensureReaderClosed(resp)
|
ensureReaderClosed(resp)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ func TestPluginEnableError(t *testing.T) {
|
||||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
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" {
|
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||||
t.Fatalf("expected a Server Error, got %v", err)
|
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 {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (cli *Client) PluginInstall(ctx context.Context, name string, options types
|
||||||
return nil
|
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) {
|
func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) {
|
||||||
|
|
Loading…
Reference in New Issue