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

pass parent execution id to broadside #22

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const RetriggerButton = ({ executions, refreshExecutions }: IRetriggerBut
console.log(res.status);
return res.json();
})
/* eslint-disable no-console */
.then((data) => console.log(data))
.catch((e) => console.error('error retriggering: ', e))
.finally(() => {
Expand Down
40 changes: 30 additions & 10 deletions spin-observatory-plugin-deck/src/services/broadside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,44 @@ const BROADSIDE_URI = `${SETTINGS.gateUrl}/proxies/broadside/v1/broadsides`;
// See https://github.com/one-thd/broadside/blob/main/api/swagger.yml#L206
const retriggerExecutions = ({ executions }: { executions: IExecution[] }) => {
/***
* application: "clipper"
* pipelineNameOrId: "Generate Clipper X.509 Key Pair"
* amount: 50
* delay: 100
* pipelineBaseParameters: '{ "parameterName": "custom data" }'
* application: "clipper"
* pipelineNameOrId: "Generate Clipper X.509 Key Pair"
* amount: 50
* delay: 100
* pipelineBaseParameters: '{ "parameterName": "custom data" }'
* pipelineMultiParameters: '[ { "multiParameterName": "custom data" } ]'
* executionID: 'QWERTYUIOP'
*/

const application = executions[0].application;
const pipelineNameOrId = executions[0].name;
const amount = executions.length;
const pipelineMultiParameters = executions.map((e) => e.trigger.parameters);
const broadsideRequest = JSON.stringify({
application: executions[0].application,
pipelineNameOrId: executions[0].name,
amount: executions.length,
pipelineMultiParameters: executions.map((e) => e.trigger.parameters),
executionID: getParentExecutionId(executions[0]),
});

return fetch(BROADSIDE_URI, {
method: 'POST',
credentials: 'include',
body: JSON.stringify({ application, pipelineNameOrId, amount, pipelineMultiParameters }),
body: broadsideRequest,
});
};

const getParentExecutionId = (e: IExecution) => {
let executionID;
const parent = e.trigger.parentExecution;
const parameters = e.trigger.parameters;

if (parent && parent.id) {
executionID = parent.id;
} else if (parameters && parameters['parentExecutionId']) {
executionID = parameters['parentExecutionId'];
} else {
executionID = e.id;
}

return executionID;
};

export const broadside = { retriggerExecutions };