Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs and validation for providedBy #342

Merged

Conversation

bobcatfish
Copy link
Collaborator

While working on creating an end to end test for #168, @dlorenc and I
had a very hard time determining why our pipeline wasn't working as
expected - it turned out that we were using the wrong resource name in
our providedBy clauses.

While adding this validation I really struggled to understand how the
providedBy clause actually works. I've updated the docs with my best
understanding of how it is currently working.

Fortunately in #320 we will be simplifying how this works!

This is follow-up work for #124

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 20, 2018
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 20, 2018
}

sameBindingExists := false
for _, output := range depTask.ResolvedTaskResources.Outputs {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 1...
not 2...
not THREE

BUT FOUR

layers of for loop nesting

😎

it is a beautiful thing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅
In terms on indentantion, we could extract some loop body into functions 👼

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm we could! but im not sure it would be any clearer - im even thinking that making findReferencedTask a separate function was maybe overkill 🤔 i'm happy to do it tho if you have any ideas - the best I could think of is moving the body of the for _, pb := range dep.ProvidedBy loop into a function but I'm not really sure how much that improves things (and we'd have to add another layer of error handling)

While working on creating an end to end test for tektoncd#168, @dlorenc and I
had a very hard time determining why our pipeline wasn't working as
expected - it turned out that we were using the wrong resource name in
our `providedBy` clauses.

While adding this validation I _really_ struggled to understand how the
`providedBy` clause actually works. I've updated the docs with my best
understanding of how it is currently working.

Fortunately in tektoncd#320 we will be simplifying how this works!

This is follow-up work for #124
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-build-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/pipelinerun/pipelinerun.go 79.1% 77.7% -1.5
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go 90.4% 88.6% -1.8

name: skaffold-image-leeroy-app
- name: deploy-app
...
- name: image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be

- name: deploy-app
  ...
  inputs:
  - name: image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, yeah that's better!

}

sameBindingExists := false
for _, output := range depTask.ResolvedTaskResources.Outputs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅
In terms on indentantion, we could extract some loop body into functions 👼

@@ -561,3 +561,283 @@ func TestGetPipelineConditionStatus(t *testing.T) {
})
}
}

func TestValidateProvidedBy(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use the test/builder package here 👼 😉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I can definitely use the resource builders but I'm not sure I can use the builders to construct the state object - I'll explain more in my follow up PR!

@abayer
Copy link
Contributor

abayer commented Dec 20, 2018

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 20, 2018
@knative-prow-robot knative-prow-robot merged commit 6688f0d into tektoncd:master Dec 20, 2018
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Jan 3, 2019
In tektoncd#342 I added docs and
validation for the `providedBy` field, but I missed some feedback from
@vdemeester before the PR was merged, so I'm addressing it now!

The change to use the builders, even just for `PipelineResources`,
removes a surprising amount of boilerplate! It doesn't seem like I can
really use the builders for constructing the `state` object (slice of
`ResolvedPipelineRunTask`) unless we add builder for
`ResolvedPipelineRunTask`. That might be a good idea, however I'm
planning to iterate on some of this for tektoncd#320 and tektoncd#168 (maybe) so I'm
inclined to wait - open to other ideas tho!
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Jan 3, 2019
In tektoncd#342 I added docs and
validation for the `providedBy` field, but I missed some feedback from
@vdemeester before the PR was merged, so I'm addressing it now!

The change to use the builders, even just for `PipelineResources`,
removes a surprising amount of boilerplate! It doesn't seem like I can
really use the builders for constructing the `state` object (slice of
`ResolvedPipelineRunTask`) unless we add builder for
`ResolvedPipelineRunTask`. That might be a good idea, however I'm
planning to iterate on some of this for tektoncd#320 and tektoncd#168 (maybe) so I'm
inclined to wait - open to other ideas tho!
@bobcatfish
Copy link
Collaborator Author

Follow up PR in #365 to address @vdemeester 's feedback!

knative-prow-robot pushed a commit that referenced this pull request Jan 4, 2019
In #342 I added docs and
validation for the `providedBy` field, but I missed some feedback from
@vdemeester before the PR was merged, so I'm addressing it now!

The change to use the builders, even just for `PipelineResources`,
removes a surprising amount of boilerplate! It doesn't seem like I can
really use the builders for constructing the `state` object (slice of
`ResolvedPipelineRunTask`) unless we add builder for
`ResolvedPipelineRunTask`. That might be a good idea, however I'm
planning to iterate on some of this for #320 and #168 (maybe) so I'm
inclined to wait - open to other ideas tho!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants