github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/client/plugin_inspect.go (about)

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