Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #109] queryWebHookConfigById endpoint causes NPE and returns empty response & Optimize Hard-coding #110

Merged
merged 4 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 45 additions & 49 deletions docs/design-document/14-webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Configuration information description
*/
private String manufacturerName;

/**
* manufacturer domain name, like www.github.com
*/
private String manufacturerDomain;

/**
* webhook event name, like rep-push
*/
Expand Down Expand Up @@ -78,12 +83,7 @@ Configuration information description
* roll out data format -> CloudEvent serialization mode
* If HTTP protocol is used, the request header contentType needs to be marked
*/
private String dataContentType = "application/json";;

/**
* source of event
*/
private String cloudEventSource;
private String dataContentType = "application/json";

/**
* id of cloudEvent, like uuid/manufacturerEventId
Expand All @@ -92,7 +92,7 @@ Configuration information description

```

##### Add webhook config
##### Add WebHook config

path: /webhook/insertWebHookConfig
method: POST
Expand All @@ -104,58 +104,31 @@ input params:
| -- | -- | -- | -- | -- |
| callbackPath | call address, unique address | string | Y | null |
| manufacturerName | manufacturer name | string | Y | null |
| manufacturerEventName | manufacturer EventName | string | Y | null |
| manufacturerDomain | manufacturer domain name | string | Y | null |
| manufacturerEventName | manufacturer event name | string | Y | null |
| contentType | http connettype | string | N | application/json |
| description | configuration instructions | string | N | null |
| secret | signature string | string | N | null |
| userName | username | string | N | null |
| password | password | string | N | null |
| cloudEventName | cloudEvent name | string | Y | null |
| cloudEventSource | cloudEvent source | string | Y | null |
| cloudEventIdGenerateMode | cloudEvent event object identification method, uuid or event id | string | N manufacturerEventId |
| cloudEventIdGenerateMode | cloudEvent event object identification method, uuid or event id | string | N |manufacturerEventId|

E.g:

```json

{
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github",
"manufacturerEventName":"all",
"secret":"eventmesh",
"cloudEventName":"github-eventmesh",
"cloudEventSource":"github"
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github",
"manufacturerDomain":"www.github.com",
"manufacturerEventName":"all",
"cloudEventName":"github-eventmesh"
}

```

Output params: 1 for success, 0 for failure

##### delete webhook config
path: /webhook/deleteWebHookConfig
method: POST
contentType: application/json

input params:

| field | desc | type | necessary | default |
| -- | -- | -- | -- | -- |
| callbackPath | call address, unique address | string | Y | null |


E.g:

```json

{
"callbackPath":"/webhook/github/eventmesh/all"
}

```

Output params: 1 for success, 0 for failure

##### select WebHookConfig by callbackPath
##### Query WebHook config by callback path
path: /webhook/queryWebHookConfigById
method: POST
contentType: application/json
Expand All @@ -165,15 +138,15 @@ input params:
| field | desc | type | necessary | default |
| -- | -- | -- | -- | -- |
| callbackPath | call address, unique address | string | Y | null |
| manufacturerName | the caller of this callbackPath belongs to | string | Y | null |

E.g:

```json

{
"callbackPath":"/webhook/github/eventmesh/all"
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github"
}

```

Output params:
Expand All @@ -182,14 +155,14 @@ Output params:
| -- | -- | -- | -- | -- |
| callbackPath | call address, unique address | string | Y | null |
| manufacturerName | manufacturer name | string | Y | null |
| manufacturerDomain | manufacturer domain name | string | Y | null |
| manufacturerEventName | manufacturer event name | string | Y | null |
| contentType | http connettype | string | N | application/json |
| description | configuration instructions | string | N | null |
| secret | signature key | string | N | null |
| userName | user name | string | N | null |
| password | password | string | N | null |
| cloudEventName | cloudEvent name | string | Y | null |
| cloudEventSource | cloudEvent source | string | Y | null |
| cloudEventIdGenerateMode | cloudEvent event object identification method, uuid or event id | string | N | manufacturerEventId |


Expand Down Expand Up @@ -221,16 +194,40 @@ Output params:
| -- | -- | -- | -- | -- |
| callbackPath | call address, unique address | string | Y | null |
| manufacturerName | manufacturer name | string | Y | null |
| manufacturerDomain | manufacturer domain name | string | Y | null |
| manufacturerEventName | manufacturer event name | string | Y | null |
| contentType | http connettype | string | N | application/json |
| description | configuration instructions | string | N | null |
| secret | signature key | string | N | null |
| userName | user name | string | N | null |
| password | password | string | N | null |
| cloudEventName | cloudEvent name | string | Y | null |
| cloudEventSource | cloudEvent source | string | Y | null |
| cloudEventIdGenerateMode | cloudEvent event object identification method, uuid or event id | string | N | manufacturerEventId |

##### Delete WebHook config

path: /webhook/deleteWebHookConfig
method: POST
contentType: application/json

input params:

| field | desc | type | necessary | default |
| ---------------- | ------------------------------------------ | ------ | --------- | ------- |
| callbackPath | call address, unique address | string | Y | null |
| manufacturerName | the caller of this callbackPath belongs to | string | Y | null |


E.g:

```json
{
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github"
}
```

Output params: 1 for success, 0 for failure

#### The third step: Check if the configuration is successful

Expand Down Expand Up @@ -272,4 +269,3 @@ secret: signature string




Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ eventMesh.webHook.producer.connector=standalone
*/
private String manufacturerName;

/**
* 厂商的域名
* manufacturer domain name, like www.github.com
*/
private String manufacturerDomain;

