forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_all.go
34 lines (27 loc) · 895 Bytes
/
list_all.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
package pipelineserver
import (
"encoding/json"
"net/http"
"github.com/concourse/atc/api/present"
"github.com/concourse/atc/auth"
"github.com/concourse/atc/db"
)
// show all public pipelines and team private pipelines if authorized
func (s *Server) ListAllPipelines(w http.ResponseWriter, r *http.Request) {
logger := s.logger.Session("list-all-pipelines")
authTeam, authTeamFound := auth.GetTeam(r)
var pipelines []db.SavedPipeline
var err error
if authTeamFound {
pipelines, err = s.teamDBFactory.GetTeamDB(authTeam.Name()).GetPrivateAndAllPublicPipelines()
} else {
pipelines, err = s.pipelinesDB.GetAllPublicPipelines()
}
if err != nil {
logger.Error("failed-to-get-all-active-pipelines", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(present.Pipelines(pipelines))
}