Beispiel #1
0
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,
	)
}
Beispiel #2
0
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,
	)
}
Beispiel #3
0
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{}
}