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


Golang PipelineDBFactory.BuildDefault方法代碼示例

本文整理匯總了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)
	})
}
開發者ID:utako,項目名稱:atc,代碼行數:25,代碼來源:handler.go

示例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)
	})
}
開發者ID:ACPK,項目名稱:atc,代碼行數:34,代碼來源:handler.go

示例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())
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:31,代碼來源:pipeline_db_factory_test.go

示例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)
			})
開發者ID:utako,項目名稱:atc,代碼行數:31,代碼來源:resource_pagination_test.go


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