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

Fixed ICAv2 event rule prefix matching #371

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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 @@ -88,6 +88,8 @@ export class Icav2AnalysisEventHandlerConstruct extends Construct {
})
);

const rulePrefix = this.coerce_names(`umccr__automated__${props.workflowName}`);

// Create a rule for this state machine
const rule = new events.Rule(this, 'rule', {
eventBus: eventbus_obj,
Expand All @@ -100,7 +102,7 @@ export class Icav2AnalysisEventHandlerConstruct extends Construct {
payload: {
userReference: [
{
prefix: `umccr__automated__${props.workflowName}`,
prefix: rulePrefix,
},
],
},
Expand All @@ -119,4 +121,17 @@ export class Icav2AnalysisEventHandlerConstruct extends Construct {
/* Grant the state machine the ability to submit events to the event bus */
eventbus_obj.grantPutEventsTo(this.stateMachineObj.role);
}

private coerce_names(name: string) {
/*
Convert a workflow name to lowercase and remove any spacing

This has to be in align with Python impl:
lib/workload/components/event-workflowrunstatechange-internal-to-inputmaker-sfn/lambdas/generate_workflow_run_name_py/generate_workflow_run_name.py
*/
let _name = name.toLowerCase().replace(new RegExp(' ', 'g'), '');
_name = _name.replace(new RegExp('\\.', 'g'), '-');
_name = _name.replace(new RegExp('_', 'g'), '-');
return _name;
}
}