These structs are intended for internal use only for the backend, and are
not intended to be used externally.
This moves the plugin-related `PluginRmConfig`, `PluginEnableConfig`, and
`PluginDisableConfig` types to the backend package to prevent them being
imported in the client, and to make it more clear that this is part of
internal APIs, and not public-facing.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"github.com/distribution/reference" |
| 9 | 9 |
"github.com/docker/docker/api/types" |
| 10 |
+ "github.com/docker/docker/api/types/backend" |
|
| 10 | 11 |
"github.com/docker/docker/api/types/filters" |
| 11 | 12 |
"github.com/docker/docker/api/types/registry" |
| 12 | 13 |
"github.com/docker/docker/plugin" |
| ... | ... |
@@ -14,11 +15,11 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
// Backend for Plugin |
| 16 | 16 |
type Backend interface {
|
| 17 |
- Disable(name string, config *types.PluginDisableConfig) error |
|
| 18 |
- Enable(name string, config *types.PluginEnableConfig) error |
|
| 17 |
+ Disable(name string, config *backend.PluginDisableConfig) error |
|
| 18 |
+ Enable(name string, config *backend.PluginEnableConfig) error |
|
| 19 | 19 |
List(filters.Args) ([]types.Plugin, error) |
| 20 | 20 |
Inspect(name string) (*types.Plugin, error) |
| 21 |
- Remove(name string, config *types.PluginRmConfig) error |
|
| 21 |
+ Remove(name string, config *backend.PluginRmConfig) error |
|
| 22 | 22 |
Set(name string, args []string) error |
| 23 | 23 |
Privileges(ctx context.Context, ref reference.Named, metaHeaders http.Header, authConfig *registry.AuthConfig) (types.PluginPrivileges, error) |
| 24 | 24 |
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 |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"github.com/distribution/reference" |
| 10 | 10 |
"github.com/docker/docker/api/server/httputils" |
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 |
+ "github.com/docker/docker/api/types/backend" |
|
| 12 | 13 |
"github.com/docker/docker/api/types/filters" |
| 13 | 14 |
"github.com/docker/docker/api/types/registry" |
| 14 | 15 |
"github.com/docker/docker/pkg/ioutils" |
| ... | ... |
@@ -207,7 +208,7 @@ func (pr *pluginRouter) enablePlugin(ctx context.Context, w http.ResponseWriter, |
| 207 | 207 |
if err != nil {
|
| 208 | 208 |
return err |
| 209 | 209 |
} |
| 210 |
- config := &types.PluginEnableConfig{Timeout: timeout}
|
|
| 210 |
+ config := &backend.PluginEnableConfig{Timeout: timeout}
|
|
| 211 | 211 |
|
| 212 | 212 |
return pr.backend.Enable(name, config) |
| 213 | 213 |
} |
| ... | ... |
@@ -218,7 +219,7 @@ func (pr *pluginRouter) disablePlugin(ctx context.Context, w http.ResponseWriter |
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 | 220 |
name := vars["name"] |
| 221 |
- config := &types.PluginDisableConfig{
|
|
| 221 |
+ config := &backend.PluginDisableConfig{
|
|
| 222 | 222 |
ForceDisable: httputils.BoolValue(r, "force"), |
| 223 | 223 |
} |
| 224 | 224 |
|
| ... | ... |
@@ -231,7 +232,7 @@ func (pr *pluginRouter) removePlugin(ctx context.Context, w http.ResponseWriter, |
| 231 | 231 |
} |
| 232 | 232 |
|
| 233 | 233 |
name := vars["name"] |
| 234 |
- config := &types.PluginRmConfig{
|
|
| 234 |
+ config := &backend.PluginRmConfig{
|
|
| 235 | 235 |
ForceRemove: httputils.BoolValue(r, "force"), |
| 236 | 236 |
} |
| 237 | 237 |
return pr.backend.Remove(name, config) |
| ... | ... |
@@ -141,3 +141,18 @@ type CommitConfig struct {
|
| 141 | 141 |
ContainerOS string |
| 142 | 142 |
ParentImageID string |
| 143 | 143 |
} |
| 144 |
+ |
|
| 145 |
+// PluginRmConfig holds arguments for plugin remove. |
|
| 146 |
+type PluginRmConfig struct {
|
|
| 147 |
+ ForceRemove bool |
|
| 148 |
+} |
|
| 149 |
+ |
|
| 150 |
+// PluginEnableConfig holds arguments for plugin enable |
|
| 151 |
+type PluginEnableConfig struct {
|
|
| 152 |
+ Timeout int |
|
| 153 |
+} |
|
| 154 |
+ |
|
| 155 |
+// PluginDisableConfig holds arguments for plugin disable. |
|
| 156 |
+type PluginDisableConfig struct {
|
|
| 157 |
+ ForceDisable bool |
|
| 158 |
+} |
| ... | ... |
@@ -21,21 +21,6 @@ type ExecConfig struct {
|
| 21 | 21 |
Cmd []string // Execution commands and args |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
-// PluginRmConfig holds arguments for plugin remove. |
|
| 25 |
-type PluginRmConfig struct {
|
|
| 26 |
- ForceRemove bool |
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 |
-// PluginEnableConfig holds arguments for plugin enable |
|
| 30 |
-type PluginEnableConfig struct {
|
|
| 31 |
- Timeout int |
|
| 32 |
-} |
|
| 33 |
- |
|
| 34 |
-// PluginDisableConfig holds arguments for plugin disable. |
|
| 35 |
-type PluginDisableConfig struct {
|
|
| 36 |
- ForceDisable bool |
|
| 37 |
-} |
|
| 38 |
- |
|
| 39 | 24 |
// NetworkListConfig stores the options available for listing networks |
| 40 | 25 |
type NetworkListConfig struct {
|
| 41 | 26 |
// TODO(@cpuguy83): naming is hard, this is pulled from what was being used in the router before moving here |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"github.com/containerd/log" |
| 9 | 9 |
"github.com/distribution/reference" |
| 10 | 10 |
"github.com/docker/docker/api/types" |
| 11 |
+ "github.com/docker/docker/api/types/backend" |
|
| 11 | 12 |
"github.com/docker/docker/api/types/registry" |
| 12 | 13 |
"github.com/docker/docker/api/types/swarm/runtime" |
| 13 | 14 |
"github.com/docker/docker/errdefs" |
| ... | ... |
@@ -42,9 +43,9 @@ type Controller struct {
|
| 42 | 42 |
// Backend is the interface for interacting with the plugin manager |
| 43 | 43 |
// Controller actions are passed to the configured backend to do the real work. |
| 44 | 44 |
type Backend interface {
|
| 45 |
- Disable(name string, config *types.PluginDisableConfig) error |
|
| 46 |
- Enable(name string, config *types.PluginEnableConfig) error |
|
| 47 |
- Remove(name string, config *types.PluginRmConfig) error |
|
| 45 |
+ Disable(name string, config *backend.PluginDisableConfig) error |
|
| 46 |
+ Enable(name string, config *backend.PluginEnableConfig) error |
|
| 47 |
+ Remove(name string, config *backend.PluginRmConfig) error |
|
| 48 | 48 |
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 |
| 49 | 49 |
Upgrade(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *registry.AuthConfig, privileges types.PluginPrivileges, outStream io.Writer) error |
| 50 | 50 |
Get(name string) (*v2.Plugin, error) |
| ... | ... |
@@ -114,7 +115,7 @@ func (p *Controller) Prepare(ctx context.Context) (err error) {
|
| 114 | 114 |
return errors.Errorf("plugin already exists: %s", p.spec.Name)
|
| 115 | 115 |
} |
| 116 | 116 |
if pl.IsEnabled() {
|
| 117 |
- if err := p.backend.Disable(pl.GetID(), &types.PluginDisableConfig{ForceDisable: true}); err != nil {
|
|
| 117 |
+ if err := p.backend.Disable(pl.GetID(), &backend.PluginDisableConfig{ForceDisable: true}); err != nil {
|
|
| 118 | 118 |
p.logger.WithError(err).Debug("could not disable plugin before running upgrade")
|
| 119 | 119 |
} |
| 120 | 120 |
} |
| ... | ... |
@@ -145,12 +146,12 @@ func (p *Controller) Start(ctx context.Context) error {
|
| 145 | 145 |
|
| 146 | 146 |
if p.spec.Disabled {
|
| 147 | 147 |
if pl.IsEnabled() {
|
| 148 |
- return p.backend.Disable(p.pluginID, &types.PluginDisableConfig{ForceDisable: false})
|
|
| 148 |
+ return p.backend.Disable(p.pluginID, &backend.PluginDisableConfig{ForceDisable: false})
|
|
| 149 | 149 |
} |
| 150 | 150 |
return nil |
| 151 | 151 |
} |
| 152 | 152 |
if !pl.IsEnabled() {
|
| 153 |
- return p.backend.Enable(p.pluginID, &types.PluginEnableConfig{Timeout: 30})
|
|
| 153 |
+ return p.backend.Enable(p.pluginID, &backend.PluginEnableConfig{Timeout: 30})
|
|
| 154 | 154 |
} |
| 155 | 155 |
return nil |
| 156 | 156 |
} |
| ... | ... |
@@ -234,7 +235,7 @@ func (p *Controller) Remove(ctx context.Context) error {
|
| 234 | 234 |
|
| 235 | 235 |
// This may error because we have exactly 1 plugin, but potentially multiple |
| 236 | 236 |
// tasks which are calling remove. |
| 237 |
- err = p.backend.Remove(p.pluginID, &types.PluginRmConfig{ForceRemove: true})
|
|
| 237 |
+ err = p.backend.Remove(p.pluginID, &backend.PluginRmConfig{ForceRemove: true})
|
|
| 238 | 238 |
if isNotFound(err) {
|
| 239 | 239 |
return nil |
| 240 | 240 |
} |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/containerd/log" |
| 13 | 13 |
"github.com/distribution/reference" |
| 14 | 14 |
"github.com/docker/docker/api/types" |
| 15 |
+ "github.com/docker/docker/api/types/backend" |
|
| 15 | 16 |
"github.com/docker/docker/api/types/registry" |
| 16 | 17 |
"github.com/docker/docker/api/types/swarm/runtime" |
| 17 | 18 |
"github.com/docker/docker/plugin" |
| ... | ... |
@@ -343,19 +344,19 @@ type mockBackend struct {
|
| 343 | 343 |
pub *pubsub.Publisher |
| 344 | 344 |
} |
| 345 | 345 |
|
| 346 |
-func (m *mockBackend) Disable(name string, config *types.PluginDisableConfig) error {
|
|
| 346 |
+func (m *mockBackend) Disable(name string, config *backend.PluginDisableConfig) error {
|
|
| 347 | 347 |
m.p.PluginObj.Enabled = false |
| 348 | 348 |
m.pub.Publish(plugin.EventDisable{})
|
| 349 | 349 |
return nil |
| 350 | 350 |
} |
| 351 | 351 |
|
| 352 |
-func (m *mockBackend) Enable(name string, config *types.PluginEnableConfig) error {
|
|
| 352 |
+func (m *mockBackend) Enable(name string, config *backend.PluginEnableConfig) error {
|
|
| 353 | 353 |
m.p.PluginObj.Enabled = true |
| 354 | 354 |
m.pub.Publish(plugin.EventEnable{})
|
| 355 | 355 |
return nil |
| 356 | 356 |
} |
| 357 | 357 |
|
| 358 |
-func (m *mockBackend) Remove(name string, config *types.PluginRmConfig) error {
|
|
| 358 |
+func (m *mockBackend) Remove(name string, config *backend.PluginRmConfig) error {
|
|
| 359 | 359 |
m.p = nil |
| 360 | 360 |
m.pub.Publish(plugin.EventRemove{})
|
| 361 | 361 |
return nil |
| ... | ... |
@@ -23,6 +23,7 @@ import ( |
| 23 | 23 |
"github.com/distribution/reference" |
| 24 | 24 |
"github.com/docker/distribution/manifest/schema2" |
| 25 | 25 |
"github.com/docker/docker/api/types" |
| 26 |
+ "github.com/docker/docker/api/types/backend" |
|
| 26 | 27 |
"github.com/docker/docker/api/types/events" |
| 27 | 28 |
"github.com/docker/docker/api/types/filters" |
| 28 | 29 |
"github.com/docker/docker/api/types/registry" |
| ... | ... |
@@ -47,7 +48,7 @@ var acceptedPluginFilterTags = map[string]bool{
|
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 | 49 |
// Disable deactivates a plugin. This means resources (volumes, networks) cant use them. |
| 50 |
-func (pm *Manager) Disable(refOrID string, config *types.PluginDisableConfig) error {
|
|
| 50 |
+func (pm *Manager) Disable(refOrID string, config *backend.PluginDisableConfig) error {
|
|
| 51 | 51 |
p, err := pm.config.Store.GetV2Plugin(refOrID) |
| 52 | 52 |
if err != nil {
|
| 53 | 53 |
return err |
| ... | ... |
@@ -75,7 +76,7 @@ func (pm *Manager) Disable(refOrID string, config *types.PluginDisableConfig) er |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 | 77 |
// Enable activates a plugin, which implies that they are ready to be used by containers. |
| 78 |
-func (pm *Manager) Enable(refOrID string, config *types.PluginEnableConfig) error {
|
|
| 78 |
+func (pm *Manager) Enable(refOrID string, config *backend.PluginEnableConfig) error {
|
|
| 79 | 79 |
p, err := pm.config.Store.GetV2Plugin(refOrID) |
| 80 | 80 |
if err != nil {
|
| 81 | 81 |
return err |
| ... | ... |
@@ -559,7 +560,7 @@ func writeManifest(ctx context.Context, cs content.Store, m *manifest) (ocispec. |
| 559 | 559 |
} |
| 560 | 560 |
|
| 561 | 561 |
// Remove deletes plugin's root directory. |
| 562 |
-func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error {
|
|
| 562 |
+func (pm *Manager) Remove(name string, config *backend.PluginRmConfig) error {
|
|
| 563 | 563 |
p, err := pm.config.Store.GetV2Plugin(name) |
| 564 | 564 |
pm.mu.RLock() |
| 565 | 565 |
c := pm.cMap[p] |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"github.com/distribution/reference" |
| 12 | 12 |
"github.com/docker/docker/api/types" |
| 13 |
+ "github.com/docker/docker/api/types/backend" |
|
| 13 | 14 |
"github.com/docker/docker/api/types/filters" |
| 14 | 15 |
"github.com/docker/docker/api/types/registry" |
| 15 | 16 |
) |
| ... | ... |
@@ -17,12 +18,12 @@ import ( |
| 17 | 17 |
var errNotSupported = errors.New("plugins are not supported on this platform")
|
| 18 | 18 |
|
| 19 | 19 |
// Disable deactivates a plugin, which implies that they cannot be used by containers. |
| 20 |
-func (pm *Manager) Disable(name string, config *types.PluginDisableConfig) error {
|
|
| 20 |
+func (pm *Manager) Disable(name string, config *backend.PluginDisableConfig) error {
|
|
| 21 | 21 |
return errNotSupported |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 | 24 |
// Enable activates a plugin, which implies that they are ready to be used by containers. |
| 25 |
-func (pm *Manager) Enable(name string, config *types.PluginEnableConfig) error {
|
|
| 25 |
+func (pm *Manager) Enable(name string, config *backend.PluginEnableConfig) error {
|
|
| 26 | 26 |
return errNotSupported |
| 27 | 27 |
} |
| 28 | 28 |
|
| ... | ... |
@@ -57,7 +58,7 @@ func (pm *Manager) Push(ctx context.Context, name string, metaHeader http.Header |
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 | 59 |
// Remove deletes plugin's root directory. |
| 60 |
-func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error {
|
|
| 60 |
+func (pm *Manager) Remove(name string, config *backend.PluginRmConfig) error {
|
|
| 61 | 61 |
return errNotSupported |
| 62 | 62 |
} |
| 63 | 63 |
|
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"testing" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/api/types" |
| 12 |
+ "github.com/docker/docker/api/types/backend" |
|
| 12 | 13 |
"github.com/docker/docker/api/types/events" |
| 13 | 14 |
"github.com/docker/docker/pkg/containerfs" |
| 14 | 15 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -63,7 +64,7 @@ func TestManagerWithPluginMounts(t *testing.T) {
|
| 63 | 63 |
t.Fatal(err) |
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 |
- if err := m.Remove(p1.GetID(), &types.PluginRmConfig{ForceRemove: true}); err != nil {
|
|
| 66 |
+ if err := m.Remove(p1.GetID(), &backend.PluginRmConfig{ForceRemove: true}); err != nil {
|
|
| 67 | 67 |
t.Fatal(err) |
| 68 | 68 |
} |
| 69 | 69 |
if mounted, err := mountinfo.Mounted(p2Mount); !mounted || err != nil {
|
| ... | ... |
@@ -127,7 +128,7 @@ func TestCreateFailed(t *testing.T) {
|
| 127 | 127 |
t.Fatalf("expected Create failed error, got %v", err)
|
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 |
- if err := m.Remove(p.GetID(), &types.PluginRmConfig{ForceRemove: true}); err != nil {
|
|
| 130 |
+ if err := m.Remove(p.GetID(), &backend.PluginRmConfig{ForceRemove: true}); err != nil {
|
|
| 131 | 131 |
t.Fatal(err) |
| 132 | 132 |
} |
| 133 | 133 |
} |