Skip to content

Commit

Permalink
fix(api): return public status with maintenance flag (#5799)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored Apr 26, 2021
1 parent 368caaf commit c72c813
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion engine/api/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{}
Expand Down

0 comments on commit c72c813

Please sign in to comment.