Skip to content

Commit

Permalink
Ensure resource defaulting is always done regardless of ref type.
Browse files Browse the repository at this point in the history
Previously we were only setting defaults for k8s API based resources.
This change ensures defaulting is done after we've extracted the
spec, making it agnostic to the resolver type.
  • Loading branch information
wlynch authored and tekton-robot committed Oct 18, 2022
1 parent ac8da46 commit d015c94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getP
}
pipelineMeta = t.PipelineMetadata()
pipelineSpec = t.PipelineSpec()
pipelineSpec.SetDefaults(ctx)
case pipelineRun.Spec.PipelineSpec != nil:
pipelineMeta = pipelineRun.ObjectMeta
pipelineSpec = *pipelineRun.Spec.PipelineSpec
Expand All @@ -61,5 +60,7 @@ func GetPipelineData(ctx context.Context, pipelineRun *v1beta1.PipelineRun, getP
default:
return nil, nil, fmt.Errorf("pipelineRun %s not providing PipelineRef or PipelineSpec", pipelineRun.Name)
}

pipelineSpec.SetDefaults(ctx)
return &pipelineMeta, &pipelineSpec, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func TestGetPipelineData_ResolutionSuccess(t *testing.T) {
Tasks: []v1beta1.PipelineTask{{
Name: "pt1",
TaskRef: &v1beta1.TaskRef{
Kind: "Task",
Name: "tref",
},
}},
Expand Down
3 changes: 2 additions & 1 deletion pkg/reconciler/taskrun/resources/taskspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask)
}
taskMeta = t.TaskMetadata()
taskSpec = t.TaskSpec()
taskSpec.SetDefaults(ctx)
case taskRun.Spec.TaskSpec != nil:
taskMeta = taskRun.ObjectMeta
taskSpec = *taskRun.Spec.TaskSpec
Expand All @@ -67,5 +66,7 @@ func GetTaskData(ctx context.Context, taskRun *v1beta1.TaskRun, getTask GetTask)
default:
return nil, nil, fmt.Errorf("taskRun %s not providing TaskRef or TaskSpec", taskRun.Name)
}

taskSpec.SetDefaults(ctx)
return &taskMeta, &taskSpec, nil
}

0 comments on commit d015c94

Please sign in to comment.