Skip to content

Validate flow as told in the flow spec comments.#398

Merged
knative-prow-robot merged 4 commits into
knative:masterfrom
n3wscott:update_webhooks
Aug 29, 2018
Merged

Validate flow as told in the flow spec comments.#398
knative-prow-robot merged 4 commits into
knative:masterfrom
n3wscott:update_webhooks

Conversation

@n3wscott
Copy link
Copy Markdown
Contributor

Follow-up to #352

Proposed Changes

  • Follow the comments provided in FlowSpec, checking fields and throwing errors as needed.

Release Note

Flows are validated on create and modify.

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 27, 2018
@n3wscott
Copy link
Copy Markdown
Contributor Author

n3wscott commented Aug 27, 2018

/assign @vaikas-google

We have moved to using the knative/pkg/webhooks to use the .Validate() method on our resources. This cleaned up a lot of code, check out the linked PR too :D

@n3wscott
Copy link
Copy Markdown
Contributor Author

/test pull-knative-eventing-go-coverage

@n3wscott
Copy link
Copy Markdown
Contributor Author

/test pull-knative-eventing-go-coverage

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/apis/flows/v1alpha1/flow_validation.go 0.0% 95.8% 95.8

Copy link
Copy Markdown
Contributor

@adamharwayne adamharwayne left a comment

Choose a reason for hiding this comment

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

/lgtm

Action: FlowAction{
TargetURI: stringPtr("http://example.com/action"),
},
Trigger: EventTrigger{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This gets recreated a few times. Maybe pull it into a variable?

validEventTrigger := ...

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2018
},
want: &apis.FieldError{
Message: `invalid value "http//example.com/action"`,
Paths: []string{"action.targetURI"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am still catching up with the changes for validation code while I was gone. I like what's being done with them, I'm just little confused on what the eventual returned to the user and how the paths get stitched together. But that's not really part of this PR, just need to go read some more code :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea is that the field context is prefixed as you come back up the call stack, so you can traverse a object graph and call validate on sub-objects. If those objects throw errors, you add the context only you know about in the context the object is used. IE:

err = obj.AnotherObj.Validate()
if err != nil {
  return err.ViaField("AnotherObj")
}

AnotherObj's type was able to have a validate function that is only aware of the objects requirements. Only obj knew the context in which the user knows how they used AnotherObj.

Check out knative/pkg/apis

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Aug 29, 2018

/lgtm
/approve

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: n3wscott, vaikas-google

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

The pull request process is described here

Details 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 Aug 29, 2018
@n3wscott
Copy link
Copy Markdown
Contributor Author

/test pull-knative-eventing-build-tests

@knative-prow-robot knative-prow-robot merged commit 8cc3a7b into knative:master Aug 29, 2018
mgencur added a commit to mgencur/eventing that referenced this pull request Oct 26, 2023
* Patch for optional chmod for codegen scripts

* Apply codegen patch

* Also apply patch after running udpate-codegen.sh
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