本文整理汇总了Golang中github.com/concourse/atc/db.PipelineDB类的典型用法代码示例。如果您正苦于以下问题:Golang PipelineDB类的具体用法?Golang PipelineDB怎么用?Golang PipelineDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PipelineDB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: EnableResourceVersion
func (s *Server) EnableResourceVersion(pipelineDB db.PipelineDB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
resourceID, err := strconv.Atoi(rata.Param(r, "resource_version_id"))
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
err = pipelineDB.EnableVersionedResource(resourceID)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
})
}
开发者ID:utako,项目名称:atc,代码行数:17,代码来源:enable_version.go
示例17: DisableResourceVersion
func (s *Server) DisableResourceVersion(pipelineDB db.PipelineDB) http.Handler {
logger := s.logger.Session("disable-resource-version")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
resourceID, err := strconv.Atoi(rata.Param(r, "resource_version_id"))
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
err = pipelineDB.DisableVersionedResource(resourceID)
if err != nil {
logger.Error("failed-to-disable-versioned-resource", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
})
}
开发者ID:ACPK,项目名称:atc,代码行数:19,代码来源:disable_version.go
示例18: CreateJobBuild
func (s *Server) CreateJobBuild(pipelineDB db.PipelineDB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
logger := s.logger.Session("create-job-build")
jobName := r.FormValue(":job_name")
config, _, found, err := pipelineDB.GetConfig()
if err != nil {
logger.Error("could-not-get-pipeline-config", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if !found {
w.WriteHeader(http.StatusNotFound)
return
}
job, found := config.Jobs.Lookup(jobName)
if !found {
w.WriteHeader(http.StatusNotFound)
return
}
if job.DisableManualTrigger {
w.WriteHeader(http.StatusConflict)
return
}
scheduler := s.schedulerFactory.BuildScheduler(pipelineDB, s.externalURL)
build, _, err := scheduler.TriggerImmediately(logger, job, config.Resources, config.ResourceTypes)
if err != nil {
logger.Error("failed-to-trigger", err)
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "failed to trigger: %s", err)
return
}
json.NewEncoder(w).Encode(present.Build(build))
})
}
开发者ID:xoebus,项目名称:checkin,代码行数:42,代码来源:create_build.go
示例19: ListJobBuilds
func (s *Server) ListJobBuilds(pipelineDB db.PipelineDB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
jobName := r.FormValue(":job_name")
builds, err := pipelineDB.GetAllJobBuilds(jobName)
if err != nil {
w.WriteHeader(http.StatusNotFound)
return
}
w.WriteHeader(http.StatusOK)
resources := make([]atc.Build, len(builds))
for i := 0; i < len(builds); i++ {
resources[i] = present.Build(builds[i])
}
json.NewEncoder(w).Encode(resources)
})
}
开发者ID:utako,项目名称:atc,代码行数:20,代码来源:list_builds.go
示例20: GetPipeline
func (server *server) GetPipeline(pipelineDB db.PipelineDB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
config, _, err := pipelineDB.GetConfig()
if err != nil {
server.logger.Error("failed-to-load-config", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
groups := map[string]bool{}
for _, group := range config.Groups {
groups[group.Name] = false
}
enabledGroups, found := r.URL.Query()["groups"]
if !found && len(config.Groups) > 0 {
enabledGroups = []string{config.Groups[0].Name}
}
for _, name := range enabledGroups {
groups[name] = true
}
data := TemplateData{
Groups: groups,
GroupStates: group.States(config.Groups, func(g atc.GroupConfig) bool {
return groups[g.Name]
}),
PipelineName: pipelineDB.GetPipelineName(),
}
log := server.logger.Session("index")
err = server.template.Execute(w, data)
if err != nil {
log.Fatal("failed-to-task-template", err, lager.Data{
"template-data": data,
})
}
})
}
开发者ID:utako,项目名称:atc,代码行数:41,代码来源:handler.go
注:本文中的github.com/concourse/atc/db.PipelineDB类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论