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

Slack interceptor 1542 #1548

Merged
merged 2 commits into from Apr 28, 2023
Merged

Conversation

ilan-pinto
Copy link
Contributor

@ilan-pinto ilan-pinto commented Mar 6, 2023

Changes

Added a Slack Interceptor that allows you to extract fields from a slack slash command payload which are sent in the http form-data section.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • [V] Includes tests (if functionality changed/added)
  • [V] Includes docs (if user facing)
  • [V] Commit messages follow commit message best practices
  • [V] Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Release Notes


Added a Slack `Interceptor` that allows you to extract fields from a slack slash command [payload](https://api.slack.com/interactivity/slash-commands#app_command_handling) which are sent in the  http form-data section.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Mar 6, 2023
@tekton-robot tekton-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 6, 2023
@tekton-robot
Copy link

Hi @ilan-pinto. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 6, 2023
@ilan-pinto ilan-pinto mentioned this pull request Mar 6, 2023
1 task
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 71.1% -0.9

@ilan-pinto ilan-pinto mentioned this pull request Mar 6, 2023
4 tasks
@ilan-pinto
Copy link
Contributor Author

@khrm how can i fix the failing test ?

It seems to be coming from the framework

Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

I think you are using go1.18 or go1.20. While using scripts in hack folder, you need to use go1.19 version because test scripts uses go1.19 version.

@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 7, 2023
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 79.3% 0.3
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 71.1% -0.9

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 79.3% 0.3
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 71.1% -0.9

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 79.3% 0.3
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 71.1% -0.9

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 82.3% 3.3
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 71.1% -0.9

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 79.3% 0.3
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 69.7% -2.3

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 10, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 12, 2023
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 79.3% 0.3
pkg/interceptors/slack/slack.go Do not exist 84.6%
pkg/sink/sink.go 72.0% 69.7% -2.3


```yaml
annotations:
tekton.dev/payload-validation: "false"
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should update our payload validation to allow json and form/urlencoded content types and return invalid for anything else

Copy link
Member

Choose a reason for hiding this comment

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

cc @khrm

kubectl get eventlisteners
}

ignoreExamples=( cron trigger-ref triggergroups )

port_forward_and_curl() {

sleep 10
Copy link
Member

Choose a reason for hiding this comment

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

why do we need a sleep 10?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I faced issues on my local when using kind. it took more than 3 sec for the event listener to be available

test/e2e-tests-examples.sh Outdated Show resolved Hide resolved
// the Requested fields to be extracted from data form

// +listType=atomic
RequestedFields []string `json:"requestedFields,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

is this a mandatory field? or do we extract all fields by default if no requestedFields is specifed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We extract only the requested fields.
it wont do any work if nothing is specified

pkg/sink/sink.go Outdated
@@ -554,7 +558,24 @@ func (r Sink) ExecuteInterceptors(trInt []*triggersv1.TriggerInterceptor, in *ht
}
// Clear interceptorParams for the next interceptor in chain
request.InterceptorParams = map[string]interface{}{}

// check if string is urlencoded
Copy link
Member

Choose a reason for hiding this comment

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

The logic here looks fine but shouldn't we call it when we first create the request object around line 467?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dibyom, good call. It simplified the Slack interceptor.
All tests are ok on my local but for some reason this test fails in GitHub action

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/slack/slack.go Do not exist 80.0%
pkg/sink/sink.go 72.0% 70.8% -1.2

@ilan-pinto
Copy link
Contributor Author

/test pull-tekton-triggers-integration-tests

@khrm
Copy link
Contributor

khrm commented Mar 21, 2023

The test is failing because resources don't exist in 0.46. We need to update the getting started pipeline. So it's not an issue with this pr.

@savitaashture savitaashture added this to the Triggers v0.24 milestone Mar 22, 2023
@savitaashture
Copy link
Contributor

/test pull-tekton-triggers-integration-tests

@dibyom
Copy link
Member

dibyom commented Apr 19, 2023

/approve

Thanks so much @ilan-pinto

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, khrm

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

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 20, 2023
@tekton-robot tekton-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 25, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 26, 2023
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/server/server.go 78.9% 81.0% 2.0
pkg/interceptors/slack/slack.go Do not exist 80.0%
pkg/sink/sink.go 72.0% 70.8% -1.2

@ilan-pinto
Copy link
Contributor Author

/retest

…ommand payload

A Slack  allows you to extract fields from a slack slash
command [payload](https://api.slack.com/interactivity/slash-commands#app
_command_handling) which are sent in the  http form-data section.

Closes tektoncd#1542

added generic urlencode handling

modified go mod file
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/slack/slack.go Do not exist 80.0%
pkg/sink/sink.go 72.0% 70.8% -1.2

Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 28, 2023
@tekton-robot tekton-robot merged commit f031e3c into tektoncd:main Apr 28, 2023
6 checks passed
Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label May 11, 2023
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

None yet

5 participants