github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/plugin_create.go (about)

     1  package client
     2  
     3  import (
     4  	"io"
     5  	"net/http"
     6  	"net/url"
     7  
     8  	"github.com/docker/docker/api/types"
     9  	"golang.org/x/net/context"
    10  )
    11  
    12  // PluginCreate creates a plugin
    13  func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
    14  	headers := http.Header(make(map[string][]string))
    15  	headers.Set("Content-Type", "application/x-tar")
    16  
    17  	query := url.Values{}
    18  	query.Set("name", createOptions.RepoName)
    19  
    20  	resp, err := cli.postRaw(ctx, "/plugins/create", query, createContext, headers)
    21  	if err != nil {
    22  		return err
    23  	}
    24  	ensureReaderClosed(resp)
    25  	return err
    26  }