No description
  • Go 95.7%
  • Dockerfile 2.3%
  • Shell 2%
Find a file
2019-12-14 19:40:55 +01:00
config updated psp 2019-12-14 19:40:55 +01:00
.gitignore added webhook validation 2019-12-14 14:48:41 +01:00
.ko.yaml read secret from k8s 2019-12-04 17:42:30 +01:00
build.sh added webhook validation 2019-12-14 14:48:41 +01:00
Dockerfile first commit 2019-11-30 12:09:41 +01:00
git.go added webhook validation 2019-12-14 14:48:41 +01:00
go.mod read secret from k8s 2019-12-04 17:42:30 +01:00
go.sum read secret from k8s 2019-12-04 17:42:30 +01:00
helper.go move git stuff out of main 2019-12-10 00:04:27 +01:00
LICENSE updated license 2019-12-04 17:49:14 +01:00
main.go added webhook validation 2019-12-14 14:48:41 +01:00
README.md added webhook validation 2019-12-14 14:48:41 +01:00
types.go added webhook validation 2019-12-14 14:48:41 +01:00

webhook-interceptor

The Webhook Interceptor checks for specific conditions when a webhook is received.

This way we can trigger cleanups when the PR is closed.

HTTP Headers

Push Event

X-Interceptor-Push-Ref: string: "refs/heads/master"
X-Interceptor-Include-Repo: []string{"my/repo"}
X-Interceptor-Exclude-Repo: []string{"my/repo"}

Response Headers:

Commit: <Head Commit Hash>

Pull-Request Event

X-Interceptor-Pr-Action: []string{"opened", "reopened", "synchronize", "synchronized"}

Response Headers:

Issue: <Pull-Request ID>
Commit: <Pull-Request Head Commit Hash>

Issue Comment Event

X-Interceptor-Comment: "/test-deploy"
X-Interceptor-Comment-Action: []string{"created"}
X-Interceptor-Label: "test-deploy:#aabbcc"
X-Interceptor-Remove-Labels: []string{"test", "deploy"}

Actions

  • /test - add test label and run test pipeline
  • /deploy - add deploy label and run deploy pipeline
  • /test-deploy - add test-deploy label and run test-deploy pipeline

Response Headers:

Issue: <Pull-Request ID>
Commit: <Pull-Request Head Commit Hash>

Validate Webhooks

Add secret webhook keys you want to have validated.

NOTE: the name must be webhook-secret.

cat <<EOF>webhook-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: webhook-secret
  namespace: webhook-interceptor
type: Opaque
stringData:
  github.com: "<secreet>"
  github.com_foo: "<foo secret>"
  github.com_foo_bar: "<bar secret>"
EOF

Build and run

Create git authentication secret:

NOTE: the name must be git-auth.

cat <<EOF>secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: git-auth
  namespace: webhook-interceptor
type: Opaque
stringData:
  github.com: "<username>:<password>"
  github.com_foo: "<foo username>:<foo password>"
  github.com_foo_bar: "<bar username>:<bar password>"
EOF
echo KO_DOCKER_REPO='gcr.io/my-gcloud-project-name' >env.txt

./build.sh