mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
While it is imported by both the client and the daemon, values of the PluginCreateOptions struct are not marshaled or unmarshaled. The only field is mapped to and from an HTTP query parameter. Furthermore, this options type is the odd one out: the daemon uses types in api/types/backend to pass options around for the other plugin lifecycle operations. Move the PluginCreateOptions type into client, and define a new PluginCreateConfig struct in api/types/backend for the daemon to use alongside PluginRmConfig, PluginEnableConfig and PluginDisableConfig. Signed-off-by: Cory Snider <csnider@mirantis.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
27 lines
624 B
Go
27 lines
624 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
// PluginCreateOptions hold all options to plugin create.
|
|
type PluginCreateOptions struct {
|
|
RepoName string
|
|
}
|
|
|
|
// PluginCreate creates a plugin
|
|
func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions PluginCreateOptions) error {
|
|
headers := http.Header(make(map[string][]string))
|
|
headers.Set("Content-Type", "application/x-tar")
|
|
|
|
query := url.Values{}
|
|
query.Set("name", createOptions.RepoName)
|
|
|
|
resp, err := cli.postRaw(ctx, "/plugins/create", query, createContext, headers)
|
|
ensureReaderClosed(resp)
|
|
return err
|
|
}
|