Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const result = await executeGoal(
{
projectLoader: this.configuration.sdm.projectLoader,
goalExecutionListeners: this.goalExecutionListeners,
},
{
...implementation,
projectListeners: [...toArray(implementation.projectListeners || []), ...listeners],
},
goalInvocation);
const terminatingStates = [
SdmGoalState.canceled,
SdmGoalState.failure,
SdmGoalState.skipped,
SdmGoalState.stopped,
SdmGoalState.success,
SdmGoalState.waiting_for_approval,
];
if (!result || !result.state || terminatingStates.includes(result.state)) {
await reportEndAndClose(result, start, progressLog);
}
return {
...result,
// successfully handled event even if goal failed
code: 0,
};
} catch (e) {
e.message = `Goal executor threw exception: ${e.message}`;
const egr: ExecuteGoalResult = {
code: 1,
message: e.message,
state: SdmGoalState.failure,
function buildStatusToSdmGoalState(buildStatus: BuildStatus): SdmGoalState {
switch (buildStatus) {
case "passed":
return SdmGoalState.success;
case "broken":
case "failed":
case "canceled":
return SdmGoalState.failure;
default:
return SdmGoalState.in_process;
}
}
const IsGoal: CreatePushTest = async (test, additionalTests, extensionTests) => {
if (test.isGoal) {
return isGoal(
{
name: typeof test.isGoal.name === "string" ? new RegExp(test.isGoal.name) : test.isGoal.name,
state: test.isGoal.state || SdmGoalState.success,
pushTest: test.isGoal.test ? await mapTest(test.isGoal.test, additionalTests, extensionTests) : undefined,
output: typeof test.isGoal.output === "string" ? new RegExp(test.isGoal.output) : test.isGoal.output,
data: typeof test.isGoal.data === "string" ? new RegExp(test.isGoal.data) : test.isGoal.data,
});
}
return undefined;
};
id,
context,
addressChannels,
deployableArtifact,
credentials,
};
logger.info("About to invoke %d ArtifactListener registrations", params.registrations.length);
await Promise.all(params.registrations
.map(toArtifactListenerRegistration)
.filter(async arl => !arl.pushTest || !!(await arl.pushTest.mapping(pli)))
.map(l => l.action(ai)));
});
}
await updateGoal(context, artifactSdmGoal, {
state: SdmGoalState.success,
description: params.goal.successDescription,
url: image.imageName,
});
logger.info("Updated artifact goal '%s'", artifactSdmGoal.name);
return Success;
}
}
addressChannels: undefined,
preferences,
credentials,
configuration: this.configuration,
context,
});
}
await updateGoal(context, sdmGoal, {
state: SdmGoalState.requested,
description: !!sdmGoal.descriptions && !!sdmGoal.descriptions.requested
? sdmGoal.descriptions.requested : goal.requestedDescription,
data: g.data,
});
} else if (sdmGoal.state === SdmGoalState.approved) {
await updateGoal(context, sdmGoal, {
state: SdmGoalState.success,
description: !!sdmGoal.descriptions && !!sdmGoal.descriptions.completed
? sdmGoal.descriptions.completed : goal.successDescription,
});
}
break;
case GoalApprovalRequestVote.Denied:
if (sdmGoal.state === SdmGoalState.pre_approved) {
const g: SdmGoalEvent = {
...sdmGoal,
preApproval: undefined,
};
await updateGoal(context, g, {
state: SdmGoalState.waiting_for_pre_approval,
description: `${!!sdmGoal.descriptions && !!sdmGoal.descriptions.waitingForPreApproval ?
sdmGoal.descriptions.waitingForPreApproval : goal.waitingForPreApprovalDescription} \u00B7 start by @${sdmGoal.preApproval.userId} denied`,
});