-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Official Slack Interceptor): help to extract fields from slash c…
…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 #1542 added generic urlencode handling modified go mod file
- Loading branch information
1 parent
e766a20
commit 65b1d92
Showing
22 changed files
with
348 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Slack slash command EventListener | ||
|
||
Creates an EventListener that listens for Slack events. | ||
|
||
### Try it out locally: | ||
|
||
1. To create the slack trigger and all related resources, run: | ||
|
||
```bash | ||
kubectl apply -f . | ||
``` | ||
|
||
1. Port forward: | ||
|
||
```bash | ||
kubectl port-forward service/el-slack-listener 8080 | ||
``` | ||
|
||
1. Test by sending the sample payload. | ||
|
||
```bash | ||
curl -v \ | ||
-H 'X-Slack-Signature: sha1=ba0cdc263b3492a74b601d240c27efe81c4720cb' \ | ||
-H 'Content-Type: application/x-www-form-urlencoded' \ | ||
-d 'token=EidhofDor5uIpqQ9RrtOVdnC&team_id=T04PK47eDS4&team_domain=demoworkspace-tid8978&channel_id=C04NETw4NBH&channel_name=sample-app&user_id=U04NVDwF7R8&&command=%2Fbuild&text=main+2222&api_app_id=A04NXU23L&is_enterprise_install=false&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT04PK47EDS4%2F4863712501879%2FdOMNffCDfTjlSskBrmB1bOtR&trigger_id=4890883491553.4801143489888.910b8eaae200b381834de25310583f74' \ | ||
http://localhost:8080 | ||
``` | ||
|
||
The response status code should be `202 Accepted` | ||
|
||
|
||
1. You should see a new TaskRun that got created: | ||
|
||
```bash | ||
kubectl get taskruns | grep slack-run- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
curl -v \ | ||
-H 'X-Slack-Signature: sha1=ba0cdc263b3492a74b601d240c27efe81c4720cb' \ | ||
-H 'Content-Type: application/x-www-form-urlencoded' \ | ||
-d 'token=EidhofDor5uIpqQ9RrtOVdnC&team_id=T04PK47eDS4&team_domain=demoworkspace-tid8978&channel_id=C04NETw4NBH&channel_name=sample-app&user_id=U04NVDwF7R8&&command=%2Fbuild&text=main+2222&api_app_id=A04NXU23L&is_enterprise_install=false&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FT04PK47EDS4%2F4863712501879%2FdOMNffCDfTjlSskBrmB1bOtR&trigger_id=4890883491553.4801143489888.910b8eaae200b381834de25310583f74' \ | ||
http://localhost:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../rbac.yaml |
49 changes: 49 additions & 0 deletions
49
examples/v1beta1/slack/slack-eventlistener-interceptor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
apiVersion: triggers.tekton.dev/v1beta1 | ||
kind: EventListener | ||
metadata: | ||
name: slack-listener | ||
annotations: | ||
tekton.dev/payload-validation: "false" | ||
spec: | ||
serviceAccountName: tekton-triggers-example-sa | ||
triggers: | ||
- name: slack-trigger | ||
interceptors: | ||
- ref: | ||
name: "slack" | ||
kind: ClusterInterceptor | ||
params: | ||
- name: requestedFields | ||
value: | ||
- text | ||
- ref: | ||
name: cel | ||
params: | ||
- name: "overlays" | ||
value: | ||
- key: branch | ||
expression: 'extensions.text[0].split(" ")[0]' | ||
- key: image | ||
expression: 'extensions.text[0].split(" ")[1]' | ||
bindings: | ||
- name: branch | ||
value: $(extensions.branch) | ||
- name: image | ||
value: $(extensions.image) | ||
template: | ||
spec: | ||
params: | ||
- name: response | ||
resourcetemplates: | ||
- apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
generateName: slack-run- | ||
spec: | ||
taskSpec: | ||
steps: | ||
- image: ubuntu | ||
script: | | ||
#! /bin/bash | ||
echo "response of slack : $(tt.params.response)" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.