feat(runners): unregister endpoint

This commit is contained in:
fiftin 2024-03-27 12:11:33 +01:00
parent 7a1e08023e
commit 60d759872a
2 changed files with 17 additions and 0 deletions

View File

@ -91,6 +91,7 @@ func Route() *mux.Router {
routersAPI.Use(StoreMiddleware, JSONMiddleware, runners.RunnerMiddleware)
routersAPI.Path("/runners/{runner_id}").HandlerFunc(runners.GetRunner).Methods("GET", "HEAD")
routersAPI.Path("/runners/{runner_id}").HandlerFunc(runners.UpdateRunner).Methods("PUT")
routersAPI.Path("/runners/{runner_id}").HandlerFunc(runners.UnregisterRunner).Methods("DELETE")
publicWebHookRouter := r.PathPrefix(webPath + "api").Subrouter()
publicWebHookRouter.Use(StoreMiddleware, JSONMiddleware)

View File

@ -196,3 +196,19 @@ func RegisterRunner(w http.ResponseWriter, r *http.Request) {
helpers.WriteJSON(w, http.StatusOK, res)
}
func UnregisterRunner(w http.ResponseWriter, r *http.Request) {
runner := context.Get(r, "runner").(db.Runner)
err := helpers.Store(r).DeleteGlobalRunner(runner.ID)
if err != nil {
helpers.WriteJSON(w, http.StatusInternalServerError, map[string]string{
"error": "Unknown error",
})
return
}
w.WriteHeader(http.StatusNoContent)
}