Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tf-build
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benedikt Wildenhain
tf-build
Commits
d43caa07
Commit
d43caa07
authored
Jan 13, 2020
by
Jason Zaman
Browse files
Options
Downloads
Patches
Plain Diff
Add webhook validator to tekton event listener
parent
7e2b07aa
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tekton/build-triggers.yaml
+30
-0
30 additions, 0 deletions
tekton/build-triggers.yaml
tekton/submit.py
+16
-2
16 additions, 2 deletions
tekton/submit.py
tekton/webhook-deployment.yaml
+91
-0
91 additions, 0 deletions
tekton/webhook-deployment.yaml
with
137 additions
and
2 deletions
tekton/build-triggers.yaml
+
30
−
0
View file @
d43caa07
...
@@ -114,3 +114,33 @@ spec:
...
@@ -114,3 +114,33 @@ spec:
name
:
build-pipelinebinding
name
:
build-pipelinebinding
template
:
template
:
name
:
build-triggertemplate
name
:
build-triggertemplate
interceptor
:
objectRef
:
kind
:
Service
name
:
webhook-validator
apiVersion
:
v1
namespace
:
sig-build
---
apiVersion
:
extensions/v1beta1
kind
:
Ingress
metadata
:
name
:
build-listener
namespace
:
sig-build
labels
:
app
:
build-listener
annotations
:
kubernetes.io/ingress.global-static-ip-name
:
tf-build-event
spec
:
rules
:
-
http
:
paths
:
-
path
:
/webhook/*
backend
:
serviceName
:
el-build-listener
servicePort
:
8080
---
This diff is collapsed.
Click to expand it.
tekton/submit.py
100644 → 100755
+
16
−
2
View file @
d43caa07
...
@@ -6,11 +6,17 @@ import hmac
...
@@ -6,11 +6,17 @@ import hmac
import
os
import
os
import
sys
import
sys
from
pprint
import
pprint
# forward to listener with:
# forward to listener with:
# kubectl port-forward svc/el-build-listener 7070:8080 --namespace=sig-build
# kubectl port-forward svc/el-build-listener 7070:8080 --namespace=sig-build
HOOKURL
=
'
http://localhost:7070/
'
HOOKURL
=
'
http://localhost:7070/
'
HEADERS
=
{
'
X-GitHub-Event
'
:
'
push
'
,
}
DATA
=
{
DATA
=
{
"
head_commit
"
:
"
head_commit
"
:
{
{
...
@@ -32,12 +38,20 @@ if len(secret) < 1:
...
@@ -32,12 +38,20 @@ if len(secret) < 1:
print
(
'
Set env var GITHUB_SECRET
'
)
print
(
'
Set env var GITHUB_SECRET
'
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
request
=
requests
.
Request
(
'
POST
'
,
HOOKURL
,
data
=
DATA
)
secret
=
secret
.
encode
(
'
utf-8
'
)
request
=
requests
.
Request
(
'
POST
'
,
HOOKURL
,
headers
=
HEADERS
,
json
=
DATA
)
prepped
=
request
.
prepare
()
prepped
=
request
.
prepare
()
sig
=
hmac
.
new
(
secret
,
prepped
.
body
,
hashlib
.
sha1
)
sig
=
hmac
.
new
(
secret
,
prepped
.
body
,
hashlib
.
sha1
)
prepped
.
headers
[
'
X-Hub-Signature
'
]
=
"
sha1=%s
"
%
sig
.
hexdigest
()
prepped
.
headers
[
'
X-Hub-Signature
'
]
=
"
sha1=%s
"
%
sig
.
hexdigest
()
with
requests
.
Session
()
as
session
:
with
requests
.
Session
()
as
session
:
response
=
session
.
send
(
prepped
)
r
=
session
.
send
(
prepped
)
print
(
"
Response status code:
"
,
r
.
status_code
)
print
(
"
Response headers:
"
)
pprint
(
r
.
headers
)
print
(
"
\n
Response text:
"
)
print
(
r
.
text
)
This diff is collapsed.
Click to expand it.
tekton/webhook-deployment.yaml
0 → 100644
+
91
−
0
View file @
d43caa07
---
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
webhook-validator
namespace
:
sig-build
labels
:
app
:
webhook-validator
spec
:
replicas
:
1
selector
:
matchLabels
:
app
:
webhook-validator
template
:
metadata
:
name
:
webhook-validator
namespace
:
sig-build
labels
:
app
:
webhook-validator
spec
:
containers
:
-
name
:
webhook-validator
image
:
gcr.io/perfinion/tensorflow-build/webhook:latest
imagePullPolicy
:
IfNotPresent
ports
:
-
containerPort
:
5001
protocol
:
TCP
readinessProbe
:
failureThreshold
:
3
httpGet
:
path
:
/
port
:
5001
scheme
:
HTTP
periodSeconds
:
10
successThreshold
:
1
timeoutSeconds
:
1
livenessProbe
:
failureThreshold
:
3
httpGet
:
path
:
/
port
:
5001
scheme
:
HTTP
periodSeconds
:
10
successThreshold
:
1
timeoutSeconds
:
1
resources
:
requests
:
memory
:
64Mi
limits
:
memory
:
128Mi
env
:
-
name
:
GITHUB_SECRET
valueFrom
:
secretKeyRef
:
name
:
github-webhook-secret
key
:
webhook-secret
-
name
:
PORT
value
:
"
5001"
-
name
:
DEBUG_MODE
value
:
"
0"
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
webhook-validator
namespace
:
sig-build
labels
:
app
:
webhook-validator
spec
:
type
:
ClusterIP
ports
:
-
port
:
80
protocol
:
TCP
targetPort
:
5001
selector
:
app
:
webhook-validator
---
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment