Skip to content

Commit

Permalink
Return an error if not ready for push
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jun 23, 2023
1 parent f4aa4c6 commit 554d20b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/apiserver-impl/api_default_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ func NewDefaultApiService(
func (s *DefaultApiService) ComponentCommandPost(ctx context.Context, componentCommandPostRequest openapi.ComponentCommandPostRequest) (openapi.ImplResponse, error) {
switch componentCommandPostRequest.Name {
case "push":
s.pushWatcher <- struct{}{}
return openapi.Response(http.StatusOK, nil), nil
select {
case s.pushWatcher <- struct{}{}:
return openapi.Response(http.StatusOK, openapi.GeneralSuccess{
Message: "push was successfully executed",
}), nil
default:
return openapi.Response(http.StatusTooManyRequests, openapi.GeneralError{
Message: "a push operation is not possible at this time. Please retry later",
}), nil
}

default:
return openapi.Response(http.StatusBadRequest, nil), fmt.Errorf("command name %q not supported. Supported values are: %q", componentCommandPostRequest.Name, "push")
}
Expand Down

0 comments on commit 554d20b

Please sign in to comment.