Add safe stale repository unlock action
This commit is contained in:
@@ -45,6 +45,7 @@ func New(socket string, svc *service.Service, log *slog.Logger) *Server {
|
||||
mux.HandleFunc("POST /v1/runs/{id}/resume", s.resumeRun)
|
||||
mux.HandleFunc("POST /v1/repositories/{id}/test", s.testRepository)
|
||||
mux.HandleFunc("POST /v1/repositories/{id}/init", s.initRepository)
|
||||
mux.HandleFunc("POST /v1/repositories/{id}/unlock", s.unlockRepository)
|
||||
mux.HandleFunc("POST /v1/repositories/{id}/{action}", s.maintenance)
|
||||
mux.HandleFunc("GET /v1/repositories/{id}/snapshots", s.snapshots)
|
||||
mux.HandleFunc("GET /v1/repositories/{id}/snapshots/{snapshot}/files", s.snapshotFiles)
|
||||
@@ -181,6 +182,15 @@ func (s *Server) testRepository(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) initRepository(w http.ResponseWriter, r *http.Request) {
|
||||
s.repositoryAction(w, r, true)
|
||||
}
|
||||
func (s *Server) unlockRepository(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
|
||||
defer cancel()
|
||||
if err := s.service.UnlockRepository(ctx, r.PathValue("id")); err != nil {
|
||||
writeError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, 200, map[string]bool{"ok": true})
|
||||
}
|
||||
func (s *Server) repositoryAction(w http.ResponseWriter, r *http.Request, initialize bool) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user