plugin_inspect.go 731 B

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