From c72c8134b8fc69c55d184e4bbf9aefe8bd587c9d Mon Sep 17 00:00:00 2001 From: Richard LT Date: Mon, 26 Apr 2021 15:56:06 +0200 Subject: [PATCH] fix(api): return public status with maintenance flag (#5799) --- engine/api/status.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/engine/api/status.go b/engine/api/status.go index cfc0a7b4b6..61196e9ae0 100644 --- a/engine/api/status.go +++ b/engine/api/status.go @@ -57,7 +57,8 @@ func (api *API) statusHandler() service.Handler { // If there is a valid session and user is maintainer, allows to get status details. currentConsumer := getAPIConsumer(ctx) if currentConsumer == nil || !isMaintainer(ctx) { - return service.WriteJSON(w, nil, status) + mStatus := api.computeGlobalPublicStatus() + return service.WriteJSON(w, mStatus, status) } mStatus := api.computeGlobalStatus(srvs) @@ -80,6 +81,19 @@ var ( tagsService []tag.Key ) +// computeGlobalPublicStatus returns global public status +func (api *API) computeGlobalPublicStatus() sdk.MonitoringStatus { + return sdk.MonitoringStatus{ + Lines: []sdk.MonitoringStatusLine{ + { + Status: sdk.MonitoringStatusOK, + Component: "Global/Maintenance", + Value: fmt.Sprintf("%v", api.Maintenance), + }, + }, + } +} + // computeGlobalStatus returns global status func (api *API) computeGlobalStatus(srvs []sdk.Service) sdk.MonitoringStatus { mStatus := sdk.MonitoringStatus{}