本文整理汇总了Golang中github.com/concourse/atc/db.PipelineDB.LoadVersionsDB方法的典型用法代码示例。如果您正苦于以下问题:Golang PipelineDB.LoadVersionsDB方法的具体用法?Golang PipelineDB.LoadVersionsDB怎么用?Golang PipelineDB.LoadVersionsDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/atc/db.PipelineDB
的用法示例。
在下文中一共展示了PipelineDB.LoadVersionsDB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
})
}
示例2: ListJobInputs
func (s *Server) ListJobInputs(pipelineDB db.PipelineDB) http.Handler {
logger := s.logger.Session("list-job-inputs")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
jobName := r.FormValue(":job_name")
pipelineConfig, _, 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
}
jobConfig, found := pipelineConfig.Jobs.Lookup(jobName)
if !found {
w.WriteHeader(http.StatusNotFound)
return
}
versionsDB, err := pipelineDB.LoadVersionsDB()
if err != nil {
logger.Error("failed-to-load-version-db", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
jobInputs := config.JobInputs(jobConfig)
inputVersions, found, err := pipelineDB.GetNextInputVersions(versionsDB, jobName, jobInputs)
if err != nil {
logger.Error("failed-to-get-latest-input-versions", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if !found {
w.WriteHeader(http.StatusNotFound)
return
}
buildInputs := make([]atc.BuildInput, len(inputVersions))
for i, input := range inputVersions {
resource, _ := pipelineConfig.Resources.Lookup(input.Resource)
var config config.JobInput
for _, jobInput := range jobInputs {
if jobInput.Name == input.Name {
config = jobInput
break
}
}
buildInputs[i] = present.BuildInput(input, config, resource.Source)
}
json.NewEncoder(w).Encode(buildInputs)
})
}