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>
| ... | ... |
@@ -150,6 +150,11 @@ type CommitConfig struct {
|
| 150 | 150 |
ParentImageID string |
| 151 | 151 |
} |
| 152 | 152 |
|
| 153 |
+// PluginCreateConfig hold all options to plugin create. |
|
| 154 |
+type PluginCreateConfig struct {
|
|
| 155 |
+ RepoName string |
|
| 156 |
+} |
|
| 157 |
+ |
|
| 153 | 158 |
// PluginRmConfig holds arguments for plugin remove. |
| 154 | 159 |
type PluginRmConfig struct {
|
| 155 | 160 |
ForceRemove bool |
| ... | ... |
@@ -156,7 +156,7 @@ type PluginAPIClient interface {
|
| 156 | 156 |
PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) |
| 157 | 157 |
PluginSet(ctx context.Context, name string, args []string) error |
| 158 | 158 |
PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) |
| 159 |
- PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error |
|
| 159 |
+ PluginCreate(ctx context.Context, createContext io.Reader, options PluginCreateOptions) error |
|
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
// ServiceAPIClient defines API client methods for the services |
| ... | ... |
@@ -5,12 +5,15 @@ import ( |
| 5 | 5 |
"io" |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"net/url" |
| 8 |
- |
|
| 9 |
- "github.com/moby/moby/api/types" |
|
| 10 | 8 |
) |
| 11 | 9 |
|
| 10 |
+// PluginCreateOptions hold all options to plugin create. |
|
| 11 |
+type PluginCreateOptions struct {
|
|
| 12 |
+ RepoName string |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 12 | 15 |
// PluginCreate creates a plugin |
| 13 |
-func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
|
| 16 |
+func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions PluginCreateOptions) error {
|
|
| 14 | 17 |
headers := http.Header(make(map[string][]string)) |
| 15 | 18 |
headers.Set("Content-Type", "application/x-tar")
|
| 16 | 19 |
|
| ... | ... |
@@ -626,7 +626,7 @@ func (pm *Manager) Set(name string, args []string) error {
|
| 626 | 626 |
|
| 627 | 627 |
// CreateFromContext creates a plugin from the given pluginDir which contains |
| 628 | 628 |
// both the rootfs and the config.json and a repoName with optional tag. |
| 629 |
-func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) (retErr error) {
|
|
| 629 |
+func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *backend.PluginCreateConfig) (retErr error) {
|
|
| 630 | 630 |
pm.muGC.RLock() |
| 631 | 631 |
defer pm.muGC.RUnlock() |
| 632 | 632 |
|
| ... | ... |
@@ -69,6 +69,6 @@ func (pm *Manager) Set(name string, args []string) error {
|
| 69 | 69 |
|
| 70 | 70 |
// CreateFromContext creates a plugin from the given pluginDir which contains |
| 71 | 71 |
// both the rootfs and the config.json and a repoName with optional tag. |
| 72 |
-func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) error {
|
|
| 72 |
+func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *backend.PluginCreateConfig) error {
|
|
| 73 | 73 |
return errNotSupported |
| 74 | 74 |
} |
| ... | ... |
@@ -25,5 +25,5 @@ type Backend interface {
|
| 25 | 25 |
Pull(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer, opts ...plugin.CreateOpt) error |
| 26 | 26 |
Push(ctx context.Context, name string, metaHeaders http.Header, authConfig *registry.AuthConfig, outStream io.Writer) error |
| 27 | 27 |
Upgrade(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) error |
| 28 |
- CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *types.PluginCreateOptions) error |
|
| 28 |
+ CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *backend.PluginCreateConfig) error |
|
| 29 | 29 |
} |
| ... | ... |
@@ -13,8 +13,10 @@ import ( |
| 13 | 13 |
registrypkg "github.com/docker/docker/daemon/pkg/registry" |
| 14 | 14 |
"github.com/moby/go-archive" |
| 15 | 15 |
"github.com/moby/moby/api/types" |
| 16 |
+ "github.com/moby/moby/api/types/backend" |
|
| 16 | 17 |
"github.com/moby/moby/api/types/events" |
| 17 | 18 |
"github.com/moby/moby/api/types/registry" |
| 19 |
+ "github.com/moby/moby/client" |
|
| 18 | 20 |
"github.com/pkg/errors" |
| 19 | 21 |
) |
| 20 | 22 |
|
| ... | ... |
@@ -49,7 +51,7 @@ func WithBinary(bin string) CreateOpt {
|
| 49 | 49 |
// CreateClient is the interface used for `BuildPlugin` to interact with the |
| 50 | 50 |
// daemon. |
| 51 | 51 |
type CreateClient interface {
|
| 52 |
- PluginCreate(context.Context, io.Reader, types.PluginCreateOptions) error |
|
| 52 |
+ PluginCreate(context.Context, io.Reader, client.PluginCreateOptions) error |
|
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 | 55 |
// Create creates a new plugin with the specified name |
| ... | ... |
@@ -69,7 +71,7 @@ func Create(ctx context.Context, c CreateClient, name string, opts ...CreateOpt) |
| 69 | 69 |
ctx, cancel := context.WithTimeout(ctx, 30*time.Second) |
| 70 | 70 |
defer cancel() |
| 71 | 71 |
|
| 72 |
- return c.PluginCreate(ctx, tar, types.PluginCreateOptions{RepoName: name})
|
|
| 72 |
+ return c.PluginCreate(ctx, tar, client.PluginCreateOptions{RepoName: name})
|
|
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 | 75 |
// CreateInRegistry makes a plugin (locally) and pushes it to a registry. |
| ... | ... |
@@ -127,7 +129,7 @@ func CreateInRegistry(ctx context.Context, repo string, auth *registry.AuthConfi |
| 127 | 127 |
|
| 128 | 128 |
ctx, cancel := context.WithTimeout(ctx, 30*time.Second) |
| 129 | 129 |
defer cancel() |
| 130 |
- if err := manager.CreateFromContext(ctx, tar, &types.PluginCreateOptions{RepoName: repo}); err != nil {
|
|
| 130 |
+ if err := manager.CreateFromContext(ctx, tar, &backend.PluginCreateConfig{RepoName: repo}); err != nil {
|
|
| 131 | 131 |
return err |
| 132 | 132 |
} |
| 133 | 133 |
|
| ... | ... |
@@ -150,6 +150,11 @@ type CommitConfig struct {
|
| 150 | 150 |
ParentImageID string |
| 151 | 151 |
} |
| 152 | 152 |
|
| 153 |
+// PluginCreateConfig hold all options to plugin create. |
|
| 154 |
+type PluginCreateConfig struct {
|
|
| 155 |
+ RepoName string |
|
| 156 |
+} |
|
| 157 |
+ |
|
| 153 | 158 |
// PluginRmConfig holds arguments for plugin remove. |
| 154 | 159 |
type PluginRmConfig struct {
|
| 155 | 160 |
ForceRemove bool |
| ... | ... |
@@ -156,7 +156,7 @@ type PluginAPIClient interface {
|
| 156 | 156 |
PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) |
| 157 | 157 |
PluginSet(ctx context.Context, name string, args []string) error |
| 158 | 158 |
PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) |
| 159 |
- PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error |
|
| 159 |
+ PluginCreate(ctx context.Context, createContext io.Reader, options PluginCreateOptions) error |
|
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
// ServiceAPIClient defines API client methods for the services |
| ... | ... |
@@ -5,12 +5,15 @@ import ( |
| 5 | 5 |
"io" |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"net/url" |
| 8 |
- |
|
| 9 |
- "github.com/moby/moby/api/types" |
|
| 10 | 8 |
) |
| 11 | 9 |
|
| 10 |
+// PluginCreateOptions hold all options to plugin create. |
|
| 11 |
+type PluginCreateOptions struct {
|
|
| 12 |
+ RepoName string |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 12 | 15 |
// PluginCreate creates a plugin |
| 13 |
-func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
|
| 16 |
+func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions PluginCreateOptions) error {
|
|
| 14 | 17 |
headers := http.Header(make(map[string][]string)) |
| 15 | 18 |
headers.Set("Content-Type", "application/x-tar")
|
| 16 | 19 |
|