Skip to content

Commit

Permalink
build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom committed Jul 1, 2019
1 parent 7bc7791 commit fcaa33d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
7 changes: 4 additions & 3 deletions pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) er
} else if !rprt.ResolvedConditionChecks.HasStarted() {
for _, rcc := range rprt.ResolvedConditionChecks {
rcc.ConditionCheck, err = c.makeConditionCheckContainer(c.Logger, rprt, rcc, pr)
if err != nil {
c.Recorder.Eventf(pr, corev1.EventTypeWarning, "ConditionCheckCreationFailed", "Failed to create TaskRun %q: %v", rcc.ConditionCheckName, err)
return xerrors.Errorf("error creating ConditionCheck container called %s for PipelineTask %s from PipelineRun %s: %w", rcc.ConditionCheckName, rprt.PipelineTask.Name, pr.Name, err)
}
}
}
}
Expand Down Expand Up @@ -592,9 +596,6 @@ func (c *Reconciler) makeConditionCheckContainer(logger *zap.SugaredLogger, rprt
labels := getTaskrunLabels(pr, rprt.PipelineTask.Name)
labels[pipeline.GroupName+pipeline.PipelineRunConditionCheckKey] = rcc.ConditionCheckName

c.Logger.Warnf("!!!!!!!!ConditionCheck name is %s", rcc.ConditionCheckName)
c.Logger.Warnf("!!!RCC is %+v", rcc)

tr := &v1alpha1.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Name: rcc.ConditionCheckName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,9 @@ func ResolvePipelineRun(

// Get all conditions that this pipelineTask will be using, if any
if len(pt.Conditions) > 0 {
rcc := []*ResolvedConditionCheck{}
for j := range pt.Conditions {
cName := pt.Conditions[j].ConditionRef
c, err := getCondition(cName)
if err != nil {
return nil, xerrors.Errorf("error retrieving Condition %s: %w", cName, err)
}
conditionCheckName := getConditionCheckName(pipelineRun.Status.TaskRuns, rprt.TaskRunName, cName)
conditionCheck, err := getTaskRun(conditionCheckName) // TODO: Wrap this onto something else?
if err != nil {
if !errors.IsNotFound(err) {
return nil, xerrors.Errorf("error retrieving ConditionCheck %s: %w", conditionCheckName, err)
}
}
rcc = append(rcc, &ResolvedConditionCheck{
Condition: c,
ConditionCheckName: conditionCheckName,
ConditionCheck: conditionCheck,
})
rcc, err := resolveConditionChecks(&pt, pipelineRun.Status.TaskRuns, rprt.TaskRunName, getTaskRun, getCondition)
if err != nil {
return nil, xerrors.Errorf("error resolving condition checks for Taskrun %s: %w", rprt.TaskRunName, err)
}
rprt.ResolvedConditionChecks = rcc
}
Expand Down Expand Up @@ -451,3 +435,30 @@ func ValidateFrom(state PipelineRunState) error {

return nil
}


func resolveConditionChecks(pt *v1alpha1.PipelineTask,
taskRunStatus map[string]*v1alpha1.PipelineRunTaskRunStatus,
taskRunName string, getTaskRun resources.GetTaskRun, getCondition GetCondition) ([]*ResolvedConditionCheck, error){
rcc := []*ResolvedConditionCheck{}
for j := range pt.Conditions {
cName := pt.Conditions[j].ConditionRef
c, err := getCondition(cName)
if err != nil {
return nil, xerrors.Errorf("error retrieving Condition %s: %w", cName, err)
}
conditionCheckName := getConditionCheckName(taskRunStatus, taskRunName, cName)
conditionCheck, err := getTaskRun(conditionCheckName) // TODO: Wrap this onto something else?
if err != nil {
if !errors.IsNotFound(err) {
return nil, xerrors.Errorf("error retrieving ConditionCheck %s: %w", conditionCheckName, err)
}
}
rcc = append(rcc, &ResolvedConditionCheck{
Condition: c,
ConditionCheckName: conditionCheckName,
ConditionCheck: conditionCheck,
})
}
return rcc, nil
}

0 comments on commit fcaa33d

Please sign in to comment.