當前位置: 首頁>>代碼示例>>Golang>>正文


Golang db.PipelineDB類代碼示例

本文整理匯總了Golang中github.com/concourse/atc/db.PipelineDB的典型用法代碼示例。如果您正苦於以下問題:Golang PipelineDB類的具體用法?Golang PipelineDB怎麽用?Golang PipelineDB使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PipelineDB類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ListJobs

func (s *Server) ListJobs(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("list-jobs")

	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		var jobs []atc.Job

		dashboard, groups, err := pipelineDB.GetDashboard()
		if err != nil {
			logger.Error("failed-to-get-dashboard", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		for _, job := range dashboard {
			jobs = append(
				jobs,
				present.Job(job.Job, job.JobConfig, groups, job.FinishedBuild, job.NextBuild),
			)
		}

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(jobs)
	})
}
開發者ID:xoebus,項目名稱:checkin,代碼行數:25,代碼來源:list.go

示例2: RenamePipeline

func (s *Server) RenamePipeline(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		data, err := ioutil.ReadAll(r.Body)
		if err != nil {
			s.logger.Error("call-to-update-pipeline-name-copy-failed", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		var value struct{ Name string }
		err = json.Unmarshal(data, &value)
		if err != nil {
			s.logger.Error("call-to-update-pipeline-name-unmarshal-failed", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		err = pipelineDB.UpdateName(value.Name)
		if err != nil {
			s.logger.Error("call-to-update-pipeline-name-failed", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusNoContent)
	})
}
開發者ID:xoebus,項目名稱:checkin,代碼行數:27,代碼來源:rename.go

示例3: ListResources

func (s *Server) ListResources(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		var resources []atc.Resource

		config, _, err := pipelineDB.GetConfig()
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		showCheckErr := s.validator.IsAuthenticated(r)

		for _, resource := range config.Resources {
			dbResource, err := pipelineDB.GetResource(resource.Name)
			if err != nil {
				w.WriteHeader(http.StatusInternalServerError)
				return
			}

			resources = append(
				resources,
				present.Resource(
					resource,
					config.Groups,
					dbResource,
					showCheckErr,
				),
			)
		}

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(resources)
	})
}
開發者ID:utako,項目名稱:atc,代碼行數:35,代碼來源:list.go

示例4: UnpauseResource

func (s *Server) UnpauseResource(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		resourceName := rata.Param(r, "resource_name")

		_, found, err := pipelineDB.GetResource(resourceName)
		if err != nil {
			s.logger.Error("failed-to-get-resource", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		if !found {
			s.logger.Debug("resource-not-found", lager.Data{"resource": resourceName})
			w.WriteHeader(http.StatusNotFound)
			return
		}

		err = pipelineDB.UnpauseResource(resourceName)
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:xoebus,項目名稱:checkin,代碼行數:26,代碼來源:unpause_resource.go

示例5: BuildScheduler

func (rsf *radarSchedulerFactory) BuildScheduler(pipelineDB db.PipelineDB) *scheduler.Scheduler {
	radar := rsf.BuildRadar(pipelineDB)
	return &scheduler.Scheduler{
		PipelineDB: pipelineDB,
		BuildsDB:   rsf.db,
		Factory:    &factory.BuildFactory{PipelineName: pipelineDB.GetPipelineName()},
		Engine:     rsf.engine,
		Scanner:    radar,
	}
}
開發者ID:utako,項目名稱:atc,代碼行數:10,代碼來源:radar_scheduler_factory.go

示例6: GetVersionsDB

func (s *Server) GetVersionsDB(pipelineDB db.PipelineDB) http.Handler {
	// logger := s.logger.Session("get-versions-db-pipeline")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		versionsDB, _ := pipelineDB.LoadVersionsDB()
		w.Header().Set("Content-Type", "application/json")

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

}
開發者ID:ACPK,項目名稱:atc,代碼行數:10,代碼來源:get_versions_db.go

示例7: UnpausePipeline

func (s *Server) UnpausePipeline(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		err := pipelineDB.Unpause()
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:utako,項目名稱:atc,代碼行數:11,代碼來源:unpause.go

示例8: UnpauseResource

func (s *Server) UnpauseResource(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		resourceName := rata.Param(r, "resource_name")

		err := pipelineDB.UnpauseResource(resourceName)
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:utako,項目名稱:atc,代碼行數:13,代碼來源:unpause_resource.go

示例9: PauseJob

func (s *Server) PauseJob(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		jobName := rata.Param(r, "job_name")

		err := pipelineDB.PauseJob(jobName)
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:utako,項目名稱:atc,代碼行數:13,代碼來源:pause_job.go

示例10: BuildScheduler

func (rsf *radarSchedulerFactory) BuildScheduler(pipelineDB db.PipelineDB) scheduler.BuildScheduler {
	radar := rsf.BuildRadar(pipelineDB)
	return &scheduler.Scheduler{
		PipelineDB: pipelineDB,
		BuildsDB:   rsf.db,
		Factory: factory.NewBuildFactory(
			pipelineDB.GetPipelineName(),
			atc.NewPlanFactory(time.Now().Unix()),
		),
		Engine:  rsf.engine,
		Scanner: radar,
	}
}
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:13,代碼來源:radar_scheduler_factory.go

示例11: PausePipeline

func (s *Server) PausePipeline(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("pause-pipeline")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		err := pipelineDB.Pause()
		if err != nil {
			logger.Error("failed-to-pause-pipeline", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:ACPK,項目名稱:atc,代碼行數:13,代碼來源:pause.go

示例12: GetResource

func (s *Server) GetResource(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("get-resource")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		config, _, found, err := pipelineDB.GetConfig()
		if err != nil {
			logger.Error("failed-to-get-config", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		if !found {
			logger.Info("config-not-found")
			w.WriteHeader(http.StatusNotFound)
			return
		}

		resourceName := r.FormValue(":resource_name")

		resourceConfig, resourceFound := config.Resources.Lookup(resourceName)
		if !resourceFound {
			logger.Info("resource-not-in-config")
			w.WriteHeader(http.StatusNotFound)
			return
		}

		dbResource, found, err := pipelineDB.GetResource(resourceName)
		if err != nil {
			logger.Error("failed-to-get-resource", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		if !found {
			logger.Debug("resource-not-found", lager.Data{"resource": resourceName})
			w.WriteHeader(http.StatusNotFound)
			return
		}

		resource := present.Resource(
			resourceConfig,
			config.Groups,
			dbResource,
			auth.IsAuthenticated(r),
		)

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(resource)
	})
}
開發者ID:xoebus,項目名稱:checkin,代碼行數:50,代碼來源:get.go

示例13: ListResources

func (s *Server) ListResources(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("list-resources")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		var resources []atc.Resource

		config, _, found, err := pipelineDB.GetConfig()
		if err != nil {
			logger.Error("failed-to-get-config", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		if !found {
			w.WriteHeader(http.StatusNotFound)
			return
		}

		showCheckErr := auth.IsAuthenticated(r)

		for _, resource := range config.Resources {
			dbResource, found, err := pipelineDB.GetResource(resource.Name)
			if err != nil {
				logger.Error("failed-to-get-resource", err)
				w.WriteHeader(http.StatusInternalServerError)
				return
			}

			if !found {
				logger.Debug("resource-not-found", lager.Data{"resource": resource})
				w.WriteHeader(http.StatusNotFound)
				return
			}

			resources = append(
				resources,
				present.Resource(
					resource,
					config.Groups,
					dbResource,
					showCheckErr,
				),
			)
		}

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(resources)
	})
}
開發者ID:xoebus,項目名稱:checkin,代碼行數:49,代碼來源:list.go

示例14: PauseResource

func (s *Server) PauseResource(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("pause-resource")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		resourceName := rata.Param(r, "resource_name")

		err := pipelineDB.PauseResource(resourceName)
		if err != nil {
			logger.Error("failed-to-pause-resource", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:ACPK,項目名稱:atc,代碼行數:15,代碼來源:pause_resource.go

示例15: UnpauseJob

func (s *Server) UnpauseJob(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("unpause-job")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		jobName := rata.Param(r, "job_name")

		err := pipelineDB.UnpauseJob(jobName)
		if err != nil {
			logger.Error("failed-to-unpause-job", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)
	})
}
開發者ID:ACPK,項目名稱:atc,代碼行數:15,代碼來源:unpause_job.go


注:本文中的github.com/concourse/atc/db.PipelineDB類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。