Skip to content

Commit bd34903

Browse files
committed
webhooks helm
1 parent 596fadf commit bd34903

File tree

7 files changed

+44
-7
lines changed

7 files changed

+44
-7
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
![Container Build](https://github.com/rht-labs/open-management-portal-git-api/workflows/Container%20Build/badge.svg)
22

3-
# Open Management Portal - Git API
3+
# LodeStar - Git API
44

5-
The Git API for the Open Management Portal.
5+
The Git API for LodeStar.
66

7-
This API uses GitLab as a repository to store OMP resources.
7+
This API uses GitLab as a repository to store LodeStar resources.
88

99
## JSON REST APIs
1010

@@ -67,12 +67,15 @@ Deployment template will read from the above secret and inject following env var
6767
|------|---------------|----------|
6868
| CONFIG_REPOSITORY_ID | 1 | True |
6969
| CONFIG_FILE | my-config.yml | True |
70+
| CONFIG_GITLAB_REF | master | False |
71+
| WEBHOOK_FILE | webhooks.yml | False |
7072

7173
### Engagements Resource
7274

7375
| Name | Example Value | Required |
7476
|------|---------------|----------|
7577
| ENGAGEMENTS_REPOSITORY_ID | 2 | True |
78+
| WEBHOOK_DEFAULT_TOKEN | tolkien | False |
7679

7780
### Version Resource
7881

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
data:
3+
webhooks.yaml: |
4+
{{- range $hook := .Values.config.hooks }}
5+
- name: {{ $hook.name }}
6+
baseUrl: {{ $hook.baseUrl }}
7+
token: {{ $hook.token }}
8+
pushEvent: {{ $hook.pushEvent | default true }}
9+
pushEventsBranchFilter: {{ $hook.pushEventsBranchFilter | default "master" }}
10+
{{- end }}
11+
kind: ConfigMap
12+
metadata:
13+
name: hook-cm

deployment/templates/deploymentconfig.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ spec:
4242
resources: {}
4343
terminationMessagePath: /dev/termination-log
4444
terminationMessagePolicy: File
45+
volumeMounts:
46+
- name: hook-cm-volume
47+
mountPath: {{ .Values.config.hookFile.path }}
4548
dnsPolicy: ClusterFirst
4649
restartPolicy: Always
4750
schedulerName: default-scheduler
4851
securityContext: {}
4952
terminationGracePeriodSeconds: 30
53+
volumes:
54+
- name: hook-cm-volume
55+
configMap:
56+
name: hook-cm
5057
test: false
5158
triggers:
5259
- type: ConfigChange

deployment/templates/gitlab-secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ stringData:
1111
GITLAB_API_URL: "{{ .Values.gitLabApiUrl }}"
1212
GITLAB_PERSONAL_ACCESS_TOKEN: "{{ .Values.gitLabPersonalAccessToken }}"
1313
ENGAGEMENTS_REPOSITORY_ID: "{{ .Values.engagementsRepositoryId }}"
14+
WEBHOOK_FILE: "{{ .Values.config.hookFile.path }}/{{ .Values.config.hookFile.name }}"
1415
{{- end }}

deployment/values-dev.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,17 @@ configRepositoryId: false
1818
deployKey: false
1919
gitLabApiUrl: false
2020
gitLabPersonalAccessToken: false
21-
engagementsRepositoryId: false
21+
engagementsRepositoryId: false
22+
23+
config:
24+
hookFile:
25+
path: /schema
26+
name: webhooks.yaml
27+
hooks:
28+
- name: hook1
29+
baseUrl: http://localhost/hook1
30+
token: ibaka
31+
- name: hook2
32+
baseUrl: http://localhost/hook2
33+
token: anunoby
34+

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ gitlab.deploy.key=${DEPLOY_KEY:0}
2727
# config
2828
config.repository.id=${CONFIG_REPOSITORY_ID:1}
2929
config.file=${CONFIG_FILE:schema/config.yml}
30-
webhook.file=${LODESTAR_WEBHOOK_FILE:/schema/webhooks.yaml}
30+
webhook.file=${WEBHOOK_FILE:/schema/webhooks.yaml}
3131
webhook.default.token=${WEBHOOK_DEFAULT_TOKEN:tolkien}
3232
config.gitlab.ref=${CONFIG_GITLAB_REF:master}
3333

src/test/java/com/redhat/labs/omp/resource/EngagementResourceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void testGetWebhooksSuccess() {
6262
given()
6363
.when()
6464
.contentType(ContentType.JSON)
65-
.get("/api/v1/engagements/jello/lemon/hooks")
65+
.get("/api/v1/engagements/customer/jello/lemon/hooks")
6666
.then()
6767
.statusCode(200)
6868
.body(is("[{\"id\":13,\"project_id\":99,\"push_events\":true,\"push_events_branch_filter\""
@@ -75,7 +75,7 @@ public void testCreateProjectHookSuccess() {
7575
.when()
7676
.contentType(ContentType.JSON)
7777
.body("{\"push_events\": true, \"url\": \"https://lodestar/webhooks/blah\"}")
78-
.post("/api/v1/engagements/jello/tutti-frutti/hooks")
78+
.post("/api/v1/engagements/customer/jello/tutti-frutti/hooks")
7979
.then()
8080
.statusCode(201);
8181
}

0 commit comments

Comments
 (0)