Skip to content

Commit

Permalink
Rename passedConstraints to providedBy
Browse files Browse the repository at this point in the history
 - Issue tektoncd#137
 - since the "passedConstraint" flag is for indicating that the task should
 use that input resource coming from the task(s) in the list,
 "providedBy" conveys the meaning better
  • Loading branch information
nader-ziada committed Nov 19, 2018
1 parent 4270f16 commit 7002517
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion docs/cuj/exercises/exercise2/hipster-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
- name: workspace
resourceRef:
name: hipster-source
passedConstraints:
providedBy:
- build-checkoutservice
- build-productcatalog
- build-frontend
Expand Down
16 changes: 8 additions & 8 deletions docs/using.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
to run against, where to store results, etc.
3. Create a `Pipeline` which expresses the Tasks you would like to run and what
[Resources](#creating-resources) the Tasks need.
Use [`passedConstraints`](#passedconstraints) to express the order the `Tasks` should run in.
Use [`providedBy`](#providedBy) to express the order the `Tasks` should run in.

See [the example guestbook Pipeline](../examples/pipelines/guestbook.yaml) and
[the example kritis Pipeline](../examples/pipelines/kritis.yaml).

### PassedConstraints
### ProvidedBy

When you need to execute `Tasks` in a particular order, it will likely be because they
are operating over the same `Resources` (e.g. your unit test task must run first against
your git repo, then you build an image from that repo, then you run integration tests
against that image).

We express this ordering by adding `passedConstraints` on `Resources` that our `Tasks`
We express this ordering by adding `providedBy` on `Resources` that our `Tasks`
need.

* The (optional) `passedConstraints` key on an `input source` defines a set of previous
* The (optional) `providedBy` key on an `input source` defines a set of previous
task names.
* When the `passedConstraints` key is specified on an input source, only the version of
the resource that passed through the defined list of tasks is used.
* The `passedConstraints` allows for `Tasks` to fan in and fan out, and ordering can be
* When the `providedBy` key is specified on an input source, only the version of
the resource that is provided by the defined list of tasks is used.
* The `providedBy` allows for `Tasks` to fan in and fan out, and ordering can be
expressed explicitly using this key since a task needing a resource from a another
task would have to run after.
* The name used in the `passedConstraints` is the name of `PipelineTask`
* The name used in the `providedBy` is the name of `PipelineTask`

## Creating a Task

Expand Down
12 changes: 6 additions & 6 deletions examples/pipelines/guestbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ spec:
- name: imageToDeploy1
resourceRef:
name: redisstagingimage
passedConstraints:
providedBy:
- build-redis
- name: imageToDeploy2
resourceRef:
name: guestbookstagingimage
passedConstraints:
providedBy:
- build-guestbook
- name: workspace
resourceRef:
Expand All @@ -63,7 +63,7 @@ spec:
- name: workspace
resourceRef:
name: guestbook-resources-git
passedConstraints:
providedBy:
- deploy-bundle-test
params:
- name: dockerBuildFile
Expand All @@ -75,7 +75,7 @@ spec:
- name: workspace
resourceRef:
name: guestbook-resources-git
passedConstraints:
providedBy:
- deploy-bundle-test
params:
- name: dockerBuildFile
Expand All @@ -87,13 +87,13 @@ spec:
- name: redisImage
resourceRef:
name: redisstagingimage
passedConstraints:
providedBy:
- int-test-osx
- int-test-linux
- name: guestbookImage
resourceRef:
name: guestbookstagingimage
passedConstraints:
providedBy:
- int-test-osx
- int-test-linux
- name: workspace
Expand Down
6 changes: 3 additions & 3 deletions examples/pipelines/kritis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
- name: workspace
resourceRef:
name: kritis-resources-git
passedConstraints: [unit-test-kritis]
providedBy: [unit-test-kritis]
outputSourceBindings:
- name: builtImage
resourceRef:
Expand All @@ -40,7 +40,7 @@ spec:
- name: builtImage
resourceRef:
name: kritis-resources-image
passedConstraints: [push-kritis]
providedBy: [push-kritis]
- name: testCluster
resourceRef:
name: kritistestcluster
Expand All @@ -54,7 +54,7 @@ spec:
- name: workspace
resourceRef:
name: kritis-resources-git
passedConstraints: [deploy-test-env]
providedBy: [deploy-test-env]
params:
- name: testArgs
value: "-e REMOTE_INTEGRATION=true"
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ type SourceBinding struct {
Name string `json:"name"`
// The Resource this binding is referring to
ResourceRef PipelineResourceRef `json:"resourceRef"`
// PassedConstraints is the list of Task names that the resource has to pass through.
// ProvidedBy is the list of Task names that the resource has to come from.
// +optional
PassedConstraints []string `json:"passedConstraints,omitempty"`
ProvidedBy []string `json:"providedBy,omitempty"`
}

// TaskRef can be used to refer to a specific instance of a task.
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func (ps *PipelineSpec) Validate() *apis.FieldError {
taskNames[t.Name] = struct{}{}
}

// passedConstraints should match other tasks.
// providedBy should match other tasks.
for _, t := range ps.Tasks {
for _, isb := range t.InputSourceBindings {
for _, pc := range isb.PassedConstraints {
for _, pc := range isb.ProvidedBy {
if _, ok := taskNames[pc]; !ok {
return apis.ErrInvalidKeyName(pc, fmt.Sprintf("spec.tasks.inputSourceBindings.%s", pc))
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestPipelineSpec_Validate_Error(t *testing.T) {
Name: "foo",
InputSourceBindings: []SourceBinding{
{
PassedConstraints: []string{"bar"},
ProvidedBy: []string{"bar"},
},
},
},
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestPipelineSpec_Validate_Valid(t *testing.T) {
Name: "foo",
InputSourceBindings: []SourceBinding{
{
PassedConstraints: []string{"bar"},
ProvidedBy: []string{"bar"},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/reconciler/v1alpha1/pipeline/resources/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ func Build(p *v1alpha1.Pipeline) (*DAG, error) {
return nil, errors.NewDuplicatePipelineTask(p, pt.Name)
}
}
// Process all passedConstraints to add task dependency
// Process all providedBy constraints to add task dependency
for _, pt := range p.Spec.Tasks {
for _, input := range pt.InputSourceBindings {
for _, constraint := range input.PassedConstraints {
for _, constraint := range input.ProvidedBy {
// We need to add dependency from constraint to node n
prev, ok := d.Nodes[constraint]
if !ok {
Expand Down
16 changes: 8 additions & 8 deletions pkg/reconciler/v1alpha1/pipeline/resources/dag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ func TestBuild(t *testing.T) {
c := v1alpha1.PipelineTask{Name: "c"}
xDependsOnA := v1alpha1.PipelineTask{
Name: "x",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"a"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"a"}}},
}
yDependsOnAB := v1alpha1.PipelineTask{
Name: "y",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"b", "a"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"b", "a"}}},
}
zDependsOnX := v1alpha1.PipelineTask{
Name: "z",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"x"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"x"}}},
}
aDependsOnZ := v1alpha1.PipelineTask{
Name: "a",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"z"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"z"}}},
}
selfLink := v1alpha1.PipelineTask{
Name: "a",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"a"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"a"}}},
}
invalidTask := v1alpha1.PipelineTask{
Name: "a",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"none"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"none"}}},
}
nodeX := &Node{Task: xDependsOnA, Prev: []*Node{&Node{Task: a}}}

