From 487a31624f76a0050c785d05a94d344970c1b72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 2 Jun 2022 12:10:53 +0200 Subject: [PATCH] Cleanup: manager, make `workerDBtoAPI(w)` use `workerSummary(w)` This makes the `workerDBtoAPI(w)` and `workerSummary(w)` functions consistent, and makes the former use the latter. --- internal/manager/api_impl/worker_mgt.go | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/internal/manager/api_impl/worker_mgt.go b/internal/manager/api_impl/worker_mgt.go index c7c9952a..1681edca 100644 --- a/internal/manager/api_impl/worker_mgt.go +++ b/internal/manager/api_impl/worker_mgt.go @@ -51,7 +51,7 @@ func (f *Flamenco) FetchWorker(e echo.Context, workerUUID string) error { } logger.Debug().Msg("fetched worker") - apiWorker := workerDBtoAPI(dbWorker) + apiWorker := workerDBtoAPI(*dbWorker) return e.JSON(http.StatusOK, apiWorker) } @@ -117,22 +117,12 @@ func workerSummary(w persistence.Worker) api.WorkerSummary { return summary } -func workerDBtoAPI(dbWorker *persistence.Worker) api.Worker { +func workerDBtoAPI(w persistence.Worker) api.Worker { apiWorker := api.Worker{ - WorkerSummary: api.WorkerSummary{ - Id: dbWorker.UUID, - Nickname: dbWorker.Name, - Status: dbWorker.Status, - Version: dbWorker.Software, - }, - IpAddress: dbWorker.Address, - Platform: dbWorker.Platform, - SupportedTaskTypes: dbWorker.TaskTypes(), - } - - if dbWorker.StatusRequested != "" { - apiWorker.StatusRequested = &dbWorker.StatusRequested - apiWorker.LazyStatusRequest = &dbWorker.LazyStatusRequest + WorkerSummary: workerSummary(w), + IpAddress: w.Address, + Platform: w.Platform, + SupportedTaskTypes: w.TaskTypes(), } return apiWorker