mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
534a90a993
As described in our ROADMAP.md, introduce new Swarm management API endpoints relying on swarmkit to deploy services. It currently vendors docker/engine-api changes. This PR is fully backward compatible (joining a Swarm is an optional feature of the Engine, and existing commands are not impacted). Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> Signed-off-by: Victor Vieux <vieux@docker.com> Signed-off-by: Daniel Nephin <dnephin@docker.com> Signed-off-by: Jana Radhakrishnan <mrjana@docker.com> Signed-off-by: Madhu Venugopal <madhu@docker.com>
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package swarm
|
|
|
|
import "github.com/docker/docker/api/server/router"
|
|
|
|
// buildRouter is a router to talk with the build controller
|
|
type swarmRouter struct {
|
|
backend Backend
|
|
routes []router.Route
|
|
}
|
|
|
|
// NewRouter initializes a new build router
|
|
func NewRouter(b Backend) router.Router {
|
|
r := &swarmRouter{
|
|
backend: b,
|
|
}
|
|
r.initRoutes()
|
|
return r
|
|
}
|
|
|
|
// Routes returns the available routers to the swarm controller
|
|
func (sr *swarmRouter) Routes() []router.Route {
|
|
return sr.routes
|
|
}
|
|
|
|
func (sr *swarmRouter) initRoutes() {
|
|
sr.routes = []router.Route{
|
|
router.NewPostRoute("/swarm/init", sr.initCluster),
|
|
router.NewPostRoute("/swarm/join", sr.joinCluster),
|
|
router.NewPostRoute("/swarm/leave", sr.leaveCluster),
|
|
router.NewGetRoute("/swarm", sr.inspectCluster),
|
|
router.NewPostRoute("/swarm/update", sr.updateCluster),
|
|
router.NewGetRoute("/services", sr.getServices),
|
|
router.NewGetRoute("/services/{id:.*}", sr.getService),
|
|
router.NewPostRoute("/services/create", sr.createService),
|
|
router.NewPostRoute("/services/{id:.*}/update", sr.updateService),
|
|
router.NewDeleteRoute("/services/{id:.*}", sr.removeService),
|
|
router.NewGetRoute("/nodes", sr.getNodes),
|
|
router.NewGetRoute("/nodes/{id:.*}", sr.getNode),
|
|
router.NewDeleteRoute("/nodes/{id:.*}", sr.removeNode),
|
|
router.NewPostRoute("/nodes/{id:.*}/update", sr.updateNode),
|
|
router.NewGetRoute("/tasks", sr.getTasks),
|
|
router.NewGetRoute("/tasks/{id:.*}", sr.getTask),
|
|
}
|
|
}
|