Expand Down Expand Up @@ -136,11 +136,11 @@ func TestGetPrevTasks(t *testing.T) {
a := v1alpha1.PipelineTask{Name: "a"}
x := v1alpha1.PipelineTask{
Name: "x",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"a"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"a"}}},
}
y := v1alpha1.PipelineTask{
Name: "y",
InputSourceBindings: []v1alpha1.SourceBinding{{PassedConstraints: []string{"x", "a"}}},
InputSourceBindings: []v1alpha1.SourceBinding{{ProvidedBy: []string{"x", "a"}}},
}
p := v1alpha1.Pipeline{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func GetNextTask(prName string, state []*PipelineRunTaskRun, logger *zap.Sugared
func canTaskRun(pt *v1alpha1.PipelineTask, state []*PipelineRunTaskRun) bool {
// Check if Task can run now. Go through all the input constraints
for _, input := range pt.InputSourceBindings {
if len(input.PassedConstraints) > 0 {
for _, constrainingTaskName := range input.PassedConstraints {
if len(input.ProvidedBy) > 0 {
for _, constrainingTaskName := range input.ProvidedBy {
for _, prtr := range state {
// the constraining task must have a successful task run to allow this task to run
if prtr.PipelineTask.Name == constrainingTaskName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var mypipelinetasks = []v1alpha1.PipelineTask{{
ResourceRef: v1alpha1.PipelineResourceRef{
Name: "myresource1",
},
PassedConstraints: []string{"mypipelinetask1"},
ProvidedBy: []string{"mypipelinetask1"},
}},
}}

Expand Down
2 changes: 1 addition & 1 deletion test/helm_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func getHelmDeployPipeline(namespace string) *v1alpha1.Pipeline {
ResourceRef: v1alpha1.PipelineResourceRef{
Name: sourceResourceName,
},
PassedConstraints: []string{createImageTaskName},
ProvidedBy: []string{createImageTaskName},
}},
Params: []v1alpha1.Param{{
Name: "pathToHelmCharts",
Expand Down

0 comments on commit 7002517

Please sign in to comment.