Skip to content

Commit

Permalink
Use the condition name in tekton.dev/conditionCheck
Browse files Browse the repository at this point in the history
The condition is implemented with a TaskRun. Right now the TaskRun
is labelled with tekton.dev/conditionCheck which contains the
name of the TaskRun itself. We should instead use the label to
carry data that is useful for discovering this TaskRun, and which
is not already available, i.e. the name of the Condition from
which the TaskRun was generated.
  • Loading branch information
afrittoli committed May 7, 2020
1 parent c861b37 commit c36caa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ func (c *Reconciler) updateLabelsAndAnnotations(pr *v1alpha1.PipelineRun) (*v1al

func (c *Reconciler) makeConditionCheckContainer(rprt *resources.ResolvedPipelineRunTask, rcc *resources.ResolvedConditionCheck, pr *v1alpha1.PipelineRun) (*v1alpha1.ConditionCheck, error) {
labels := getTaskrunLabels(pr, rprt.PipelineTask.Name)
labels[pipeline.GroupName+pipeline.ConditionCheckKey] = rcc.ConditionCheckName
labels[pipeline.GroupName+pipeline.ConditionCheckKey] = rcc.Condition.Name

for key, value := range rcc.Condition.ObjectMeta.Labels {
labels[key] = value
Expand Down
12 changes: 6 additions & 6 deletions pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ func TestReconcileWithFailingConditionChecks(t *testing.T) {
tb.TaskRunOwnerReference("kind", "name"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineLabelKey, "test-pipeline-run-with-conditions"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineRunLabelKey, "test-pipeline"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.ConditionCheckKey, conditionCheckName),
tb.TaskRunLabel(pipeline.GroupName+pipeline.ConditionCheckKey, "always-false"),
tb.TaskRunSpec(tb.TaskRunTaskSpec()),
tb.TaskRunStatus(tb.StatusCondition(apis.Condition{
Type: apis.ConditionSucceeded,
Expand Down Expand Up @@ -1657,9 +1657,9 @@ func TestReconcileWithFailingConditionChecks(t *testing.T) {
tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"),
tb.Controller, tb.BlockOwnerDeletion,
),
tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineLabelKey, "test-pipeline"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineTaskLabelKey, "task-3"),
tb.TaskRunLabel("tekton.dev/pipelineRun", "test-pipeline-run-with-conditions"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineRunLabelKey, "test-pipeline-run-with-conditions"),
tb.TaskRunAnnotation("PipelineRunAnnotation", "PipelineRunValue"),
tb.TaskRunSpec(
tb.TaskRunTaskRef("hello-world"),
Expand All @@ -1679,10 +1679,10 @@ func makeExpectedTr(condName, ccName string, labels map[string]string) *v1alpha1
tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"),
tb.Controller, tb.BlockOwnerDeletion,
),
tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineLabelKey, "test-pipeline"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineTaskLabelKey, "hello-world-1"),
tb.TaskRunLabel("tekton.dev/pipelineRun", "test-pipeline-run"),
tb.TaskRunLabel("tekton.dev/conditionCheck", ccName),
tb.TaskRunLabel(pipeline.GroupName+pipeline.PipelineRunLabelKey, "test-pipeline-run"),
tb.TaskRunLabel(pipeline.GroupName+pipeline.ConditionCheckKey, condName),
tb.TaskRunLabels(labels),
tb.TaskRunAnnotation("PipelineRunAnnotation", "PipelineRunValue"),
tb.TaskRunSpec(
Expand Down

0 comments on commit c36caa7

Please sign in to comment.