code: func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (rc io.ReadCloser, err error) {
  	query := url.Values{}
  	if _, err := reference.ParseNormalizedNamed(options.RemoteRef); err != nil {
  		return nil, errors.Wrap(err, "invalid remote reference")
  	}
  	query.Set("remote", options.RemoteRef)
  
  	privileges, err := cli.checkPluginPermissions(ctx, query, options)
  	if err != nil {
  		return nil, err
  	}
  
  	// set name for plugin pull, if empty should default to remote reference
  	query.Set("name", name)
  
  	resp, err := cli.tryPluginPull(ctx, query, privileges, options.RegistryAuth)
  	if err != nil {
  		return nil, err
  	}
  
  	name = resp.header.Get("Docker-Plugin-Name")
  
  	pr, pw := io.Pipe()
  	go func() { // todo: the client should probably be designed more around the actual api
  		_, err := io.Copy(pw, resp.body)
  		if err != nil {
  			pw.CloseWithError(err)
  			return
  		}
  		defer func() {
  			if err != nil {
  				delResp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil)
  				ensureReaderClosed(delResp)
  			}
  		}()
  		if len(options.Args) > 0 {
  			if err := cli.PluginSet(ctx, name, options.Args); err != nil {
  				pw.CloseWithError(err)
  				return
  			}
  		}
  
  		if options.Disabled {
  			pw.Close()
  			return
  		}
  
  		enableErr := cli.PluginEnable(ctx, name, types.PluginEnableOptions{Timeout: 0})
  		pw.CloseWithError(enableErr)
  	}()
  	return pr, nil
  }
docs: // PluginInstall installs a plugin