forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_destroying_containers.go
36 lines (28 loc) · 1005 Bytes
/
list_destroying_containers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package containerserver
import (
"encoding/json"
"net/http"
"code.cloudfoundry.org/lager"
)
func (s *Server) ListDestroyingContainers(w http.ResponseWriter, r *http.Request) {
workerName := r.URL.Query().Get("worker_name")
w.Header().Set("Content-Type", "application/json")
logger := s.logger.Session("list-destroying-containers-worker", lager.Data{"name": workerName})
if workerName != "" {
containerHandles, err := s.containerRepository.FindDestroyingContainers(workerName)
if err != nil {
logger.Error("failed-to-find-destroying-worker", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
logger.Debug("list", lager.Data{"destroying-container-count": len(containerHandles)})
err = json.NewEncoder(w).Encode(containerHandles)
if err != nil {
logger.Error("failed-to-marshall-container-handles-for-worker", err)
w.WriteHeader(http.StatusInternalServerError)
}
} else {
logger.Info("failed-to-find-worker")
w.WriteHeader(http.StatusNotFound)
}
}