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


Golang PipelineDB.GetResource方法代碼示例

本文整理匯總了Golang中github.com/concourse/atc/db.PipelineDB.GetResource方法的典型用法代碼示例。如果您正苦於以下問題:Golang PipelineDB.GetResource方法的具體用法?Golang PipelineDB.GetResource怎麽用?Golang PipelineDB.GetResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/concourse/atc/db.PipelineDB的用法示例。


在下文中一共展示了PipelineDB.GetResource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5:

				lease.Break()

				time.Sleep(time.Second)

				newLease, leased, err := pipelineDB.LeaseScheduling(1 * time.Second)
				Expect(err).NotTo(HaveOccurred())
				Expect(leased).To(BeTrue())

				newLease.Break()
			})
		})
	})

	Describe("taking out a lease on resource checking", func() {
		BeforeEach(func() {
			_, err := pipelineDB.GetResource("some-resource")
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when there has been a check recently", func() {
			Context("when acquiring immediately", func() {
				It("gets the lease", func() {
					lease, leased, err := pipelineDB.LeaseResourceChecking("some-resource", 1*time.Second, false)
					Expect(err).NotTo(HaveOccurred())
					Expect(leased).To(BeTrue())

					lease.Break()

					lease, leased, err = pipelineDB.LeaseResourceChecking("some-resource", 1*time.Second, true)
					Expect(err).NotTo(HaveOccurred())
					Expect(leased).To(BeTrue())
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:31,代碼來源:lease_test.go

示例6:

				Eventually(page.FindByLink("resource-name")).Should(BeFound())
				Expect(page.FindByLink("resource-name").Click()).To(Succeed())

				// resource detail -> paused resource detail
				Expect(page).Should(HaveURL(withPath("/resources/resource-name")))
				Expect(page.Find("h1")).To(HaveText("resource-name"))

				Authenticate(page, "admin", "password")

				Expect(page.Find(".js-resource .js-pauseUnpause").Click()).To(Succeed())
				Eventually(page.Find(".header i.fa-play")).Should(BeFound())

				page.Refresh()

				Eventually(page.Find(".header i.fa-play")).Should(BeFound())

				resource, err := pipelineDB.GetResource("resource-name")
				Ω(err).ShouldNot(HaveOccurred())

				err = pipelineDB.SetResourceCheckError(resource, errors.New("failed to foo the bar"))
				Ω(err).ShouldNot(HaveOccurred())

				page.Refresh()

				Eventually(page.Find(".header h3")).Should(HaveText("checking failed"))
				Eventually(page.Find(".build-step .step-body")).Should(HaveText("failed to foo the bar"))
			})
		})
	})
})
開發者ID:utako,項目名稱:atc,代碼行數:30,代碼來源:resource_pausing_test.go


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