コード例 #1
0
ファイル: build_step.go プロジェクト: xoebus/checkin
func (build *execBuild) buildDependentGetStep(logger lager.Logger, plan atc.Plan) exec.StepFactory {
	logger = logger.Session("get", lager.Data{
		"name": plan.DependentGet.Name,
	})

	getPlan := plan.DependentGet.GetPlan()
	workerID, workerMetadata := build.stepIdentifier(
		logger.Session("stepIdentifier"),
		getPlan.Name,
		plan.ID,
		plan.DependentGet.PipelineID,
		plan.Attempts,
		"get",
	)

	return build.factory.DependentGet(
		logger,
		build.stepMetadata,
		exec.SourceName(getPlan.Name),
		workerID,
		workerMetadata,
		build.delegate.InputDelegate(logger, getPlan, event.OriginID(plan.ID)),
		atc.ResourceConfig{
			Name:   getPlan.Resource,
			Type:   getPlan.Type,
			Source: getPlan.Source,
		},
		getPlan.Tags,
		getPlan.Params,
		getPlan.ResourceTypes,
	)
}
コード例 #2
0
ファイル: build_step.go プロジェクト: ACPK/atc
func (build *execBuild) buildGetStep(logger lager.Logger, plan atc.Plan) exec.StepFactory {
	logger = logger.Session("get", lager.Data{
		"name": plan.Get.Name,
	})

	var location event.OriginLocation
	if plan.Location != nil {
		location = event.OriginLocationFrom(*plan.Location)
	}

	pipelineName := plan.Get.Pipeline

	return build.factory.Get(
		logger,
		build.stepMetadata,
		exec.SourceName(plan.Get.Name),
		build.getIdentifier(plan.Get.Name, location, pipelineName),
		build.delegate.InputDelegate(logger, *plan.Get, location),
		atc.ResourceConfig{
			Name:   plan.Get.Resource,
			Type:   plan.Get.Type,
			Source: plan.Get.Source,
		},
		plan.Get.Params,
		plan.Get.Tags,
		plan.Get.Version,
	)
}
コード例 #3
0
ファイル: build_step.go プロジェクト: ACPK/atc
func (build *execBuild) buildTaskStep(logger lager.Logger, plan atc.Plan) exec.StepFactory {
	logger = logger.Session("task")

	var configSource exec.TaskConfigSource
	if plan.Task.Config != nil && plan.Task.ConfigPath != "" {
		configSource = exec.MergedConfigSource{
			A: exec.FileConfigSource{plan.Task.ConfigPath},
			B: exec.StaticConfigSource{*plan.Task.Config},
		}
	} else if plan.Task.Config != nil {
		configSource = exec.StaticConfigSource{*plan.Task.Config}
	} else if plan.Task.ConfigPath != "" {
		configSource = exec.FileConfigSource{plan.Task.ConfigPath}
	} else {
		return exec.Identity{}
	}

	var location event.OriginLocation
	if plan.Location != nil {
		location = event.OriginLocationFrom(*plan.Location)
	}

	pipelineName := plan.Task.Pipeline

	return build.factory.Task(
		logger,
		exec.SourceName(plan.Task.Name),
		build.taskIdentifier(plan.Task.Name, location, pipelineName),
		build.delegate.ExecutionDelegate(logger, *plan.Task, location),
		exec.Privileged(plan.Task.Privileged),
		plan.Task.Tags,
		configSource,
	)
}
コード例 #4
0
ファイル: build_step.go プロジェクト: xoebus/checkin
func (build *execBuild) buildTaskStep(logger lager.Logger, plan atc.Plan) exec.StepFactory {
	logger = logger.Session("task")

	var configSource exec.TaskConfigSource
	if plan.Task.ConfigPath != "" && (plan.Task.Config != nil || plan.Task.Params != nil) {
		configSource = exec.MergedConfigSource{
			A: exec.FileConfigSource{plan.Task.ConfigPath},
			B: exec.StaticConfigSource{*plan.Task},
		}
	} else if plan.Task.Config != nil {
		configSource = exec.StaticConfigSource{*plan.Task}
	} else if plan.Task.ConfigPath != "" {
		configSource = exec.FileConfigSource{plan.Task.ConfigPath}
	} else {
		return exec.Identity{}
	}

	configSource = exec.ValidatingConfigSource{configSource}

	workerID, workerMetadata := build.stepIdentifier(
		logger.Session("taskIdentifier"),
		plan.Task.Name,
		plan.ID,
		plan.Task.PipelineID,
		plan.Attempts,
		"task",
	)

	clock := clock.NewClock()

	return build.factory.Task(
		logger,
		exec.SourceName(plan.Task.Name),
		workerID,
		workerMetadata,
		build.delegate.ExecutionDelegate(logger, *plan.Task, event.OriginID(plan.ID)),
		exec.Privileged(plan.Task.Privileged),
		plan.Task.Tags,
		configSource,
		plan.Task.ResourceTypes,
		plan.Task.InputMapping,
		plan.Task.OutputMapping,
		clock,
	)
}
コード例 #5
0
ファイル: exec_engine_hooks_test.go プロジェクト: ACPK/atc
									},
								},
							},
						},
					}

					build, err := execEngine.CreateBuild(logger, buildModel, plan)
					Expect(err).NotTo(HaveOccurred())
					build.Resume(logger)
				})

				It("constructs the steps correctly", func() {
					Expect(fakeFactory.TaskCallCount()).To(Equal(3))
					logger, sourceName, workerID, delegate, _, _, _ := fakeFactory.TaskArgsForCall(0)
					Expect(logger).NotTo(BeNil())
					Expect(sourceName).To(Equal(exec.SourceName("some-success-task-1")))
					Expect(workerID).To(Equal(worker.Identifier{
						BuildID: 84,
						Type:    db.ContainerTypeTask,
						Name:    "some-success-task-1",
					}))

					Expect(delegate).To(Equal(fakeExecutionDelegate))

					Expect(fakeFactory.GetCallCount()).To(Equal(2))
					logger, metadata, sourceName, workerID, getDelegate, _, _, _, _ := fakeFactory.GetArgsForCall(1)
					Expect(logger).NotTo(BeNil())
					Expect(metadata).To(Equal(expectedMetadata))
					Expect(sourceName).To(Equal(exec.SourceName("some-input")))
					Expect(workerID).To(Equal(worker.Identifier{
						BuildID: 84,
コード例 #6
0
				plan = atc.Plan{
					Location: nil,
					Get: &atc.GetPlan{
						Name: "some input",
					},
				}
			})

			It("constructs the step correctly", func() {
				build, err := execEngine.CreateBuild(buildModel, plan)
				Ω(err).ShouldNot(HaveOccurred())
				build.Resume(logger)

				Ω(fakeFactory.GetCallCount()).Should(Equal(1))
				sourceName, workerID, delegate, _, _, _, _ := fakeFactory.GetArgsForCall(0)
				Ω(sourceName).Should(Equal(exec.SourceName("some input")))
				Ω(workerID).Should(Equal(worker.Identifier{
					BuildID: 84,
					Type:    worker.ContainerTypeGet,
					Name:    "some input",
				}))

				Ω(delegate).Should(Equal(fakeGetDelegate))
				_, _, location := fakeDelegate.InputDelegateArgsForCall(0)
				Ω(location).ShouldNot(BeNil())
			})
		})

		Context("put with nil location", func() {
			var (
				putStepFactory *execfakes.FakeStepFactory
コード例 #7
0
ファイル: exec_engine_test.go プロジェクト: utako/atc
					Ω(fakeFactory.DependentGetCallCount()).Should(Equal(2))

					sourceName, workerID, delegate, resourceConfig, tags, params := fakeFactory.DependentGetArgsForCall(0)
					Ω(workerID).Should(Equal(worker.Identifier{
						BuildID: 42,
						Type:    worker.ContainerTypeGet,
						Name:    "some-put",
					}))

					Ω(tags).Should(BeEmpty())
					Ω(delegate).Should(Equal(fakeInputDelegate))
					_, plan, location := fakeDelegate.InputDelegateArgsForCall(1)
					Ω(plan).Should(Equal((*outputPlan.Plan.Aggregate)[0].Conditional.Plan.OnSuccess.Next.DependentGet.GetPlan()))
					Ω(location).ShouldNot(BeNil())

					Ω(sourceName).Should(Equal(exec.SourceName("some-put")))
					Ω(resourceConfig.Name).Should(Equal("some-output-resource"))
					Ω(resourceConfig.Type).Should(Equal("some-type"))
					Ω(resourceConfig.Source).Should(Equal(atc.Source{"some": "source"}))
					Ω(params).Should(Equal(atc.Params{"another": "params"}))

					sourceName, workerID, delegate, resourceConfig, tags, params = fakeFactory.DependentGetArgsForCall(1)
					Ω(workerID).Should(Equal(worker.Identifier{
						BuildID: 42,
						Type:    worker.ContainerTypeGet,
						Name:    "some-put-2",
					}))

					Ω(tags).Should(BeEmpty())
					Ω(delegate).Should(Equal(fakeInputDelegate))
					_, plan, location = fakeDelegate.InputDelegateArgsForCall(2)
コード例 #8
0
					Get: &atc.GetPlan{
						Name: "some input",
					},
				}
			})

			It("constructs the step correctly", func() {
				build, err := execEngine.CreateBuild(logger, buildModel, plan)
				Expect(err).NotTo(HaveOccurred())
				build.Resume(logger)

				Expect(fakeFactory.GetCallCount()).To(Equal(1))
				logger, metadata, sourceName, workerID, delegate, _, _, _, _ := fakeFactory.GetArgsForCall(0)
				Expect(logger).ToNot(BeNil())
				Expect(metadata).To(Equal(expectedMetadata))
				Expect(sourceName).To(Equal(exec.SourceName("some input")))
				Expect(workerID).To(Equal(worker.Identifier{
					BuildID: 84,
					Type:    db.ContainerTypeGet,
					Name:    "some input",
				}))

				Expect(delegate).To(Equal(fakeGetDelegate))
				_, _, location := fakeDelegate.InputDelegateArgsForCall(0)
				Expect(location).NotTo(BeNil())
			})
		})

		Context("put with nil location", func() {
			var (
				putStepFactory *execfakes.FakeStepFactory
コード例 #9
0
ファイル: exec_engine_hooks_test.go プロジェクト: utako/atc
										},
									},
								},
							},
						},
					}

					build, err := execEngine.CreateBuild(buildModel, plan)
					Ω(err).ShouldNot(HaveOccurred())
					build.Resume(logger)
				})

				It("constructs the steps correctly", func() {
					Ω(fakeFactory.TaskCallCount()).Should(Equal(3))
					sourceName, workerID, delegate, _, _, _ := fakeFactory.TaskArgsForCall(0)
					Ω(sourceName).Should(Equal(exec.SourceName("some-success-task-1")))
					Ω(workerID).Should(Equal(worker.Identifier{
						BuildID: 84,
						Type:    worker.ContainerTypeTask,
						Name:    "some-success-task-1",
					}))
					Ω(delegate).Should(Equal(fakeExecutionDelegate))

					Ω(fakeFactory.GetCallCount()).Should(Equal(2))
					sourceName, workerID, getDelegate, _, _, _, _ := fakeFactory.GetArgsForCall(1)
					Ω(sourceName).Should(Equal(exec.SourceName("some-input")))
					Ω(workerID).Should(Equal(worker.Identifier{
						BuildID: 84,
						Type:    worker.ContainerTypeGet,
						Name:    "some-input",
					}))
コード例 #10
0
ファイル: exec_engine_timeout_test.go プロジェクト: utako/atc
							Get: &atc.GetPlan{
								Name: "some-input",
							},
						},
					},
				}

				build, err := execEngine.CreateBuild(buildModel, plan)
				Ω(err).ShouldNot(HaveOccurred())
				build.Resume(logger)
			})

			It("constructs the step correctly", func() {
				Ω(fakeFactory.GetCallCount()).Should(Equal(1))
				sourceName, workerID, delegate, _, _, _, _ := fakeFactory.GetArgsForCall(0)
				Ω(sourceName).Should(Equal(exec.SourceName("some-input")))
				Ω(workerID).Should(Equal(worker.Identifier{
					BuildID: 84,
					Type:    worker.ContainerTypeGet,
					Name:    "some-input",
				}))

				Ω(delegate).Should(Equal(fakeInputDelegate))
				_, _, location := fakeDelegate.InputDelegateArgsForCall(0)
				Ω(location).ShouldNot(BeNil())
			})
		})

		Context("when the step times out", func() {
			BeforeEach(func() {
				inputStep.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
コード例 #11
0
ファイル: exec_engine_test.go プロジェクト: ACPK/atc
					Expect(logger).NotTo(BeNil())
					Expect(metadata).To(Equal(expectedMetadata))
					Expect(workerID).To(Equal(worker.Identifier{
						BuildID:      42,
						Type:         db.ContainerTypeGet,
						Name:         "some-put",
						PipelineName: "some-pipeline",
					}))

					Expect(tags).To(BeEmpty())
					Expect(delegate).To(Equal(fakeInputDelegate))
					_, plan, location := fakeDelegate.InputDelegateArgsForCall(0)
					Expect(plan).To(Equal((*outputPlan.Aggregate)[0].OnSuccess.Next.DependentGet.GetPlan()))
					Expect(location).NotTo(BeNil())

					Expect(sourceName).To(Equal(exec.SourceName("some-put")))
					Expect(resourceConfig.Name).To(Equal("some-output-resource"))
					Expect(resourceConfig.Type).To(Equal("some-type"))
					Expect(resourceConfig.Source).To(Equal(atc.Source{"some": "source"}))
					Expect(params).To(Equal(atc.Params{"another": "params"}))

					logger, metadata, sourceName, workerID, delegate, resourceConfig, tags, params = fakeFactory.DependentGetArgsForCall(1)
					Expect(logger).NotTo(BeNil())
					Expect(metadata).To(Equal(expectedMetadata))
					Expect(workerID).To(Equal(worker.Identifier{
						BuildID:      42,
						Type:         db.ContainerTypeGet,
						Name:         "some-put-2",
						PipelineName: "some-pipeline",
					}))
コード例 #12
0
				plan := planFactory.NewPlan(atc.TryPlan{
					Step: inputPlan,
				})

				build, err := execEngine.CreateBuild(logger, buildModel, plan)
				Expect(err).NotTo(HaveOccurred())
				build.Resume(logger)
			})

			It("constructs the step correctly", func() {
				Expect(fakeFactory.GetCallCount()).To(Equal(1))
				logger, metadata, sourceName, workerID, workerMetadata, delegate, _, _, _, _, _ := fakeFactory.GetArgsForCall(0)
				Expect(logger).NotTo(BeNil())
				Expect(metadata).To(Equal(expectedMetadata))
				Expect(sourceName).To(Equal(exec.SourceName("some-input")))
				Expect(workerMetadata).To(Equal(worker.Metadata{
					Type:         db.ContainerTypeGet,
					StepName:     "some-input",
					PipelineName: "some-pipeline",
				}))
				Expect(workerID).To(Equal(worker.Identifier{
					BuildID: 84,
					PlanID:  inputPlan.ID,
				}))

				Expect(delegate).To(Equal(fakeInputDelegate))
				_, _, location := fakeDelegate.InputDelegateArgsForCall(0)
				Expect(location).NotTo(BeNil())
			})
		})
