Allow bypassing Unauthorized error when deleting runner
This change allows users to bypass GitHub Unauthorized errors when removing github runners. This means that removing runners will now be possible even if the pool manager is stopped. There is a new flag added to the runner rm command and to the API that tells GARM to bypass pool being stopped and any 401 error returned by GitHub. This means you will be able to remove the runners from garm and your provider, but will mean that the runner will still exist in github as "offline" if the credentials are not updated or the runner manually removed. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
df72c4917e
commit
9a6770c3a3
19 changed files with 730 additions and 123 deletions
|
|
@ -128,8 +128,15 @@ func (a *APIController) GetInstanceHandler(w http.ResponseWriter, r *http.Reques
|
|||
// in: query
|
||||
// required: false
|
||||
//
|
||||
// Responses:
|
||||
// default: APIErrorResponse
|
||||
// + name: bypassGHUnauthorized
|
||||
// description: If true GARM will ignore unauthorized errors returned by GitHub when removing a runner. This is useful if you want to clean up runners and your credentials have expired.
|
||||
// type: boolean
|
||||
// in: query
|
||||
// required: false
|
||||
//
|
||||
// Responses:
|
||||
//
|
||||
// default: APIErrorResponse
|
||||
func (a *APIController) DeleteInstanceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
vars := mux.Vars(r)
|
||||
|
|
@ -146,7 +153,8 @@ func (a *APIController) DeleteInstanceHandler(w http.ResponseWriter, r *http.Req
|
|||
}
|
||||
|
||||
forceRemove, _ := strconv.ParseBool(r.URL.Query().Get("forceRemove"))
|
||||
if err := a.r.DeleteRunner(ctx, instanceName, forceRemove); err != nil {
|
||||
bypassGHUnauthorized, _ := strconv.ParseBool(r.URL.Query().Get("bypassGHUnauthorized"))
|
||||
if err := a.r.DeleteRunner(ctx, instanceName, forceRemove, bypassGHUnauthorized); err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "removing runner")
|
||||
handleError(ctx, w, err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -601,6 +601,10 @@ paths:
|
|||
in: query
|
||||
name: forceRemove
|
||||
type: boolean
|
||||
- description: If true GARM will ignore unauthorized errors returned by GitHub when removing a runner. This is useful if you want to clean up runners and your credentials have expired.
|
||||
in: query
|
||||
name: bypassGHUnauthorized
|
||||
type: boolean
|
||||
responses:
|
||||
default:
|
||||
description: APIErrorResponse
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue