2016-06-13 22:52:49 -04:00
|
|
|
package swarm
|
|
|
|
|
2016-11-16 20:58:06 -05:00
|
|
|
import "github.com/docker/docker/api/server/router"
|
2016-06-13 22:52:49 -04:00
|
|
|
|
2016-11-10 21:45:48 -05:00
|
|
|
// swarmRouter is a router to talk with the build controller
|
2016-06-13 22:52:49 -04:00
|
|
|
type swarmRouter struct {
|
|
|
|
backend Backend
|
|
|
|
routes []router.Route
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewRouter initializes a new build router
|
2016-11-16 20:58:06 -05:00
|
|
|
func NewRouter(b Backend) router.Router {
|
2016-06-13 22:52:49 -04:00
|
|
|
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),
|
2016-10-27 21:50:49 -04:00
|
|
|
router.NewGetRoute("/swarm/unlockkey", sr.getUnlockKey),
|
2016-06-13 22:52:49 -04:00
|
|
|
router.NewPostRoute("/swarm/update", sr.updateCluster),
|
2016-10-21 21:07:55 -04:00
|
|
|
router.NewPostRoute("/swarm/unlock", sr.unlockCluster),
|
2017-03-15 17:52:17 -04:00
|
|
|
|
2016-06-13 22:52:49 -04:00
|
|
|
router.NewGetRoute("/services", sr.getServices),
|
2016-10-26 04:17:31 -04:00
|
|
|
router.NewGetRoute("/services/{id}", sr.getService),
|
2016-06-13 22:52:49 -04:00
|
|
|
router.NewPostRoute("/services/create", sr.createService),
|
2016-10-26 04:17:31 -04:00
|
|
|
router.NewPostRoute("/services/{id}/update", sr.updateService),
|
|
|
|
router.NewDeleteRoute("/services/{id}", sr.removeService),
|
2017-04-10 21:14:36 -04:00
|
|
|
router.NewGetRoute("/services/{id}/logs", sr.getServiceLogs, router.WithCancel),
|
2017-03-15 17:52:17 -04:00
|
|
|
|
2016-06-13 22:52:49 -04:00
|
|
|
router.NewGetRoute("/nodes", sr.getNodes),
|
2016-10-26 04:17:31 -04:00
|
|
|
router.NewGetRoute("/nodes/{id}", sr.getNode),
|
|
|
|
router.NewDeleteRoute("/nodes/{id}", sr.removeNode),
|
|
|
|
router.NewPostRoute("/nodes/{id}/update", sr.updateNode),
|
2017-03-15 17:52:17 -04:00
|
|
|
|
2016-06-13 22:52:49 -04:00
|
|
|
router.NewGetRoute("/tasks", sr.getTasks),
|
2016-10-26 04:17:31 -04:00
|
|
|
router.NewGetRoute("/tasks/{id}", sr.getTask),
|
2017-04-10 21:14:36 -04:00
|
|
|
router.NewGetRoute("/tasks/{id}/logs", sr.getTaskLogs, router.WithCancel),
|
2017-03-15 17:52:17 -04:00
|
|
|
|
2016-10-19 12:22:02 -04:00
|
|
|
router.NewGetRoute("/secrets", sr.getSecrets),
|
2016-11-16 21:51:16 -05:00
|
|
|
router.NewPostRoute("/secrets/create", sr.createSecret),
|
2016-10-26 04:17:31 -04:00
|
|
|
router.NewDeleteRoute("/secrets/{id}", sr.removeSecret),
|
|
|
|
router.NewGetRoute("/secrets/{id}", sr.getSecret),
|
|
|
|
router.NewPostRoute("/secrets/{id}/update", sr.updateSecret),
|
2017-03-15 17:52:17 -04:00
|
|
|
|
|
|
|
router.NewGetRoute("/configs", sr.getConfigs),
|
|
|
|
router.NewPostRoute("/configs/create", sr.createConfig),
|
|
|
|
router.NewDeleteRoute("/configs/{id}", sr.removeConfig),
|
|
|
|
router.NewGetRoute("/configs/{id}", sr.getConfig),
|
|
|
|
router.NewPostRoute("/configs/{id}/update", sr.updateConfig),
|
2016-06-13 22:52:49 -04:00
|
|
|
}
|
|
|
|
}
|