/**
* 厂商的事件名
* webhook event name ,like rep-push
Expand Down Expand Up @@ -86,12 +92,7 @@ eventMesh.webHook.producer.connector=standalone
* roll out data format -> CloudEvent serialization mode
* If HTTP protocol is used, the request header contentType needs to be marked
*/
private String dataContentType = "application/json";;

/**
* source of event
*/
private String cloudEventSource;
private String dataContentType = "application/json";

/**
* cloudEvent事件对象唯一标识符识别方式,uuid或者manufacturerEventId(厂商id)
Expand All @@ -111,55 +112,28 @@ contentType: application/json
| -- | -- | -- | -- | -- |
| callbackPath | 调用地址,唯一地址 | string | 是 | null |
| manufacturerName | 厂商名 | string | 是 | null |
| manufacturerDomain | 厂商的域名 | string | 是 | null |
| manufacturerEventName | 厂商事件名 | string | 是 | null |
| contentType | http connettype | string | 否 | application/json |
| description | 配置说明 | string | 否 | null |
| secret | 验签密钥 | string | 否 | null |
| userName | 用户名 | string | 否 | null |
| password | 用户密码 | string | 否 | null |
| cloudEventName | 事件名() | string | 是 | null |
| cloudEventSource | 事件来源可以填写 | string | 是 | null |
| cloudEventName | 事件名 | string | 是 | null |
| cloudEventIdGenerateMode | cloudEvent事件对象唯一标识符识别方式,uuid或者manufacturerEventId(厂商id) | string | 否 | manufacturerEventId |

列子:
```json

{
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github",
"manufacturerEventName":"all",
"secret":"eventmesh",
"cloudEventName":"github-eventmesh",
"cloudEventSource":"github"
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github",
"manufacturerDomain":"www.github.com",
"manufacturerEventName":"all",
"cloudEventName":"github-eventmesh"
}

```
输出参数:1 成功,0失败

##### 删除接口
路径: /webhook/deleteWebHookConfig
方法: POST
contentType: application/json

输入参数:
| 字段 | 说明 | 类型 | 必须 | 默认值 |
| -- | -- | -- | -- | -- |
| callbackPath | 调用地址,唯一地址 | string | 是 | null |


列子:

```json

{
"callbackPath":"/webhook/github/eventmesh/all"
}

```


输出参数:1 成功,0失败

##### 通过callbackPath查询WebHookConfig
路径: /webhook/queryWebHookConfigById
方法: POST
Expand All @@ -169,16 +143,16 @@ contentType: application/json
| 字段 | 说明 | 类型 | 必须 | 默认值 |
| -- | -- | -- | -- | -- |
| callbackPath | 调用地址,唯一地址 | string | 是 | null |
| manufacturerName | 调用地址的提供方 | string | 是 | null |


列子:

```json

{
"callbackPath":"/webhook/github/eventmesh/all"
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github"
}

```


Expand All @@ -187,14 +161,14 @@ contentType: application/json
| -- | -- | -- | -- | -- |
| callbackPath | 调用地址,唯一地址 | string | 是 | null |
| manufacturerName | 厂商名 | string | 是 | null |
| manufacturerDomain | 厂商的域名 | string | 是 | null |
| manufacturerEventName | 厂商事件名 | string | 是 | null |
| contentType | http connettype | string | 否 | application/json |
| description | 配置说明 | string | 否 | null |
| secret | 验签密钥 | string | 否 | null |
| userName | 用户名 | string | 否 | null |
| password | 用户密码 | string | 否 | null |
| cloudEventName | 事件名() | string | 是 | null |
| cloudEventSource | 事件来源可以填写 | string | 是 | null |
| cloudEventIdGenerateMode | cloudEvent事件对象唯一标识符识别方式,uuid或者manufacturerEventId(厂商id) | string | 否 | manufacturerEventId |


Expand Down Expand Up @@ -225,18 +199,44 @@ contentType: application/json
| -- | -- | -- | -- | -- |
| callbackPath | 调用地址,唯一地址 | string | 是 | null |
| manufacturerName | 厂商名 | string | 是 | null |
| manufacturerDomain | 厂商的域名 | string | 是 | null |
| manufacturerEventName | 厂商事件名 | string | 是 | null |
| contentType | http connettype | string | 否 | application/json |
| description | 配置说明 | string | 否 | null |
| secret | 验签密钥 | string | 否 | null |
| userName | 用户名 | string | 否 | null |
| password | 用户密码 | string | 否 | null |
| cloudEventName | 事件名() | string | 是 | null |
| cloudEventSource | 事件来源可以填写 | string | 是 | null |
| cloudEventIdGenerateMode | cloudEvent事件对象唯一标识符识别方式,uuid或者manufacturerEventId(厂商id) | string | 否 | manufacturerEventId |

##### 删除接口

路径: /webhook/deleteWebHookConfig
方法: POST
contentType: application/json

输入参数:

| 字段 | 说明 | 类型 | 必须 | 默认值 |
| ---------------- | ------------------ | ------ | ---- | ------ |
| callbackPath | 调用地址,唯一地址 | string | 是 | null |
| manufacturerName | 调用地址的提供方 | string | 是 | null |


列子:

```json
{
"callbackPath":"/webhook/github/eventmesh/all",
"manufacturerName":"github"
}
```


输出参数:1 成功,0失败

#### 第三步:查看配置是否成功

1. file存储模式。请到eventMesh.webHook.fileMode.filePath 目录下查看。文件名为callbackPath转移后的
2. nacos存储模式。请到eventMesh.webHook.nacosMode.serverAddr 配置的nacos服务去看

Expand Down Expand Up @@ -265,4 +265,3 @@ secret: 验签字符串