コード例 #1
0
ファイル: list.go プロジェクト: xoebus/checkin
func (s *Server) ListPipelines(w http.ResponseWriter, r *http.Request) {
	logger := s.logger.Session("list-pipelines")

	pipelines, err := s.pipelinesDB.GetAllPipelines()
	if err != nil {
		logger.Error("failed-to-get-all-active-pipelines", err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	presentedPipelines := make([]atc.Pipeline, len(pipelines))
	for i := 0; i < len(pipelines); i++ {
		pipeline := pipelines[i]

		config, _, _, err := s.configDB.GetConfig(atc.DefaultTeamName, pipeline.Name)
		if err != nil {
			logger.Error("call-to-get-pipeline-config-failed", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		presentedPipelines[i] = present.Pipeline(pipeline, config)
	}

	w.Header().Set("Content-Type", "application/json")

	json.NewEncoder(w).Encode(presentedPipelines)
}
コード例 #2
0
ファイル: list.go プロジェクト: utako/atc
func (s *Server) ListPipelines(w http.ResponseWriter, r *http.Request) {
	pipelines, err := s.db.GetAllActivePipelines()
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)

	presentedPipelines := make([]atc.Pipeline, len(pipelines))
	for i := 0; i < len(pipelines); i++ {
		presentedPipelines[i] = present.Pipeline(pipelines[i])
	}

	json.NewEncoder(w).Encode(presentedPipelines)
}
コード例 #3
0
ファイル: get.go プロジェクト: xoebus/checkin
func (s *Server) GetPipeline(w http.ResponseWriter, r *http.Request) {
	pipelineName := r.FormValue(":pipeline_name")

	pipeline, err := s.pipelinesDB.GetPipelineByTeamNameAndName(atc.DefaultTeamName, pipelineName)
	if err != nil {
		s.logger.Error("call-to-get-pipeline-failed", err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	config, _, _, err := s.configDB.GetConfig(atc.DefaultTeamName, pipelineName)
	if err != nil {
		s.logger.Error("call-to-get-pipeline-config-failed", err)
		w.WriteHeader(http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)

	presentedPipeline := present.Pipeline(pipeline, config)

	json.NewEncoder(w).Encode(presentedPipeline)
}