本文整理匯總了Golang中github.com/concourse/atc/db.PipelineDBFactory.BuildDefault方法的典型用法代碼示例。如果您正苦於以下問題:Golang PipelineDBFactory.BuildDefault方法的具體用法?Golang PipelineDBFactory.BuildDefault怎麽用?Golang PipelineDBFactory.BuildDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/concourse/atc/db.PipelineDBFactory
的用法示例。
在下文中一共展示了PipelineDBFactory.BuildDefault方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewHandler
func NewHandler(
logger lager.Logger,
pipelineDBFactory db.PipelineDBFactory,
pipelineHandler func(db.PipelineDB) http.Handler,
template *template.Template,
) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
pipelineDB, err := pipelineDBFactory.BuildDefault()
if err != nil {
if err == db.ErrNoPipelines {
err = template.Execute(w, TemplateData{})
if err != nil {
log.Fatal("failed-to-task-template", err, lager.Data{})
}
return
}
logger.Error("failed-to-load-pipelinedb", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
pipelineHandler(pipelineDB).ServeHTTP(w, r)
})
}
示例2: NewHandler
func NewHandler(
logger lager.Logger,
pipelineDBFactory db.PipelineDBFactory,
pipelineHandler http.Handler,
template *template.Template,
) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log := logger.Session("index")
pipelineDB, found, err := pipelineDBFactory.BuildDefault()
if err != nil {
log.Error("failed-to-load-pipelinedb", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if !found {
err = template.Execute(w, TemplateData{})
if err != nil {
log.Fatal("failed-to-build-template", err, lager.Data{})
}
return
}
if r.Form == nil {
r.Form = url.Values{}
}
r.Form[":pipeline"] = []string{pipelineDB.GetPipelineName()}
pipelineHandler.ServeHTTP(w, r)
})
}
示例3:
},
}
savedPipelineTwo := db.SavedPipeline{
ID: 2,
Pipeline: db.Pipeline{
Name: "another-pipeline",
},
}
pipelinesDB.GetAllPipelinesReturns([]db.SavedPipeline{
savedPipelineOne,
savedPipelineTwo,
}, nil)
defaultPipelineDB, found, err := pipelineDBFactory.BuildDefault()
Expect(err).NotTo(HaveOccurred())
Expect(found).To(BeTrue())
Expect(defaultPipelineDB.GetPipelineName()).To(Equal("a-pipeline"))
})
Context("when there are no pipelines", func() {
BeforeEach(func() {
pipelinesDB.GetAllPipelinesReturns([]db.SavedPipeline{}, nil)
})
It("returns a useful error if there are no pipelines", func() {
_, found, err := pipelineDBFactory.BuildDefault()
Expect(err).NotTo(HaveOccurred())
Expect(found).To(BeFalse())
示例4:
{
Name: "job-name",
Plan: atc.PlanSequence{
{
Get: "resource-name",
},
},
},
},
Resources: atc.ResourceConfigs{
{Name: "resource-name"},
},
}, db.ConfigVersion(1), db.PipelineUnpaused)
Ω(err).ShouldNot(HaveOccurred())
pipelineDB, err = pipelineDBFactory.BuildDefault()
Ω(err).ShouldNot(HaveOccurred())
resourceConfig := atc.ResourceConfig{
Name: "resource-name",
Type: "some-type",
Source: atc.Source{},
}
var resourceVersions []atc.Version
for i := 0; i < 104; i++ {
resourceVersions = append(resourceVersions, atc.Version{"version": strconv.Itoa(i)})
}
pipelineDB.SaveResourceVersions(resourceConfig, resourceVersions)
})