コード例 #13
0
ファイル: exec_engine.go プロジェクト: utako/atc
func (build *execBuild) buildStepFactory(logger lager.Logger, plan atc.Plan) exec.StepFactory {
	if plan.Aggregate != nil {

		logger = logger.Session("aggregate")

		step := exec.Aggregate{}

		for _, innerPlan := range *plan.Aggregate {
			stepFactory := build.buildStepFactory(logger, innerPlan)

			step = append(step, stepFactory)
		}

		return step
	}

	if plan.Timeout != nil {
		step := build.buildStepFactory(logger, plan.Timeout.Step)
		return exec.Timeout(step, plan.Timeout.Duration)
	}

	if plan.Try != nil {
		step := build.buildStepFactory(logger, plan.Try.Step)
		return exec.Try(step)
	}

	if plan.OnSuccess != nil {
		step := build.buildStepFactory(logger, plan.OnSuccess.Step)
		next := build.buildStepFactory(logger, plan.OnSuccess.Next)
		return exec.OnSuccess(step, next)
	}

	if plan.OnFailure != nil {
		step := build.buildStepFactory(logger, plan.OnFailure.Step)
		next := build.buildStepFactory(logger, plan.OnFailure.Next)
		return exec.OnFailure(step, next)
	}

	if plan.Ensure != nil {
		step := build.buildStepFactory(logger, plan.Ensure.Step)
		next := build.buildStepFactory(logger, plan.Ensure.Next)
		return exec.Ensure(step, next)
	}

	if plan.Compose != nil {
		x := build.buildStepFactory(logger, plan.Compose.A)
		y := build.buildStepFactory(logger, plan.Compose.B)
		return exec.Compose(x, y)
	}

	if plan.Conditional != nil {
		logger = logger.Session("conditional", lager.Data{
			"on": plan.Conditional.Conditions,
		})

		steps := build.buildStepFactory(logger, plan.Conditional.Plan)

		return exec.Conditional{
			Conditions:  plan.Conditional.Conditions,
			StepFactory: steps,
		}
	}

	if plan.Task != nil {
		logger = logger.Session("task")

		var configSource exec.TaskConfigSource
		if plan.Task.Config != nil && plan.Task.ConfigPath != "" {
			configSource = exec.MergedConfigSource{
				A: exec.FileConfigSource{plan.Task.ConfigPath},
				B: exec.StaticConfigSource{*plan.Task.Config},
			}
		} else if plan.Task.Config != nil {
			configSource = exec.StaticConfigSource{*plan.Task.Config}
		} else if plan.Task.ConfigPath != "" {
			configSource = exec.FileConfigSource{plan.Task.ConfigPath}
		} else {
			return exec.Identity{}
		}

		var location event.OriginLocation
		if plan.Location != nil {
			location = event.OriginLocationFrom(*plan.Location)
		}

		return build.factory.Task(
			exec.SourceName(plan.Task.Name),
			build.taskIdentifier(plan.Task.Name, location),
			build.delegate.ExecutionDelegate(logger, *plan.Task, location),
			exec.Privileged(plan.Task.Privileged),
			plan.Task.Tags,
			configSource,
		)
	}

	if plan.Get != nil {
		logger = logger.Session("get", lager.Data{
			"name": plan.Get.Name,
		})

		var location event.OriginLocation
		if plan.Location != nil {
			location = event.OriginLocationFrom(*plan.Location)
		}

		return build.factory.Get(
			exec.SourceName(plan.Get.Name),
			build.getIdentifier(plan.Get.Name, location),
			build.delegate.InputDelegate(logger, *plan.Get, location),
			atc.ResourceConfig{
				Name:   plan.Get.Resource,
				Type:   plan.Get.Type,
				Source: plan.Get.Source,
			},
			plan.Get.Params,
			plan.Get.Tags,
			plan.Get.Version,
		)
	}

	if plan.Put != nil {
		logger = logger.Session("put", lager.Data{
			"name": plan.Put.Name,
		})

		var location event.OriginLocation
		if plan.Location != nil {
			location = event.OriginLocationFrom(*plan.Location)
		}

		return build.factory.Put(
			build.putIdentifier(plan.Put.Name, location),
			build.delegate.OutputDelegate(logger, *plan.Put, location),
			atc.ResourceConfig{
				Name:   plan.Put.Resource,
				Type:   plan.Put.Type,
				Source: plan.Put.Source,
			},
			plan.Put.Tags,
			plan.Put.Params,
		)
	}

	if plan.DependentGet != nil {
		logger = logger.Session("get", lager.Data{
			"name": plan.DependentGet.Name,
		})

		var location event.OriginLocation
		if plan.Location != nil {
			location = event.OriginLocationFrom(*plan.Location)
		}

		getPlan := plan.DependentGet.GetPlan()
		return build.factory.DependentGet(
			exec.SourceName(getPlan.Name),
			build.getIdentifier(getPlan.Name, location),
			build.delegate.InputDelegate(logger, getPlan, location),
			atc.ResourceConfig{
				Name:   getPlan.Resource,
				Type:   getPlan.Type,
				Source: getPlan.Source,
			},
			getPlan.Tags,
			getPlan.Params,
		)
	}

	return exec.Identity{}
}