From 33721e54aaec914f9e2240f2ef4f5bb77c635061 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Wed, 8 Oct 2014 21:44:43 -0700 Subject: [PATCH] endpoint to post a new worker to the pool --- server/handler/worker.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/handler/worker.go b/server/handler/worker.go index 09e4d3cc..c8b7cd77 100644 --- a/server/handler/worker.go +++ b/server/handler/worker.go @@ -6,6 +6,7 @@ import ( "github.com/drone/drone/server/worker" "github.com/drone/drone/server/worker/director" + "github.com/drone/drone/server/worker/docker" "github.com/drone/drone/server/worker/pool" "github.com/goji/context" "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) } +// 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 // of pending work and returns in JSON format. //