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

🤖 Triggering CI on branch 'release-next' after synching to upstream/master #271

Merged
merged 1 commit into from
Dec 23, 2019

Conversation

alanfx
Copy link

@alanfx alanfx commented Dec 22, 2019

No description provided.

@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Dec 22, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alanfx
To complete the pull request process, please assign markusthoemmes
You can assign the PR to them by writing /assign @markusthoemmes in a comment when ready.

The full list of commands accepted by this bot can be found 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

@alanfx
Copy link
Author

alanfx commented Dec 23, 2019

OCF Webhook is merging this PR

@alanfx alanfx merged commit d461a82 into release-next Dec 23, 2019
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
This commit adds two new types for InterceptorRequest and
InterceptorResponse. Instead of just forwarding the incoming request,
EventListeners will use these types to send requests to interceptors.

This commit introduces an `extensions` field where Interceptors can add
additional data that is available to TriggerBindings. This replaces the
previous mechanism where Interceptors could freely modify the input
bodies. With this change, the input bodies are immutable, and any extra
fields added by Interceptors can only be done within the `extensions`
field.

This commit simply adds the new interface types and plumbing. Future
commits will change the Interceptors to adopt the new Interface.

Part of #271 and tektoncd#778

Signed-off-by: Dibyo Mukherjee <[email protected]>
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
This commit updates the CEL interceptor to use the new interface that supports
immutable input event bodies. This represents a BREAKING CHANGE for users using
`overlays`. Overlays will no longer modify the request body. Instead `keys`
from overlays will be added to a new top-level `extensions` field that is
accessible to TriggerBindings.

Part of #271

Signed-off-by: Dibyo Mukherjee <[email protected]>
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
This commit migrates the GitHub, GitLab, BitBucket interceptors to use the new
InterceptorRequest/Response types. Since these interceptors do not modify the
event body, this change is not a breaking change.

In addition, this commit also refactors the tests for the interceptors by
splitting valid and invalid scenarios into separate test cases.

Part of #271 and tektoncd#778

Signed-off-by: Dibyo Mukherjee <[email protected]>
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
We were using GRPC's `status.Status` as the type for the `Status` field in
InterceptorResponse. This struct contains an embedded proto status message.
This means that we'd have to use a custom Marshal/Unmarshal function for the
Status to correctly contain the Code and Message fields. Instead, this commit
creates our own Status struct that mimics the GRPC status. We will still use
the same Status codes from GRPC but having our own type makes the JSON
encoding/decoding process significantly less complex.

In the future, we'd have to come up with a way to represent the Details field
(which is of proto.Any type) as well.

Part of #271

Signed-off-by: Dibyo Mukherjee <[email protected]>
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
1. Change body from []byte to json.RawMessage
2. Remove omitempty tag for boolean type so that it marshals when false
3. Change context.url to context.event_url to match struct type

Part of #271

Signed-off-by: Dibyo Mukherjee <[email protected]>
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
This commit packages the 4 core interceptors into a single HTTP server.
Each interceptor is available at a different path e.g. /cel for CEL etc.

This does not wire up the implementation of the server into the
EventListener which will be done in a future commit.

Part of #271

Signed-off-by: Dibyo Mukherjee <[email protected]>
pradeepitm12 pushed a commit that referenced this pull request Jan 27, 2021
Storing the body as `json.RawMessage` can lead to loss of information about
spaces in the incoming body when the InterceptorRequest is marshaled as JSON
before sending it over HTTP.

This is because Go's `json.Marshal` will encode `[]byte` as a base64 string and
base64 does not preserve spaces. Adding a custom `MarshalJSON` does not help
here since `MarshalJSON` will return a `[]byte` that will then get compacted as
base64 by `json.Marshal`.

This loss of spaces can be problematic for some use cases. For instance, the
GitHub payload signature validation requires us to compare using the exact body
as it was sent. Otherwise, the validation fails. Note that this will only be a
problem when we marshal the InterceptorRequest i.e. when we move the core
interceptors out to its own server.

Using a string means that the string will be quoted e.g. `{\"foo\": \"bar\"}`.
Go should take care of unquoting it during the unmarshaling process. However,
intercetpor authors using a different language will have to manually unquote
the string by parsing it as a JSON object.

Part of #271, tektoncd#867

Signed-off-by: Dibyo Mukherjee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/sync-fork-to-upstream size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants