当前位置: 首页>>代码示例>>Golang>>正文


Golang PipelineDB.GetConfig方法代码示例

本文整理汇总了Golang中github.com/concourse/atc/db.PipelineDB.GetConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang PipelineDB.GetConfig方法的具体用法?Golang PipelineDB.GetConfig怎么用?Golang PipelineDB.GetConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/concourse/atc/db.PipelineDB的用法示例。


在下文中一共展示了PipelineDB.GetConfig方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ListJobs

func (s *Server) ListJobs(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		var jobs []atc.Job
		config, _, err := pipelineDB.GetConfig()
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		for _, job := range config.Jobs {
			finished, next, err := pipelineDB.GetJobFinishedAndNextBuild(job.Name)
			if err != nil {
				w.WriteHeader(http.StatusInternalServerError)
				return
			}

			dbJob, err := pipelineDB.GetJob(job.Name)
			if err != nil {
				w.WriteHeader(http.StatusInternalServerError)
				return
			}

			jobs = append(jobs, present.Job(dbJob, job, config.Groups, finished, next))
		}

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(jobs)
	})
}
开发者ID:utako,项目名称:atc,代码行数:30,代码来源:list.go

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

示例3: GetJob

func (s *Server) GetJob(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		jobName := r.FormValue(":job_name")

		config, _, err := pipelineDB.GetConfig()
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		job, found := config.Jobs.Lookup(jobName)
		if !found {
			w.WriteHeader(http.StatusNotFound)
			return
		}

		finished, next, err := pipelineDB.GetJobFinishedAndNextBuild(jobName)
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		dbJob, err := pipelineDB.GetJob(job.Name)
		if err != nil {
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(present.Job(dbJob, job, config.Groups, finished, next))
	})
}
开发者ID:utako,项目名称:atc,代码行数:33,代码来源:get.go

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

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

示例6: TriggerBuild

func (server *server) TriggerBuild(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
		}

		job, found := config.Jobs.Lookup(r.FormValue(":job"))
		if !found {
			w.WriteHeader(http.StatusNotFound)
			return
		}

		log := server.logger.Session("trigger-build", lager.Data{
			"job": job.Name,
		})

		log.Debug("triggering")

		scheduler := server.radarSchedulerFactory.BuildScheduler(pipelineDB)

		build, err := scheduler.TriggerImmediately(log, job, config.Resources)
		if err != nil {
			log.Error("failed-to-trigger", err)
			w.WriteHeader(http.StatusInternalServerError)
			fmt.Fprintf(w, "failed to trigger: %s", err)
			return
		}

		redirectPath, err := routes.Routes.CreatePathForRoute(routes.GetBuild, rata.Params{
			"pipeline_name": pipelineDB.GetPipelineName(),
			"job":           job.Name,
			"build":         build.Name,
		})
		if err != nil {
			log.Fatal("failed-to-construct-redirect-uri", err, lager.Data{
				"pipeline": pipelineDB.GetPipelineName(),
				"job":      job.Name,
				"build":    build.Name,
			})
		}

		http.Redirect(w, r, redirectPath, http.StatusFound)
	})
}
开发者ID:utako,项目名称:atc,代码行数:47,代码来源:handler.go

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

示例8: GetJob

func (s *Server) GetJob(pipelineDB db.PipelineDB) http.Handler {
	logger := s.logger.Session("get-job")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		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
		}

		finished, next, err := pipelineDB.GetJobFinishedAndNextBuild(jobName)
		if err != nil {
			logger.Error("could-not-get-job-finished-and-next-build", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		dbJob, err := pipelineDB.GetJob(job.Name)
		if err != nil {
			logger.Error("could-not-get-job-finished", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		w.WriteHeader(http.StatusOK)

		json.NewEncoder(w).Encode(present.Job(dbJob, job, config.Groups, finished, next))
	})
}
开发者ID:ACPK,项目名称:atc,代码行数:42,代码来源:get.go

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

示例10: 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)
	})
}
开发者ID:xoebus,项目名称:checkin,代码行数:62,代码来源:list_inputs.go

示例11: GetBuild

func (server *server) GetBuild(pipelineDB db.PipelineDB) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		jobName := r.FormValue(":job")
		if len(jobName) == 0 {
			w.WriteHeader(http.StatusBadRequest)
			return
		}

		buildName := r.FormValue(":build")
		if len(buildName) == 0 {
			w.WriteHeader(http.StatusBadRequest)
			return
		}

		config, _, err := pipelineDB.GetConfig()
		if err != nil {
			server.logger.Error("failed-to-load-config", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		job, found := config.Jobs.Lookup(jobName)
		if !found {
			w.WriteHeader(http.StatusNotFound)
			return
		}

		log := server.logger.Session("get-build", lager.Data{
			"job":   job.Name,
			"build": buildName,
		})

		build, err := pipelineDB.GetJobBuild(jobName, buildName)
		if err != nil {
			log.Error("get-build-failed", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		inputs, outputs, err := pipelineDB.GetBuildResources(build.ID)
		if err != nil {
			log.Error("failed-to-get-build-resources", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		bs, err := pipelineDB.GetAllJobBuilds(jobName)
		if err != nil {
			log.Error("get-all-builds-failed", err)
			w.WriteHeader(http.StatusInternalServerError)
			return
		}

		templateData := TemplateData{
			GroupStates: group.States(config.Groups, func(g atc.GroupConfig) bool {
				for _, groupJob := range g.Jobs {
					if groupJob == job.Name {
						return true
					}
				}

				return false
			}),

			Job:    job,
			Builds: bs,

			Build:        build,
			Inputs:       inputs,
			Outputs:      outputs,
			PipelineName: pipelineDB.GetPipelineName(),
		}

		err = server.template.Execute(w, templateData)
		if err != nil {
			log.Fatal("failed-to-task-template", err, lager.Data{
				"template-data": templateData,
			})
		}
	})
}
开发者ID:utako,项目名称:atc,代码行数:81,代码来源:handler.go


注:本文中的github.com/concourse/atc/db.PipelineDB.GetConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。