-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update PipelineSpec Task validation to prevents errors at runtime #1358
Conversation
The following is the coverage report on pkg/.
|
8b3a7f1
to
b4b93cf
Compare
Not sure where within https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md to update or if it is necessary? |
b4b93cf
to
12445d6
Compare
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where within https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md to update or if it is necessary?
Sounds worth mentioning to me, maybe at:
https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md#pipeline-tasks ?
Adding hold for the docs but otherwise looks good!
/hold
/lgtm
/approve
(I'm also gonna edit your release notes to include this change!)
@@ -23,6 +23,7 @@ import ( | |||
"github.com/tektoncd/pipeline/pkg/list" | |||
"golang.org/x/xerrors" | |||
"k8s.io/apimachinery/pkg/api/equality" | |||
"k8s.io/apimachinery/pkg/util/validation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo what a handy library!
Maybe docs can link to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names |
12445d6
to
9eb296c
Compare
The following is the coverage report on pkg/.
|
Just realized that the TaskRef names weren't being checked either so I just added this as well. |
Thanks @vtereso !! /lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thank you!
I have a minor comment on the errors, let me know what you think about it.
} | ||
// TaskRef name must be a valid k8s name | ||
if errSlice := validation.IsQualifiedName(t.TaskRef.Name); len(errSlice) != 0 { | ||
return apis.ErrInvalidValue(errSlice[0], "spec.tasks.taskRef") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
I kinda agree with @afrittoli but I think we can do that in a follow-up. Sounds good @afrittoli @vtereso ?
9eb296c
to
eb57389
Compare
It was an easy change so I returned all the errors |
The following is the coverage report on pkg/.
|
eb57389
to
27c91b6
Compare
The following is the coverage report on pkg/.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/test pull-tekton-pipeline-integration-tests |
/hold cancel |
27c91b6
to
efc93cd
Compare
The following is the coverage report on pkg/.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/lgtm cancel |
… errors at runtime
efc93cd
to
167dd54
Compare
The following is the coverage report on pkg/.
|
The cla is 🆗 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bobcatfish, vdemeester 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 |
Changes
Currently, if step names are omitted, a duplicate empty value collides in the Pipeline validation. Also, if a Task name uses forbidden characters, pods will fail to be created since it is appended to the name. If the name is omitted (in a single step, which would pass validation) we would get
<PipelineRunName>--<Rand>-<ConditionalRefName>-<Rand>
for a condition pod and<PipelineRunName>--<Rand>
otherwise, where the double hyphen imply the name should be specified. Further, in the catalog and elsewhere it seems to be a well documented practice to include the name.This PR adds validation to PipelineSpec Task name and TaskRef name validation to ensure that the name are valid Kubernetes names (revokes empty values).
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes