Example #1
0
func (build *execBuild) buildPutStep(logger lager.Logger, plan atc.Plan) exec.StepFactory {
	logger = logger.Session("put", lager.Data{
		"name": plan.Put.Name,
	})

	workerID, workerMetadata := build.stepIdentifier(
		logger.Session("stepIdentifier"),
		plan.Put.Name,
		plan.ID,
		plan.Put.PipelineID,
		plan.Attempts,
		"put",
	)

	return build.factory.Put(
		logger,
		build.stepMetadata,
		workerID,
		workerMetadata,
		build.delegate.OutputDelegate(logger, *plan.Put, event.OriginID(plan.ID)),
		atc.ResourceConfig{
			Name:   plan.Put.Resource,
			Type:   plan.Put.Type,
			Source: plan.Put.Source,
		},
		plan.Put.Tags,
		plan.Put.Params,
		plan.Put.ResourceTypes,
	)
}
Example #2
0
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,
	)
}
Example #3
0
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,
	)
}
		logger *lagertest.TestLogger

		originID event.OriginID
	)

	BeforeEach(func() {
		fakeDB = new(fakes.FakeEngineDB)
		factory = NewBuildDelegateFactory(fakeDB)

		buildID = 42
		delegate = factory.Delegate(buildID)

		logger = lagertest.NewTestLogger("test")

		originID = event.OriginID("some-origin-id")
	})

	Describe("InputDelegate", func() {
		var (
			getPlan atc.GetPlan

			inputDelegate exec.GetDelegate
		)

		BeforeEach(func() {
			getPlan = atc.GetPlan{
				Name:     "some-input",
				Resource: "some-input-resource",
				Pipeline: "some-pipeline",
				Type:     "some-type",
Example #5
0
					Expect(workerID).To(Equal(worker.Identifier{
						BuildID: 42,
						PlanID:  plan.ID,
					}))

					Expect(tags).To(ConsistOf("some", "get", "tags"))
					Expect(resourceConfig.Name).To(Equal("some-input-resource"))
					Expect(resourceConfig.Type).To(Equal("get"))
					Expect(resourceConfig.Source).To(Equal(atc.Source{"some": "source"}))
					Expect(params).To(Equal(atc.Params{"some": "params"}))
					Expect(version).To(Equal(atc.Version{"some": "version"}))

					Expect(delegate).To(Equal(fakeInputDelegate))

					_, _, planID := fakeDelegate.InputDelegateArgsForCall(0)
					Expect(planID).To(Equal(event.OriginID(plan.ID)))
				})

				It("releases inputs correctly", func() {
					inputStep.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
						defer GinkgoRecover()
						Consistently(inputStep.ReleaseCallCount).Should(BeZero())
						return nil
					}
					var err error
					build, err = execEngine.CreateBuild(logger, buildModel, plan)
					Expect(err).NotTo(HaveOccurred())
					build.Resume(logger)

					Expect(inputStep.ReleaseCallCount()).To(Equal(1))
				})