forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.go
44 lines (36 loc) · 969 Bytes
/
order.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
37
38
39
40
41
42
43
44
package pipelineserver
import (
"encoding/json"
"net/http"
"code.cloudfoundry.org/lager"
)
func (s *Server) OrderPipelines(w http.ResponseWriter, r *http.Request) {
logger := s.logger.Session("order-pipelines")
var pipelineNames []string
if err := json.NewDecoder(r.Body).Decode(&pipelineNames); err != nil {
logger.Error("invalid-json", err)
w.WriteHeader(http.StatusBadRequest)
return
}
teamName := r.FormValue(":team_name")
team, found, err := s.teamFactory.FindTeam(teamName)
if err != nil {
logger.Error("failed-to-get-team", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if !found {
logger.Info("team-not-found")
w.WriteHeader(http.StatusNotFound)
return
}
err = team.OrderPipelines(pipelineNames)
if err != nil {
logger.Error("failed-to-order-pipelines", err, lager.Data{
"pipeline-names": pipelineNames,
})
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}