-
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
Enhance v1beta1 validation code for pipeline 🍸 #3277
Enhance v1beta1 validation code for pipeline 🍸 #3277
Conversation
The following is the coverage report on the affected files.
|
387fd4b
to
734861f
Compare
The following is the coverage report on the affected files.
|
|
||
return nil | ||
errs = errs.Also(validatePipelineResults(ps.Results)) | ||
errs = errs.Also(validateTasksAndFinallySection(ps)) |
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.
This is a bit duplicated (in some weird way) with the task validation above. The whole task
and finally
validation code could be enhanced in follow-ups
// Task names are appended to the container name, which must exist and | ||
// must be a valid k8s name | ||
if errSlice := validation.IsQualifiedName(t.Name); len(errSlice) != 0 { | ||
return apis.ErrInvalidValue(strings.Join(errSlice, ","), fmt.Sprintf(prefix+"[%d].name", i)) | ||
} |
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.
This is less strict than validatePipelineTaskName
so we don't really need to do it, at all
734861f
to
2979f0c
Compare
The following is the coverage report on the affected files.
|
This make a better use of knative.dev/pkg apis errors package in order to make the code simpler, *and* the report better. - This allows reporting multiple validation error at once — so, one failure message (webhook error) would be more useful to the user. - This reduce `if err != nil` path, simplifying the code. This commit tackles `Pipeline` 🙃 Signed-off-by: Vincent Demeester <[email protected]>
2979f0c
to
494bbbd
Compare
The following is the coverage report on the affected files.
|
func TestPipelineSpec_Validate_Failure_CycleDAG(t *testing.T) { | ||
name := "invalid pipeline spec with DAG having cyclic dependency" | ||
ps := &PipelineSpec{ | ||
Tasks: []PipelineTask{{ | ||
Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}, RunAfter: []string{"bar"}, | ||
}, { | ||
Name: "bar", TaskRef: &TaskRef{Name: "bar-task"}, RunAfter: []string{"foo"}, | ||
}}, | ||
} | ||
err := ps.Validate(context.Background()) | ||
if err == nil { | ||
t.Errorf("PipelineSpec.Validate() did not return error for invalid pipelineSpec: %s", name) | ||
} | ||
} | ||
|
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.
Extracted this to not have a flaky unit test. We do validate it errors out but not checking the error as the order is not deterministic (can be foo -> bar -> foo
or bar -> foo -> bar
, both make senses).
/hold cancel |
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.
The only comment I have is a minor style thing: the line lengths are quite long in several areas. This is not a blocker but breaking them up a bit would aid readability a bit I think.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg 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 |
Yeah indeed. I'll try to make an issue on tech dept in there (and other |
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.
/lgtm
Changes
This make a better use of knative.dev/pkg apis errors package in order
to make the code simpler, and the report better.
failure message (webhook error) would be more useful to the user.
if err != nil
path, simplifying the code.This commit tackles
Pipeline
🙃Signed-off-by: Vincent Demeester [email protected]
/cc @pritidesai @jerop @bobcatfish @sbwsg @savitaashture @imjasonh
/kind cleanup
/hold
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