本文整理汇总了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)
})
}
示例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)
})
}
示例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)
})
}
示例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)
})
}
示例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,
}
}
示例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)
})
}
示例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)
})
}
示例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)
})
}
示例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)
})
}
示例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,
}
}
示例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)
})
}
示例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)
})
}
示例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)
})
}
示例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)
})
}
示例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)
})
}