Skip to content

Commit

Permalink
Refactor sfn->sfn context injection code by merging two functions (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lym953 committed Sep 25, 2024
1 parent 85813ef commit 682a7d6
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/commands/stepfunctions/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,6 @@ export const injectContextIntoTasks = async (
}
}

export const addTraceContextToStepFunctionParameters = ({Parameters}: StepType): void => {
if (Parameters) {
if (!Parameters.Input) {
Parameters.Input = {}
}
Parameters.Input['CONTEXT.$'] = 'States.JsonMerge($$, $, false)'
}
}

export type StateMachineDefinitionType = {
Comment?: string
StartAt?: string
Expand Down Expand Up @@ -284,7 +275,7 @@ traces, check out https://docs.datadoghq.com/serverless/step_functions/troublesh
}

if (!step.Parameters.Input) {
addTraceContextToStepFunctionParameters(step)
step.Parameters.Input = {'CONTEXT.$': 'States.JsonMerge($$, $, false)'}

return true
}
Expand All @@ -299,7 +290,7 @@ merge these traces, check out https://docs.datadoghq.com/serverless/step_functio
}

if (!step.Parameters.Input['CONTEXT.$'] && !step.Parameters.Input['CONTEXT']) {
addTraceContextToStepFunctionParameters(step)
step.Parameters.Input['CONTEXT.$'] = 'States.JsonMerge($$, $, false)'

return true
}
Expand Down

0 comments on commit 682a7d6

Please sign in to comment.