Skip to content

Commit b1f5d28

Browse files
committed
Refactor the documentation
1 parent 1f8dc2e commit b1f5d28

File tree

3 files changed

+210
-152
lines changed

3 files changed

+210
-152
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
### Introduction
3+
This readme explain the step to step to run this sample in Docker.
4+
5+
We will use the ODM for developper image. No needs to have an ODM installed.
6+
We needs to have build the image as explain in the [README.md](README.md) file.
7+
8+
### Run the sample
9+
10+
1. Run ODM and Notifiers docker images
11+
```bash
12+
docker-compose -f docker-compose.yaml -f compose-odm-dev.yml up
13+
```
14+
15+
2. Register the webhook in Decision Center using the REST API tool, providing the token and URL (`http://localhost:3000/slack` and `http://localhost:3000/print`).
16+
17+
1. For File Notifier:
18+
```shell
19+
curl -X 'PUT' \
20+
'http://localhost:9060/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Flogifle%3A3000%2Fprint' \
21+
-H 'accept: */*' \
22+
-H 'Content-Type: application/json' \
23+
-d 'null' \
24+
-u odmAdmin:odmAdmin
25+
```
26+
27+
2. For the Slack Notifier:
28+
29+
* Generate the Token :
30+
```shell
31+
kubectl exec -ti webhooknotifier-slack -- curl -X 'GET' \
32+
'http://localhost:3000/token.generate' \
33+
-H 'accept: */*' \
34+
-H 'Content-Type: application/json'
35+
```
36+
xxxxxx.xxxxxx.xxxxxxxx -> Token
37+
38+
This command return a token that should be injected in the next command line.
39+
40+
* Register the webhook with the generated token
41+
```shell
42+
curl -X 'PUT' \
43+
'http://localhost:9060/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Fslack%3A3000%2Fslack' \
44+
-H 'accept: */*' \
45+
-H 'Content-Type: application/json' \
46+
-d '<GENERATED_TOKEN>' \
47+
-u odmAdmin:odmAdmin
48+
```
49+
### Using the Sample
50+
51+
Once the webhook is set up, events from the Decision Center will trigger the notifications and either post messages to Slack or generate log files in the `results` directory.
52+
53+
You can trigger an event by deploying a rule app for example.
54+
55+
You can see the notification in the docker-compose windows.
56+
57+
```bash
58+
slack-1 | {
59+
slack-1 | "version": "1.0",
60+
slack-1 | "id": "cc66c9e8-9905-486d-99e9-7ab89af3d976",
61+
slack-1 | "author": "odmAdmin",
62+
slack-1 | "date": 1725633110628,
63+
slack-1 | "type": "SnapshotCreated",
64+
slack-1 | "content": [
65+
slack-1 | {
66+
slack-1 | "id": "dcf08c59-877c-42d4-9360-2189345577c8",
67+
slack-1 | "internalId": "dsm.DsDeploymentBsln:103:103",
68+
slack-1 | "name": "test_deployment_2024-09-06_16-31-45-855",
69+
slack-1 | "createdBy": "odmAdmin",
70+
slack-1 | "createdOn": 1725633110000,
71+
slack-1 | "lastchangedBy": "odmAdmin",
72+
slack-1 | "lastChangedOn": 1725633110000,
73+
slack-1 | "parentId": "1558f25b-daa6-4982-8b0b-48a388c7c202",
74+
slack-1 | "documentation": null,
75+
slack-1 | "buildMode": "DecisionEngine",
76+
slack-1 | "kind": "DeploymentSnapshot"
77+
slack-1 | }
78+
slack-1 | ],
79+
slack-1 | "details": [
80+
slack-1 | {
81+
slack-1 | "targetURL": "http://172.22.0.4:9060/decisioncenter/t/library#overviewsnapshot?id=dsm.DsDeploymentBsln%3A103%3A103&datasource=jdbc%2FilogDataSource&baselineId=dsm.DsDeploymentBsln%3A103%3A103"
82+
slack-1 | }
83+
slack-1 | ],
84+
```
85+
86+
Log file structure:
87+
- `deployments.txt`: Deployment details.
88+
- `rules.txt`: Rule changes.
89+
- `releases.txt`: Release details.
90+
- `activities.txt`: Activity details.
91+
92+
### Stopping the Sample
93+
94+
```bash
95+
docker-compose -f docker-compose.yaml -f compose-odm-dev.yml down
96+
```
97+
98+
99+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
### Run this sample on Kubenetes
2+
1. Push the images to the Kubernetes registry
3+
```bash
4+
docker login $REGISTRY_HOST -u <REGISTRY_USERNAME> -p <REGISTRY_PASSWORD>
5+
docker tag webhooknotifier-slack $REGISTRY_HOST/webhooknotifier-slack
6+
docker tag webhooknotifier-logfile $REGISTRY_HOST/samples/webhooknotifier-logfile
7+
docker push $REGISTRY_HOST/samples/webhooknotifier-logfile
8+
docker push $REGISTRY_HOST/webhooknotifier-slack
9+
```
10+
11+
2. Instanciate the pods
12+
```bash
13+
kubectl run webhooknotifier-logfile --image=image-registry.openshift-image-registry.svc:5000/samples/webhooknotifier-logfile:latest --port 3000 --expose --port 3000
14+
kubectl run webhooknotifier-slack --image=image-registry.openshift-image-registry.svc:5000/samples/webhooknotifier-slack:latest --port 3000 --expose --port 3000
15+
```
16+
17+
3. Declare the services
18+
1. The logs files notifier
19+
```shell
20+
curl -k -X 'PUT' \
21+
'https://my-odm-release-odm-dc-route-samples.apps.odm-dev-ocp.cp.fyre.ibm.com/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Fwebhooknotifier-logfile.samples.svc.cluster.local%3A3000%2Fprint' \
22+
-H 'accept: */*' \
23+
-H 'Content-Type: application/json' \
24+
-d 'null' \
25+
-u odmAdmin:odmAdmin -k
26+
```
27+
28+
2. For the Slack Notifier:
29+
30+
* Generate the Token :
31+
```shell
32+
kubectl exec -ti webhooknotifier-slack -- curl -X 'GET' \
33+
'http://localhost:3000/token.generate' \
34+
-H 'accept: */*' \
35+
-H 'Content-Type: application/json'
36+
```
37+
xxxxxx.xxxxxx.xxxxxxxx -> GENERATED_TOKEN
38+
39+
This command return a token that should be injected in the next command line.
40+
41+
* Register the webhook with the generated token
42+
```shell
43+
curl -X 'PUT' -k \
44+
'https://<DC_URL>/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Fwebhooknotifier-slack.<NAMESPACE>.svc.cluster.local%3A3000%2Fslack' \
45+
-H 'accept: */*' \
46+
-H 'Content-Type: application/json' \
47+
-d '<GENERATED_TOKEN>' \
48+
-u <USERNAME_PASSWORD>
49+
```
50+
{"id":"57896361-62f8-4a0e-a86b-3da46417f493","url":"http://webhooknotifier-slack.svc.cluster.local:3000/slack","authToken":"*****************************************************"}%
51+
```
52+
Where:
53+
* DC_URL : The URL where decision center is accessible.
54+
* NAMESPACE : The namespace where the sample has been deployed.
55+
* GENERATED_TOKEN : The token generated in the previous step.
56+
* USERNAME_PASSWORD : If you installed the demo or starter mode you can put odmAdmin:odmAdmin
57+
58+
### Using the Sample
59+
60+
Once the webhook is set up, events from the Decision Center will trigger the notifications and either post messages to Slack or generate log files in the `results` directory.
61+
62+
You can trigger an event by deploying a rule app for example.
63+
64+
You can see the notification in the docker-compose windows.
65+
66+
```bash
67+
slack-1 | {
68+
slack-1 | "version": "1.0",
69+
slack-1 | "id": "cc66c9e8-9905-486d-99e9-7ab89af3d976",
70+
slack-1 | "author": "odmAdmin",
71+
slack-1 | "date": 1725633110628,
72+
slack-1 | "type": "SnapshotCreated",
73+
slack-1 | "content": [
74+
slack-1 | {
75+
slack-1 | "id": "dcf08c59-877c-42d4-9360-2189345577c8",
76+
slack-1 | "internalId": "dsm.DsDeploymentBsln:103:103",
77+
slack-1 | "name": "test_deployment_2024-09-06_16-31-45-855",
78+
slack-1 | "createdBy": "odmAdmin",
79+
slack-1 | "createdOn": 1725633110000,
80+
slack-1 | "lastchangedBy": "odmAdmin",
81+
slack-1 | "lastChangedOn": 1725633110000,
82+
slack-1 | "parentId": "1558f25b-daa6-4982-8b0b-48a388c7c202",
83+
slack-1 | "documentation": null,
84+
slack-1 | "buildMode": "DecisionEngine",
85+
slack-1 | "kind": "DeploymentSnapshot"
86+
slack-1 | }
87+
slack-1 | ],
88+
slack-1 | "details": [
89+
slack-1 | {
90+
slack-1 | "targetURL": "http://172.22.0.4:9060/decisioncenter/t/library#overviewsnapshot?id=dsm.DsDeploymentBsln%3A103%3A103&datasource=jdbc%2FilogDataSource&baselineId=dsm.DsDeploymentBsln%3A103%3A103"
91+
slack-1 | }
92+
slack-1 | ],
93+
```
94+
95+
Log file structure:
96+
- `deployments.txt`: Deployment details.
97+
- `rules.txt`: Rule changes.
98+
- `releases.txt`: Release details.
99+
- `activities.txt`: Activity details.
100+
101+
### Stopping the Sample
102+
103+
```bash
104+
oc delete svc,pods webhooknotifier-logfile
105+
oc delete svc,pods webhooknotifier-slack
106+
# TODO Delete the notification hook.
107+
108+
```

decisioncenter/webhooknotifier/README.md

Lines changed: 3 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -28,158 +28,9 @@ This NodeJS sample code will be packaged in 2 docker images.
2828
docker-compose build
2929
```
3030

31+
### Run the sample
3132

32-
### 2.1 Run this sample on Kubenetes
33-
1. Push the images to the Kubernetes registry
34-
```bash
35-
docker login $REGISTRY_HOST -u <REGISTRY_USERNAME> -p <REGISTRY_PASSWORD>
36-
docker tag webhooknotifier-slack $REGISTRY_HOST/webhooknotifier-slack
37-
docker tag webhooknotifier-logfile $REGISTRY_HOST/samples/webhooknotifier-logfile
38-
docker push $REGISTRY_HOST/samples/webhooknotifier-logfile
39-
docker push $REGISTRY_HOST/webhooknotifier-slack
40-
```
41-
42-
2. Instanciate the pods
43-
```bash
44-
kubectl run webhooknotifier-logfile --image=image-registry.openshift-image-registry.svc:5000/samples/webhooknotifier-logfile:latest --port 3000 --expose --port 3000
45-
kubectl run webhooknotifier-slack --image=image-registry.openshift-image-registry.svc:5000/samples/webhooknotifier-slack:latest --port 3000 --expose --port 3000
46-
```
47-
48-
3. Declare the services
49-
1. The logs files notifier
50-
```shell
51-
curl -k -X 'PUT' \
52-
'https://my-odm-release-odm-dc-route-samples.apps.odm-dev-ocp.cp.fyre.ibm.com/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Fwebhooknotifier-logfile.samples.svc.cluster.local%3A3000%2Fprint' \
53-
-H 'accept: */*' \
54-
-H 'Content-Type: application/json' \
55-
-d 'null' \
56-
-u odmAdmin:odmAdmin -k
57-
```
58-
59-
2. For the Slack Notifier:
60-
61-
* Generate the Token :
62-
```shell
63-
kubectl exec -ti webhooknotifier-slack -- curl -X 'GET' \
64-
'http://localhost:3000/token.generate' \
65-
-H 'accept: */*' \
66-
-H 'Content-Type: application/json'
67-
```
68-
xxxxxx.xxxxxx.xxxxxxxx -> GENERATED_TOKEN
69-
70-
This command return a token that should be injected in the next command line.
71-
72-
* Register the webhook with the generated token
73-
```shell
74-
curl -X 'PUT' -k \
75-
'https://<DC_URL>/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Fwebhooknotifier-slack.<NAMESPACE>.svc.cluster.local%3A3000%2Fslack' \
76-
-H 'accept: */*' \
77-
-H 'Content-Type: application/json' \
78-
-d '<GENERATED_TOKEN>' \
79-
-u <USERNAME_PASSWORD>
80-
```
81-
{"id":"57896361-62f8-4a0e-a86b-3da46417f493","url":"http://webhooknotifier-slack.svc.cluster.local:3000/slack","authToken":"*****************************************************"}%
82-
```
83-
Where:
84-
* DC_URL : The URL where decision center is accessible.
85-
* NAMESPACE : The namespace where the sample has been deployed.
86-
* GENERATED_TOKEN : The token generated in the previous step.
87-
* USERNAME_PASSWORD : If you installed the demo or starter mode you can put odmAdmin:odmAdmin
88-
89-
### 2.2 Run this sample on Docker
90-
We will use the ODM for developper image. No needs to have an ODM installed.
91-
92-
1. Run ODM and Notifiers docker images
93-
```bash
94-
docker-compose -f docker-compose.yaml -f compose-odm-dev.yml up
95-
```
96-
97-
2. Register the webhook in Decision Center using the REST API tool, providing the token and URL (`http://localhost:3000/slack` and `http://localhost:3000/print`).
98-
99-
1. For File Notifier:
100-
```shell
101-
curl -X 'PUT' \
102-
'http://localhost:9060/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Flogifle%3A3000%2Fprint' \
103-
-H 'accept: */*' \
104-
-H 'Content-Type: application/json' \
105-
-d 'null' \
106-
-u odmAdmin:odmAdmin
107-
```
108-
109-
2. For the Slack Notifier:
110-
111-
* Generate the Token :
112-
```shell
113-
kubectl exec -ti webhooknotifier-slack -- curl -X 'GET' \
114-
'http://localhost:3000/token.generate' \
115-
-H 'accept: */*' \
116-
-H 'Content-Type: application/json'
117-
```
118-
xxxxxx.xxxxxx.xxxxxxxx -> Token
119-
120-
This command return a token that should be injected in the next command line.
121-
122-
* Register the webhook with the generated token
123-
```shell
124-
curl -X 'PUT' \
125-
'http://localhost:9060/decisioncenter-api/v1/webhook/notify?url=http%3A%2F%2Fslack%3A3000%2Fslack' \
126-
-H 'accept: */*' \
127-
-H 'Content-Type: application/json' \
128-
-d '<GENERATED_TOKEN>' \
129-
-u odmAdmin:odmAdmin
130-
```
131-
## 3. Using the Sample
132-
133-
Once the webhook is set up, events from the Decision Center will trigger the notifications and either post messages to Slack or generate log files in the `results` directory.
134-
135-
You can trigger an event by deploying a rule app for example.
136-
137-
You can see the notification in the docker-compose windows.
138-
139-
```bash
140-
slack-1 | {
141-
slack-1 | "version": "1.0",
142-
slack-1 | "id": "cc66c9e8-9905-486d-99e9-7ab89af3d976",
143-
slack-1 | "author": "odmAdmin",
144-
slack-1 | "date": 1725633110628,
145-
slack-1 | "type": "SnapshotCreated",
146-
slack-1 | "content": [
147-
slack-1 | {
148-
slack-1 | "id": "dcf08c59-877c-42d4-9360-2189345577c8",
149-
slack-1 | "internalId": "dsm.DsDeploymentBsln:103:103",
150-
slack-1 | "name": "test_deployment_2024-09-06_16-31-45-855",
151-
slack-1 | "createdBy": "odmAdmin",
152-
slack-1 | "createdOn": 1725633110000,
153-
slack-1 | "lastchangedBy": "odmAdmin",
154-
slack-1 | "lastChangedOn": 1725633110000,
155-
slack-1 | "parentId": "1558f25b-daa6-4982-8b0b-48a388c7c202",
156-
slack-1 | "documentation": null,
157-
slack-1 | "buildMode": "DecisionEngine",
158-
slack-1 | "kind": "DeploymentSnapshot"
159-
slack-1 | }
160-
slack-1 | ],
161-
slack-1 | "details": [
162-
slack-1 | {
163-
slack-1 | "targetURL": "http://172.22.0.4:9060/decisioncenter/t/library#overviewsnapshot?id=dsm.DsDeploymentBsln%3A103%3A103&datasource=jdbc%2FilogDataSource&baselineId=dsm.DsDeploymentBsln%3A103%3A103"
164-
slack-1 | }
165-
slack-1 | ],
166-
```
167-
168-
Log file structure:
169-
- `deployments.txt`: Deployment details.
170-
- `rules.txt`: Rule changes.
171-
- `releases.txt`: Release details.
172-
- `activities.txt`: Activity details.
173-
174-
## Stopping the Sample
175-
176-
```bash
177-
docker-compose -f docker-compose.yaml -f compose-odm-dev.yml down
178-
```
179-
33+
* [In Kubernetes](README-KUBERNETES.md). (You need ODM installed in Kubernetes)
34+
* [In Docker](README-DOCKER.md).
18035

181-
## Source Files
18236

183-
You can explore and modify the source files under `/decisioncenter/samples/webhooknotifier/`, which includes:
184-
- `slack-notifier.js`: Slack webhook implementation.
185-
- `log-notifier.js`: File-based webhook implementation.

0 commit comments

Comments
 (0)