forked from concourse/concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.go
45 lines (37 loc) · 1023 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
45
package pipelineserver
import (
"encoding/json"
"net/http"
"code.cloudfoundry.org/lager"
"github.com/pf-qiu/concourse/v6/atc"
)
func (s *Server) OrderPipelines(w http.ResponseWriter, r *http.Request) {
logger := s.logger.Session("order-pipelines")
var pipelinesRefs atc.OrderPipelinesRequest
if err := json.NewDecoder(r.Body).Decode(&pipelinesRefs); 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(pipelinesRefs)
if err != nil {
logger.Error("failed-to-order-pipelines", err, lager.Data{
"pipeline-refs": pipelinesRefs,
})
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}