plugin_inspect.go 620 B

12345678910111213141516171819202122232425262728
  1. package client
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "io/ioutil"
  6. "github.com/docker/docker/api/types"
  7. "golang.org/x/net/context"
  8. )
  9. // PluginInspectWithRaw inspects an existing plugin
  10. func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) {
  11. resp, err := cli.get(ctx, "/plugins/"+name, nil, nil)
  12. if err != nil {
  13. return nil, nil, err
  14. }
  15. defer ensureReaderClosed(resp)
  16. body, err := ioutil.ReadAll(resp.body)
  17. if err != nil {
  18. return nil, nil, err
  19. }
  20. var p types.Plugin
  21. rdr := bytes.NewReader(body)
  22. err = json.NewDecoder(rdr).Decode(&p)
  23. return &p, body, err
  24. }