Skip to content

Commit

Permalink
feat(api): maintenance allow worker and service calls (#6163)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored May 4, 2022
1 parent fce521f commit 386edb1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions engine/api/router_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import (
)

func (api *API) maintenanceMiddleware(ctx context.Context, w http.ResponseWriter, req *http.Request, rc *service.HandlerConfig) (context.Context, error) {
if !isMaintainer(ctx) && api.Maintenance && !rc.MaintenanceAware && rc.Method != http.MethodGet {
return ctx, sdk.WrapError(sdk.ErrServiceUnavailable, "CDS Maintenance ON")
if api.Maintenance && !rc.MaintenanceAware && rc.Method != http.MethodGet {
isAllowed := isMaintainer(ctx) || isService(ctx) || isWorker(ctx)
if !isAllowed {
return ctx, sdk.WrapError(sdk.ErrServiceUnavailable, "CDS Maintenance ON")
}
}
return ctx, nil
}

0 comments on commit 386edb1

Please sign in to comment.