зеркало из https://github.com/docker/engine-api.git
Merge pull request #376 from vieux/plugin_inspect
add -f to plugin inspect
This commit is contained in:
Коммит
b66d7d91db
|
@ -30,7 +30,7 @@ type PluginAPIClient interface {
|
|||
PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) error
|
||||
PluginPush(ctx context.Context, name string, registryAuth string) error
|
||||
PluginSet(ctx context.Context, name string, args []string) error
|
||||
PluginInspect(ctx context.Context, name string) (*types.Plugin, error)
|
||||
PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
|
||||
}
|
||||
|
||||
// Ensure that Client always implements APIClient.
|
||||
|
|
|
@ -3,20 +3,28 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/docker/engine-api/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// PluginInspect inspects an existing plugin
|
||||
func (cli *Client) PluginInspect(ctx context.Context, name string) (*types.Plugin, error) {
|
||||
var p types.Plugin
|
||||
func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) {
|
||||
resp, err := cli.get(ctx, "/plugins/"+name, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
err = json.NewDecoder(resp.body).Decode(&p)
|
||||
ensureReaderClosed(resp)
|
||||
return &p, err
|
||||
|
||||
defer ensureReaderClosed(resp)
|
||||
body, err := ioutil.ReadAll(resp.body)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
var p types.Plugin
|
||||
rdr := bytes.NewReader(body)
|
||||
err = json.NewDecoder(rdr).Decode(&p)
|
||||
return &p, body, err
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestPluginInspectError(t *testing.T) {
|
|||
transport: newMockClient(nil, errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
|
||||
_, err := client.PluginInspect(context.Background(), "nothing")
|
||||
_, _, err := client.PluginInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func TestPluginInspect(t *testing.T) {
|
|||
}),
|
||||
}
|
||||
|
||||
pluginInspect, err := client.PluginInspect(context.Background(), "plugin_name")
|
||||
pluginInspect, _, err := client.PluginInspectWithRaw(context.Background(), "plugin_name")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче