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 actual validation to the task validation webhook skeleton. #117

Merged
merged 2 commits into from
Oct 10, 2018

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Oct 9, 2018

This PR adds the following validation:

  • Task inputs and outputs must have a valid Type
  • Task inputs and outputs must not have a duplicated name.

Ref #29

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlorenc

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 Oct 9, 2018
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 9, 2018
@dlorenc dlorenc force-pushed the moretaskvalidation branch 3 times, most recently from 0a66647 to c3ccab0 Compare October 9, 2018 16:09
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 9, 2018

Got this working and tested in my cluster:

Changing the type in build_task.yaml to "what" from "git" gives:

Error from server (InternalError): error when creating "examples/build_task.yaml": Internal error occurred: admission webhook "webhook.pipeline.knative.dev" denied the request: mutation failed: invalid value "what": taskspec.Outputs.Sources.builtImage.Type

I'm not in love with the duplicate error, but I copied the validation from build: https://github.com/knative/build/blob/c5d66f1ca208fa2ea3408eb46f0328e4cd390bd1/pkg/apis/build/v1alpha1/build_template_validation.go#L50

That looks like:

Error from server (InternalError): error when creating "examples/build_task.yaml": Internal error occurred: admission webhook "webhook.pipeline.knative.dev" denied the request: mutation failed: expected exactly one, got both: taskspec.Outputs.Sources.Name

},
},
},
wantErr: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you think about having a separate set of tests for the failure/success conditions vs. having a boolean flag to indicate failure/success?

i find it easier to read tests that are written that way and then the logic in the test itself doesn't have to account for 2 fairly different cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

Lookin good! Do you have any more validation planned? Looking at the Types, Clusters is a possibility, tho we'll probably be changing that significantly in #68 anyway

fields: fields{
Outputs: &Outputs{
Sources: []Source{validSource},
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm surprised we can create Tasks without buildSpecs - I guess we're assuming that will be caught by the serialization/deserialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah not sure, I'll play around with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@dlorenc dlorenc force-pushed the moretaskvalidation branch from c3ccab0 to e61315a Compare October 9, 2018 18:34
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 9, 2018

Lookin good! Do you have any more validation planned? Looking at the Types, Clusters is a possibility, tho we'll probably be changing that significantly in #68 anyway

Yeah, there's a lot more we can validate here. We'll keep going on this.

@bobcatfish
Copy link
Collaborator

lookin good!

/lgtm
/meow space

@knative-prow-robot
Copy link

@bobcatfish: cat image

In response to this:

lookin good!

/lgtm
/meow space

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 10, 2018
@bobcatfish
Copy link
Collaborator

ruh roh

@bobcatfish
Copy link
Collaborator

/me backs away slowly

This PR adds the following validation:
- Task inputs and outputs must have a valid Type
- Task inputs and outputs must not have a duplicated name.
@dlorenc dlorenc force-pushed the moretaskvalidation branch from e7785b6 to bda8a34 Compare October 10, 2018 16:55
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 10, 2018
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 10, 2018

Ahh, looks like everything got renamed. Rebased and renamed stuff.

@bobcatfish
Copy link
Collaborator

/lgtm

sorry @dlorenc that was probably my bad from #114 😓

whispers it's a race 🏎️

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 10, 2018
@knative-prow-robot knative-prow-robot merged commit 4c7cf1f into tektoncd:master Oct 10, 2018
@dlorenc dlorenc deleted the moretaskvalidation branch October 10, 2018 17:15
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.

3 participants