endpoint to post a new worker to the pool
This commit is contained in:
parent
962aa8e968
commit
33721e54aa
1 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/drone/drone/server/worker"
|
"github.com/drone/drone/server/worker"
|
||||||
"github.com/drone/drone/server/worker/director"
|
"github.com/drone/drone/server/worker/director"
|
||||||
|
"github.com/drone/drone/server/worker/docker"
|
||||||
"github.com/drone/drone/server/worker/pool"
|
"github.com/drone/drone/server/worker/pool"
|
||||||
"github.com/goji/context"
|
"github.com/goji/context"
|
||||||
"github.com/zenazn/goji/web"
|
"github.com/zenazn/goji/web"
|
||||||
|
@ -23,6 +24,19 @@ func GetWorkers(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(workers)
|
json.NewEncoder(w).Encode(workers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PostWorker accepts a request to allocate a new
|
||||||
|
// worker to the pool.
|
||||||
|
//
|
||||||
|
// POST /api/workers
|
||||||
|
//
|
||||||
|
func PostWorker(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||||
|
ctx := context.FromC(c)
|
||||||
|
workers := pool.FromContext(ctx)
|
||||||
|
node := r.FormValue("node")
|
||||||
|
workers.Allocate(docker.NewHost(node))
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
// GetWorkPending accepts a request to retrieve the list
|
// GetWorkPending accepts a request to retrieve the list
|
||||||
// of pending work and returns in JSON format.
|
// of pending work and returns in JSON format.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue