Merge pull request #94 from github/joshmgross/client_payload
Allow `{}` to represent any value in event payloads
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
{
|
||||
"action": "on-demand-test",
|
||||
"branch": "master",
|
||||
"client_payload": {
|
||||
"unit": false,
|
||||
"integration": true
|
||||
},
|
||||
"client_payload": {},
|
||||
"repository": {
|
||||
"id": 17273051,
|
||||
"node_id": "MDEwOlJlcG9zaXRvcnkxNzI3MzA1MQ==",
|
||||
|
||||
@@ -99,6 +99,13 @@ function getEventContext(workflowContext: WorkflowContext): ExpressionData {
|
||||
function merge(d: data.Dictionary, toAdd: Object): data.Dictionary {
|
||||
for (const [key, value] of Object.entries(toAdd)) {
|
||||
if (value && typeof value === "object" && !d.get(key)) {
|
||||
|
||||
if (!Array.isArray(value) && Object.entries(value).length === 0) {
|
||||
// Allow an empty object to be any value
|
||||
d.add(key, new data.Null());
|
||||
continue;
|
||||
}
|
||||
|
||||
d.add(key, merge(new data.Dictionary(), value));
|
||||
} else {
|
||||
d.add(key, new data.Null());
|
||||
|
||||
@@ -1236,5 +1236,23 @@ jobs:
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it("allows any property in client_payload", async () => {
|
||||
const input = `
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [test]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo \${{ github.event.client_payload.anything }}
|
||||
- run: echo \${{ github.event.client_payload.branch }}`
|
||||
|
||||
const result = await validate(createDocument("wf.yaml", input));
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user