From f9bd8ee12f2b2458d253293bd83e2640ad4f70a9 Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Thu, 24 Jan 2019 15:12:35 -0800 Subject: [PATCH] Rename `providedBy` to `from` `providedBy` was a way for users to indicate when a Tasks's input should come from the output of another Task - including any changes that Task had made to it (e.g. adding files to a checkout of a git repo by building a binary). We have struggled with an intuitive way to describe it - orginally this was called `passedConstraint`. In the design doc for #320, @sebgoa suggested we call this `from` which seems like the clearest name yet! Fixes #320 (remaining item in #320 to add `runAfter` will be moved to another issue) --- docs/developers/README.md | 2 +- docs/tutorial.md | 4 +- docs/using.md | 28 +++++------ examples/README.md | 6 +-- examples/output-pipeline.yaml | 2 +- examples/pipeline.yaml | 4 +- pkg/apis/pipeline/v1alpha1/pipeline_types.go | 4 +- .../pipeline/v1alpha1/pipeline_validation.go | 18 ++++---- .../v1alpha1/pipeline_validation_test.go | 18 ++++---- .../v1alpha1/zz_generated.deepcopy.go | 4 +- .../v1alpha1/pipeline/resources/dag.go | 4 +- .../v1alpha1/pipeline/resources/dag_test.go | 16 +++---- .../v1alpha1/pipelinerun/pipelinerun.go | 2 +- .../v1alpha1/pipelinerun/pipelinerun_test.go | 2 +- .../resources/input_output_steps.go | 6 +-- .../resources/input_output_steps_test.go | 12 ++--- .../resources/pipelinerunresolution.go | 12 ++--- .../resources/pipelinerunresolution_test.go | 46 +++++++++---------- test/builder/pipeline.go | 6 +-- test/builder/pipeline_test.go | 8 ++-- test/pipelinerun_test.go | 6 +-- 21 files changed, 105 insertions(+), 105 deletions(-) diff --git a/docs/developers/README.md b/docs/developers/README.md index 2d2ac9a45b9..3407ae84fa8 100644 --- a/docs/developers/README.md +++ b/docs/developers/README.md @@ -12,7 +12,7 @@ on path `/pvc` by PipelineRun. adds a step to copy each output resource to the directory path `/pvc/task_name/resource_name`. -- If an input resource includes `providedBy` condition then the `TaskRun` +- If an input resource includes `from` condition then the `TaskRun` controller adds a step to copy from PVC to directory path `/pvc/previous_task/resource_name`. diff --git a/docs/tutorial.md b/docs/tutorial.md index 856e8c2ebb8..f93180cd0bd 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -329,7 +329,7 @@ resource definition. A [`Pipeline`](concepts.md#pipelines) defines a list of tasks to execute in order, while also indicating if any outputs should be used as inputs -of a following task by using [the `providedBy` field](using.md#providedby). +of a following task by using [the `from` field](using.md#from). The same templating you used in tasks is also available in pipeline. For example: @@ -370,7 +370,7 @@ spec: resource: source-repo - name: image resource: web-image - providedBy: + from: - build-skaffold-web params: - name: path diff --git a/docs/using.md b/docs/using.md index d42e834357e..6de899fa8fc 100644 --- a/docs/using.md +++ b/docs/using.md @@ -16,7 +16,7 @@ specific to your project (e.g. running your particular set of unit tests). 2. Create a `Pipeline` which expresses the Tasks you would like to run and what [PipelineResources](#resources-in-a-pipeline) the Tasks need. Use - [`providedBy`](#providedBy) to express when the input of a `Task` should come + [`from`](#from) to express when the input of a `Task` should come from the output of a previous `Task`. See [the example Pipeline](../examples/pipeline.yaml). @@ -24,7 +24,7 @@ See [the example Pipeline](../examples/pipeline.yaml). ### PipelineResources in a Pipeline In order for a `Pipeline` to execute, it will probably need -[`PipelineResources`](#creating-pipelineresources) which will be provided to +[`PipelineResources`](#creating-pipelineresources) which will be given to `Tasks` as inputs and outputs. Your `Pipeline` must declare the `PipelineResources` it needs in a `resources` @@ -42,7 +42,7 @@ spec: type: image ``` -These `PipelineResources` can then be provided to `Task`s in the `Pipeline` as +These `PipelineResources` can then be given to `Task`s in the `Pipeline` as inputs and outputs, for example: ```yaml @@ -61,21 +61,21 @@ spec: resource: my-image ``` -### ProvidedBy +### From Sometimes you will have `Tasks` that need to take as input the output of a previous `Task`, for example, an image built by a previous `Task`. -Express this dependency by adding `providedBy` on `Resources` that your `Tasks` +Express this dependency by adding `from` on `Resources` that your `Tasks` need. -- The (optional) `providedBy` key on an `input source` defines a set of previous +- The (optional) `from` key on an `input source` defines a set of previous `PipelineTasks` (i.e. the named instance of a `Task`) in the `Pipeline` -- When the `providedBy` key is specified on an input source, the version of - the resource that is provided by the defined list of tasks is used -- The `providedBy` can support fan in and fan out +- When the `from` key is specified on an input source, the version of + the resource that is from the defined list of tasks is used +- `from` can support fan in and fan out - The name of the `PipelineResource` must correspond to a `PipelineResource` - from the `Task` that the referenced `PipelineTask` provides as an output + from the `Task` that the referenced `PipelineTask` gives as an output For example see this `Pipeline` spec: @@ -93,11 +93,11 @@ For example see this `Pipeline` spec: resources: inputs: - name: my-image - providedBy: + from: - build-app ``` -The resource `my-image` is expected to be provided to the `deploy-app` `Task` from +The resource `my-image` is expected to be given to the `deploy-app` `Task` from the `build-app` `Task`. This means that the `PipelineResource` `my-image` must also be declared as an output of `build-app`. @@ -184,7 +184,7 @@ configure that by edit the `image`'s value in a configmap named ### Resource sharing between tasks Pipeline `Tasks` are allowed to pass resources from previous `Tasks` via the -[`providedBy`](#providedby) field. This feature is implemented using +[`from`](#from) field. This feature is implemented using Persistent Volume Claims under the hood but however has an implication that tasks cannot have any volume mounted under path `/pvc`. @@ -338,7 +338,7 @@ In order to run a Pipeline, you will need to provide: 2. The `PipelineResources` to use with this Pipeline. On its own, a `Pipeline` declares what `Tasks` to run, and dependencies between -`Task` inputs and outputs via [`providedBy`](#providedby). When running a `Pipeline`, you +`Task` inputs and outputs via [`from`](#from). When running a `Pipeline`, you will need to specify the `PipelineResources` to use with it. One `Pipeline` may need to be run with different `PipelineResources` in cases such as: diff --git a/examples/README.md b/examples/README.md index 1a8c1df2f70..dbf7540ba42 100644 --- a/examples/README.md +++ b/examples/README.md @@ -66,15 +66,15 @@ The [run](./run/) directory contains an example ### Pipeline with outputs [The Pipeline with outputs](output-pipeline.yaml) contains a Pipeline that -demonstrates how the outputs of a `Task` can be provided as inputs to the next +demonstrates how the outputs of a `Task` can be given as inputs to the next `Task`. It does this by: 1. Running a `Task` that writes to a `PipelineResource` 2. Running a `Task` that reads the written value from the `PipelineResource` -The [`Output`](../docs/Concepts.md#outputs) of the first `Task` is provided as +The [`Output`](../docs/Concepts.md#outputs) of the first `Task` is given as an [`Input`](../docs/Concepts.md#inputs) to the next `Task` thanks to the -[`providedBy`](../docs/using.md#providedby) clause. +[`from`](../docs/using.md#from) clause. #### Output Tasks diff --git a/examples/output-pipeline.yaml b/examples/output-pipeline.yaml index 8a74b49d3d0..2e8657f8ddb 100644 --- a/examples/output-pipeline.yaml +++ b/examples/output-pipeline.yaml @@ -24,4 +24,4 @@ spec: inputs: - name: workspace resource: source-repo - providedBy: [first-create-file] + from: [first-create-file] diff --git a/examples/pipeline.yaml b/examples/pipeline.yaml index a0bd0d1fc1b..15d8688da61 100644 --- a/examples/pipeline.yaml +++ b/examples/pipeline.yaml @@ -50,7 +50,7 @@ spec: resource: source-repo - name: image resource: app-image - providedBy: + from: - build-skaffold-app params: - name: path @@ -68,7 +68,7 @@ spec: resource: source-repo - name: image resource: web-image - providedBy: + from: - build-skaffold-web params: - name: path diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_types.go b/pkg/apis/pipeline/v1alpha1/pipeline_types.go index 67729a12635..8e8acb64997 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_types.go @@ -116,9 +116,9 @@ type PipelineTaskInputResource struct { Name string `json:"name"` // Resource is the name of the DeclaredPipelineResource to use. Resource string `json:"resource"` - // ProvidedBy is the list of PipelineTask names that the resource has to come from. + // From is the list of PipelineTask names that the resource has to come from. // +optional - ProvidedBy []string `json:"providedBy,omitempty"` + From []string `json:"from,omitempty"` } // PipelineTaskOutputResource maps the name of a declared PipelineResource output diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_validation.go b/pkg/apis/pipeline/v1alpha1/pipeline_validation.go index 0fd59746aac..85cef07eae5 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_validation.go @@ -66,14 +66,14 @@ func isOutput(task PipelineTask, resource string) bool { return false } -// validateProvidedBy ensures that the `providedBy` values make sense: that they rely on values from Tasks +// validateFrom ensures that the `from` values make sense: that they rely on values from Tasks // that ran previously, and that the PipelineResource is actually an output of the Task it should come from. // TODO(#168) when pipelines don't just execute linearly this will need to be more sophisticated -func validateProvidedBy(tasks []PipelineTask) error { +func validateFrom(tasks []PipelineTask) error { for i, t := range tasks { if t.Resources != nil { for _, rd := range t.Resources.Inputs { - for _, pb := range rd.ProvidedBy { + for _, pb := range rd.From { if i == 0 { return fmt.Errorf("first Task in Pipeline can't depend on anything before it (b/c there is nothing)") } @@ -81,15 +81,15 @@ func validateProvidedBy(tasks []PipelineTask) error { // Look for previous Task that satisfies constraint for j := i - 1; j >= 0; j-- { if tasks[j].Name == pb { - // The input resource must actually be an output of the providedBy tasks + // The input resource must actually be an output of the from tasks if !isOutput(tasks[j], rd.Resource) { - return fmt.Errorf("the resource %s provided by %s must be an output but is an input", rd.Resource, pb) + return fmt.Errorf("the resource %s from %s must be an output but is an input", rd.Resource, pb) } found = true } } if !found { - return fmt.Errorf("expected resource %s to be provided by task %s, but task %s doesn't exist", rd.Resource, pb, pb) + return fmt.Errorf("expected resource %s to be from task %s, but task %s doesn't exist", rd.Resource, pb, pb) } } } @@ -120,9 +120,9 @@ func (ps *PipelineSpec) Validate() *apis.FieldError { return apis.ErrInvalidValue(err.Error(), "spec.resources") } - // The providedBy values should make sense - if err := validateProvidedBy(ps.Tasks); err != nil { - return apis.ErrInvalidValue(err.Error(), "spec.tasks.resources.inputs.providedBy") + // The from values should make sense + if err := validateFrom(ps.Tasks); err != nil { + return apis.ErrInvalidValue(err.Error(), "spec.tasks.resources.inputs.from") } return nil } diff --git a/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go b/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go index 0b9256d1f7b..448bd1dff22 100644 --- a/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go @@ -36,28 +36,28 @@ func TestPipelineSpec_Validate_Error(t *testing.T) { )), }, { - name: "providedby is on first task", + name: "from is on first task", p: tb.Pipeline("pipeline", "namespace", tb.PipelineSpec( tb.PipelineDeclaredResource("great-resource", v1alpha1.PipelineResourceTypeGit), tb.PipelineTask("foo", "foo-task", - tb.PipelineTaskInputResource("the-resource", "great-resource", tb.ProvidedBy("bar"))), + tb.PipelineTaskInputResource("the-resource", "great-resource", tb.From("bar"))), )), }, { - name: "providedby task doesnt exist", + name: "from task doesnt exist", p: tb.Pipeline("pipeline", "namespace", tb.PipelineSpec( tb.PipelineDeclaredResource("great-resource", v1alpha1.PipelineResourceTypeGit), tb.PipelineTask("baz", "baz-task"), tb.PipelineTask("foo", "foo-task", - tb.PipelineTaskInputResource("the-resource", "great-resource", tb.ProvidedBy("bar"))), + tb.PipelineTaskInputResource("the-resource", "great-resource", tb.From("bar"))), )), }, { - name: "providedby task is afterward", + name: "from task is afterward", p: tb.Pipeline("pipeline", "namespace", tb.PipelineSpec( tb.PipelineDeclaredResource("great-resource", v1alpha1.PipelineResourceTypeGit), tb.PipelineTask("foo", "foo-task", - tb.PipelineTaskInputResource("the-resource", "great-resource", tb.ProvidedBy("bar"))), + tb.PipelineTaskInputResource("the-resource", "great-resource", tb.From("bar"))), tb.PipelineTask("bar", "bar-task", tb.PipelineTaskOutputResource("the-resource", "great-resource")), )), @@ -90,14 +90,14 @@ func TestPipelineSpec_Validate_Error(t *testing.T) { )), }, { - name: "providedBy resource isn't output by task", + name: "from resource isn't output by task", p: tb.Pipeline("pipeline", "namespace", tb.PipelineSpec( tb.PipelineDeclaredResource("great-resource", v1alpha1.PipelineResourceTypeGit), tb.PipelineDeclaredResource("wonderful-resource", v1alpha1.PipelineResourceTypeImage), tb.PipelineTask("bar", "bar-task", tb.PipelineTaskInputResource("some-workspace", "great-resource")), tb.PipelineTask("foo", "foo-task", - tb.PipelineTaskInputResource("wow-image", "wonderful-resource", tb.ProvidedBy("bar"))), + tb.PipelineTaskInputResource("wow-image", "wonderful-resource", tb.From("bar"))), )), }, } @@ -141,7 +141,7 @@ func TestPipelineSpec_Validate_Valid(t *testing.T) { tb.PipelineTaskInputResource("some-workspace", "great-resource"), tb.PipelineTaskOutputResource("some-image", "wonderful-resource")), tb.PipelineTask("foo", "foo-task", - tb.PipelineTaskInputResource("wow-image", "wonderful-resource", tb.ProvidedBy("bar"))), + tb.PipelineTaskInputResource("wow-image", "wonderful-resource", tb.From("bar"))), )), }, } diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go index 7d7baefdc94..1640710074e 100644 --- a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -675,8 +675,8 @@ func (in *PipelineTask) DeepCopy() *PipelineTask { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PipelineTaskInputResource) DeepCopyInto(out *PipelineTaskInputResource) { *out = *in - if in.ProvidedBy != nil { - in, out := &in.ProvidedBy, &out.ProvidedBy + if in.From != nil { + in, out := &in.From, &out.From *out = make([]string, len(*in)) copy(*out, *in) } diff --git a/pkg/reconciler/v1alpha1/pipeline/resources/dag.go b/pkg/reconciler/v1alpha1/pipeline/resources/dag.go index 49ddb107a4b..4c80c58e466 100644 --- a/pkg/reconciler/v1alpha1/pipeline/resources/dag.go +++ b/pkg/reconciler/v1alpha1/pipeline/resources/dag.go @@ -103,11 +103,11 @@ func Build(p *v1alpha1.Pipeline) (*DAG, error) { return nil, errors.NewDuplicatePipelineTask(p, pt.Name) } } - // Process all providedBy constraints to add task dependency + // Process all from constraints to add task dependency for _, pt := range p.Spec.Tasks { if pt.Resources != nil { for _, rd := range pt.Resources.Inputs { - for _, constraint := range rd.ProvidedBy { + for _, constraint := range rd.From { // We need to add dependency from constraint to node n prev, ok := d.Nodes[constraint] if !ok { diff --git a/pkg/reconciler/v1alpha1/pipeline/resources/dag_test.go b/pkg/reconciler/v1alpha1/pipeline/resources/dag_test.go index 78e2628ca1b..e6c1024fc96 100644 --- a/pkg/reconciler/v1alpha1/pipeline/resources/dag_test.go +++ b/pkg/reconciler/v1alpha1/pipeline/resources/dag_test.go @@ -31,37 +31,37 @@ func TestBuild(t *testing.T) { xDependsOnA := v1alpha1.PipelineTask{ Name: "x", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"a"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"a"}}}, }, } yDependsOnAB := v1alpha1.PipelineTask{ Name: "y", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"b", "a"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"b", "a"}}}, }, } zDependsOnX := v1alpha1.PipelineTask{ Name: "z", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"x"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"x"}}}, }, } aDependsOnZ := v1alpha1.PipelineTask{ Name: "a", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"z"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"z"}}}, }, } selfLink := v1alpha1.PipelineTask{ Name: "a", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"a"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"a"}}}, }, } invalidTask := v1alpha1.PipelineTask{ Name: "a", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"none"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"none"}}}, }, } nodeX := &Node{Task: xDependsOnA, Prev: []*Node{{Task: a}}} @@ -149,13 +149,13 @@ func TestGetPrevTasks(t *testing.T) { x := v1alpha1.PipelineTask{ Name: "x", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"a"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"a"}}}, }, } y := v1alpha1.PipelineTask{ Name: "y", Resources: &v1alpha1.PipelineTaskResources{ - Inputs: []v1alpha1.PipelineTaskInputResource{{ProvidedBy: []string{"x", "a"}}}, + Inputs: []v1alpha1.PipelineTaskInputResource{{From: []string{"x", "a"}}}, }, } p := v1alpha1.Pipeline{ diff --git a/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go b/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go index fcaef129d71..a6d1f8b255f 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go @@ -249,7 +249,7 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1alpha1.PipelineRun) er return nil } - if err := resources.ValidateProvidedBy(pipelineState); err != nil { + if err := resources.ValidateFrom(pipelineState); err != nil { // This Run has failed, so we need to mark it as failed and stop reconciling it pr.Status.SetCondition(&duckv1alpha1.Condition{ Type: duckv1alpha1.ConditionSucceeded, diff --git a/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun_test.go b/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun_test.go index 3aafa80e728..e75b0276e61 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun_test.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/pipelinerun_test.go @@ -93,7 +93,7 @@ func TestReconcile(t *testing.T) { tb.PipelineTaskOutputResource("workspace", "git-repo"), ), tb.PipelineTask("unit-test-2", "unit-test-followup-task", - tb.PipelineTaskInputResource("workspace", "git-repo", tb.ProvidedBy("unit-test-1")), + tb.PipelineTaskInputResource("workspace", "git-repo", tb.From("unit-test-1")), ), tb.PipelineTask("unit-test-cluster-task", "unit-test-cluster-task", tb.PipelineTaskRefKind(v1alpha1.ClusterTaskKind), diff --git a/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps.go b/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps.go index 1d582f3f32c..6458bcf9ccd 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps.go @@ -43,8 +43,8 @@ func GetOutputSteps(outputs map[string]*v1alpha1.PipelineResource, taskName stri return taskOutputResources } -// GetInputSteps will add the correct `path` to the input resources for pt. If the resources are provided by -// a previous task, the correct `path` will be used so that the resource provided by that task will be used. +// GetInputSteps will add the correct `path` to the input resources for pt. If the resources are from +// a previous task, the correct `path` will be used so that the resource from that task will be used. func GetInputSteps(inputs map[string]*v1alpha1.PipelineResource, pt *v1alpha1.PipelineTask) []v1alpha1.TaskResourceBinding { var taskInputResources []v1alpha1.TaskResourceBinding @@ -61,7 +61,7 @@ func GetInputSteps(inputs map[string]*v1alpha1.PipelineResource, pt *v1alpha1.Pi if pt.Resources != nil { for _, pipelineTaskInput := range pt.Resources.Inputs { if pipelineTaskInput.Name == name { - for _, constr := range pipelineTaskInput.ProvidedBy { + for _, constr := range pipelineTaskInput.From { stepSourceNames = append(stepSourceNames, filepath.Join(pvcDir, constr, name)) } } diff --git a/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps_test.go b/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps_test.go index c6164aca52b..cf8cb4c49bf 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps_test.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/resources/input_output_steps_test.go @@ -95,8 +95,8 @@ func Test_GetInputSteps(t *testing.T) { pipelineTask: &v1alpha1.PipelineTask{ Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "test-input", - ProvidedBy: []string{"prev-task-1"}, + Name: "test-input", + From: []string{"prev-task-1"}, }}, }, }, @@ -121,8 +121,8 @@ func Test_GetInputSteps(t *testing.T) { pipelineTask: &v1alpha1.PipelineTask{ Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "test-input", - ProvidedBy: []string{"prev-task-1", "prev-task-2"}, + Name: "test-input", + From: []string{"prev-task-1", "prev-task-2"}, }}, }, }, @@ -162,8 +162,8 @@ func Test_WrapSteps(t *testing.T) { Name: "test-task", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "test-input", - ProvidedBy: []string{"prev-task"}, + Name: "test-input", + From: []string{"prev-task"}, }}, }, } diff --git a/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go b/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go index 56a9866bc24..aa0f4311f23 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go @@ -282,17 +282,17 @@ func findReferencedTask(pb string, state []*ResolvedPipelineRunTask) *ResolvedPi return nil } -// ValidateProvidedBy will look at any `providedBy` clauses in the resolved PipelineRun state -// and validate it: the `providedBy` must specify an input of the current `Task`. The `PipelineTask` -// it is provided by must actually exist in the `Pipeline`. The `PipelineResource` that is bound to the input +// ValidateFrom will look at any `from` clauses in the resolved PipelineRun state +// and validate it: the `from` must specify an input of the current `Task`. The `PipelineTask` +// it corresponds to must actually exist in the `Pipeline`. The `PipelineResource` that is bound to the input // must be the same `PipelineResource` that was bound to the output of the previous `Task`. If the state is // not valid, it will return an error. -func ValidateProvidedBy(state []*ResolvedPipelineRunTask) error { +func ValidateFrom(state []*ResolvedPipelineRunTask) error { for _, rprt := range state { if rprt.PipelineTask.Resources != nil { for _, dep := range rprt.PipelineTask.Resources.Inputs { inputBinding := rprt.ResolvedTaskResources.Inputs[dep.Name] - for _, pb := range dep.ProvidedBy { + for _, pb := range dep.From { if pb == rprt.PipelineTask.Name { return fmt.Errorf("PipelineTask %s is trying to depend on a PipelineResource from itself", pb) } @@ -308,7 +308,7 @@ func ValidateProvidedBy(state []*ResolvedPipelineRunTask) error { } } if !sameBindingExists { - return fmt.Errorf("providedBy is ambiguous: input %q for PipelineTask %q is bound to %q but no outputs in PipelineTask %q are bound to same resource", + return fmt.Errorf("from is ambiguous: input %q for PipelineTask %q is bound to %q but no outputs in PipelineTask %q are bound to same resource", dep.Name, rprt.PipelineTask.Name, inputBinding.Name, depTask.PipelineTask.Name) } } diff --git a/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution_test.go b/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution_test.go index 5d059daae39..b0c4572de27 100644 --- a/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution_test.go +++ b/pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution_test.go @@ -679,7 +679,7 @@ func TestGetPipelineConditionStatus(t *testing.T) { } } -func TestValidateProvidedBy(t *testing.T) { +func TestValidateFrom(t *testing.T) { r := tb.PipelineResource("holygrail", namespace, tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage)) state := []*ResolvedPipelineRunTask{{ PipelineTask: &v1alpha1.PipelineTask{ @@ -696,8 +696,8 @@ func TestValidateProvidedBy(t *testing.T) { Name: "winning", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "awesome-thing", - ProvidedBy: []string{"quest"}, + Name: "awesome-thing", + From: []string{"quest"}, }}, }}, ResolvedTaskResources: tb.ResolvedTaskResources( @@ -707,13 +707,13 @@ func TestValidateProvidedBy(t *testing.T) { tb.ResolvedTaskResourcesInputs("awesome-thing", r), ), }} - err := ValidateProvidedBy(state) + err := ValidateFrom(state) if err != nil { - t.Fatalf("Didn't expect error when validating valid providedBy clause but got: %v", err) + t.Fatalf("Didn't expect error when validating valid from clause but got: %v", err) } } -func TestValidateProvidedBy_Invalid(t *testing.T) { +func TestValidateFrom_Invalid(t *testing.T) { r := tb.PipelineResource("holygrail", namespace, tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage)) otherR := tb.PipelineResource("holyhandgrenade", namespace, tb.PipelineResourceSpec(v1alpha1.PipelineResourceTypeImage)) @@ -722,7 +722,7 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { state []*ResolvedPipelineRunTask errContains string }{{ - name: "providedBy tries to reference input", + name: "from tries to reference input", state: []*ResolvedPipelineRunTask{{ PipelineTask: &v1alpha1.PipelineTask{ Name: "quest", @@ -738,8 +738,8 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { Name: "winning", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "awesome-thing", - ProvidedBy: []string{"quest"}, + Name: "awesome-thing", + From: []string{"quest"}, }}, }}, ResolvedTaskResources: tb.ResolvedTaskResources( @@ -751,7 +751,7 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { }}, errContains: "ambiguous", }, { - name: "providedBy resource doesn't exist", + name: "from resource doesn't exist", state: []*ResolvedPipelineRunTask{{ PipelineTask: &v1alpha1.PipelineTask{ Name: "quest", @@ -762,8 +762,8 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { Name: "winning", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "awesome-thing", - ProvidedBy: []string{"quest"}, + Name: "awesome-thing", + From: []string{"quest"}, }}, }}, ResolvedTaskResources: tb.ResolvedTaskResources( @@ -775,14 +775,14 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { }}, errContains: "ambiguous", }, { - name: "providedBy task doesn't exist", + name: "from task doesn't exist", state: []*ResolvedPipelineRunTask{{ PipelineTask: &v1alpha1.PipelineTask{ Name: "winning", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "awesome-thing", - ProvidedBy: []string{"quest"}, + Name: "awesome-thing", + From: []string{"quest"}, }}, }}, ResolvedTaskResources: tb.ResolvedTaskResources( @@ -794,14 +794,14 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { }}, errContains: "does not exist", }, { - name: "providedBy task refers to itself", + name: "from task refers to itself", state: []*ResolvedPipelineRunTask{{ PipelineTask: &v1alpha1.PipelineTask{ Name: "winning", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "awesome-thing", - ProvidedBy: []string{"winning"}, + Name: "awesome-thing", + From: []string{"winning"}, }}, }}, ResolvedTaskResources: tb.ResolvedTaskResources( @@ -813,7 +813,7 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { }}, errContains: "from itself", }, { - name: "providedBy is bound to different resource", + name: "from is bound to different resource", state: []*ResolvedPipelineRunTask{{ PipelineTask: &v1alpha1.PipelineTask{ Name: "quest", @@ -829,8 +829,8 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { Name: "winning", Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "awesome-thing", - ProvidedBy: []string{"quest"}, + Name: "awesome-thing", + From: []string{"quest"}, }}, }}, ResolvedTaskResources: tb.ResolvedTaskResources( @@ -843,9 +843,9 @@ func TestValidateProvidedBy_Invalid(t *testing.T) { errContains: "ambiguous", }} { t.Run(tc.name, func(t *testing.T) { - err := ValidateProvidedBy(tc.state) + err := ValidateFrom(tc.state) if err == nil { - t.Fatalf("Expected error when validating invalid providedBy but got none") + t.Fatalf("Expected error when validating invalid from but got none") } if !strings.Contains(err.Error(), tc.errContains) { t.Errorf("Expected error to contain %q but was: %v", tc.errContains, err) diff --git a/test/builder/pipeline.go b/test/builder/pipeline.go index 08fc8e5f47f..5f4f1671a97 100644 --- a/test/builder/pipeline.go +++ b/test/builder/pipeline.go @@ -131,11 +131,11 @@ func PipelineTaskParam(name, value string) PipelineTaskOp { } } -// ProvidedBy will update the provided PipelineTaskInputResource to indicate that it +// From will update the provided PipelineTaskInputResource to indicate that it // should come from tasks. -func ProvidedBy(tasks ...string) PipelineTaskInputResourceOp { +func From(tasks ...string) PipelineTaskInputResourceOp { return func(r *v1alpha1.PipelineTaskInputResource) { - r.ProvidedBy = tasks + r.From = tasks } } diff --git a/test/builder/pipeline_test.go b/test/builder/pipeline_test.go index 0e66c77fbf5..e3e7cf19eba 100644 --- a/test/builder/pipeline_test.go +++ b/test/builder/pipeline_test.go @@ -32,7 +32,7 @@ func TestPipeline(t *testing.T) { ), tb.PipelineTask("bar", "chocolate", tb.PipelineTaskRefKind(v1alpha1.ClusterTaskKind), - tb.PipelineTaskInputResource("some-repo", "my-only-git-resource", tb.ProvidedBy("foo")), + tb.PipelineTaskInputResource("some-repo", "my-only-git-resource", tb.From("foo")), tb.PipelineTaskOutputResource("some-image", "my-only-image-resource"), ), )) @@ -55,9 +55,9 @@ func TestPipeline(t *testing.T) { TaskRef: v1alpha1.TaskRef{Name: "chocolate", Kind: v1alpha1.ClusterTaskKind}, Resources: &v1alpha1.PipelineTaskResources{ Inputs: []v1alpha1.PipelineTaskInputResource{{ - Name: "some-repo", - Resource: "my-only-git-resource", - ProvidedBy: []string{"foo"}, + Name: "some-repo", + Resource: "my-only-git-resource", + From: []string{"foo"}, }}, Outputs: []v1alpha1.PipelineTaskOutputResource{{ Name: "some-image", diff --git a/test/pipelinerun_test.go b/test/pipelinerun_test.go index 2905b49e161..851ae976850 100644 --- a/test/pipelinerun_test.go +++ b/test/pipelinerun_test.go @@ -244,15 +244,15 @@ func getFanInFanOutPipeline(suffix int, namespace string) *v1alpha1.Pipeline { tb.PipelineTaskOutputResource("workspace", "git-repo"), ), tb.PipelineTask("create-fan-out-1", "check-create-files-exists", - tb.PipelineTaskInputResource("workspace", "git-repo", tb.ProvidedBy("create-file-kritis")), + tb.PipelineTaskInputResource("workspace", "git-repo", tb.From("create-file-kritis")), tb.PipelineTaskOutputResource("workspace", "git-repo"), ), tb.PipelineTask("create-fan-out-2", "check-create-files-exists-2", - tb.PipelineTaskInputResource("workspace", "git-repo", tb.ProvidedBy("create-file-kritis")), + tb.PipelineTaskInputResource("workspace", "git-repo", tb.From("create-file-kritis")), tb.PipelineTaskOutputResource("workspace", "git-repo"), ), tb.PipelineTask("check-fan-in", "read-files", - tb.PipelineTaskInputResource("workspace", "git-repo", tb.ProvidedBy("create-fan-out-2", "create-fan-out-1")), + tb.PipelineTaskInputResource("workspace", "git-repo", tb.From("create-fan-out-2", "create-fan-out-1")), ), )) }