mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
03c6949739
This allows a plugin to be upgraded without requiring to uninstall/reinstall a plugin. Since plugin resources (e.g. volumes) are tied to a plugin ID, this is important to ensure resources aren't lost. The plugin must be disabled while upgrading (errors out if enabled). This does not add any convenience flags for automatically disabling/re-enabling the plugin during before/after upgrade. Since an upgrade may change requested permissions, the user is required to accept permissions just like `docker plugin install`. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package plugin
|
|
|
|
import "github.com/docker/docker/api/server/router"
|
|
|
|
// pluginRouter is a router to talk with the plugin controller
|
|
type pluginRouter struct {
|
|
backend Backend
|
|
routes []router.Route
|
|
}
|
|
|
|
// NewRouter initializes a new plugin router
|
|
func NewRouter(b Backend) router.Router {
|
|
r := &pluginRouter{
|
|
backend: b,
|
|
}
|
|
r.initRoutes()
|
|
return r
|
|
}
|
|
|
|
// Routes returns the available routers to the plugin controller
|
|
func (r *pluginRouter) Routes() []router.Route {
|
|
return r.routes
|
|
}
|
|
|
|
func (r *pluginRouter) initRoutes() {
|
|
r.routes = []router.Route{
|
|
router.NewGetRoute("/plugins", r.listPlugins),
|
|
router.NewGetRoute("/plugins/{name:.*}/json", r.inspectPlugin),
|
|
router.NewGetRoute("/plugins/privileges", r.getPrivileges),
|
|
router.NewDeleteRoute("/plugins/{name:.*}", r.removePlugin),
|
|
router.NewPostRoute("/plugins/{name:.*}/enable", r.enablePlugin), // PATCH?
|
|
router.NewPostRoute("/plugins/{name:.*}/disable", r.disablePlugin),
|
|
router.Cancellable(router.NewPostRoute("/plugins/pull", r.pullPlugin)),
|
|
router.Cancellable(router.NewPostRoute("/plugins/{name:.*}/push", r.pushPlugin)),
|
|
router.Cancellable(router.NewPostRoute("/plugins/{name:.*}/upgrade", r.upgradePlugin)),
|
|
router.NewPostRoute("/plugins/{name:.*}/set", r.setPlugin),
|
|
router.NewPostRoute("/plugins/create", r.createPlugin),
|
|
}
|
|
}
|