use CheckpointOptions where possible

Signed-off-by: Kurt King <kurtaking@gmail.com>
This commit is contained in:
Kurt King
2025-03-21 22:42:27 -06:00
committed by benjdlambert
parent 919a616673
commit 3fb5a07af2
2 changed files with 11 additions and 9 deletions
@@ -50,6 +50,7 @@ import {
import { createConditionAuthorizer } from '@backstage/plugin-permission-node';
import { actionExecutePermission } from '@backstage/plugin-scaffolder-common/alpha';
import {
CheckpointOptions,
TaskContext,
TemplateAction,
TemplateFilter,
@@ -375,10 +376,9 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
secrets: task.secrets ?? {},
logger: taskLogger,
workspacePath,
async checkpoint<T extends JsonValue | void>(opts: {
key?: string;
fn: () => Promise<T> | T;
}) {
async checkpoint<T extends JsonValue | void>(
opts: CheckpointOptions<T>,
) {
const { key: checkpointKey, fn } = opts;
const key = `v1.task.checkpoint.${step.id}.${checkpointKey}`;
@@ -21,7 +21,10 @@ import {
mockServices,
} from '@backstage/backend-test-utils';
import { JsonObject, JsonValue } from '@backstage/types';
import { ActionContext } from '@backstage/plugin-scaffolder-node';
import {
ActionContext,
CheckpointOptions,
} from '@backstage/plugin-scaffolder-node';
import { loggerToWinstonLogger } from './loggerToWinstonLogger';
/**
@@ -44,10 +47,9 @@ export function createMockActionContext<
output: jest.fn(),
createTemporaryDirectory: jest.fn(),
input: {} as TActionInput,
async checkpoint<T extends JsonValue | void>(opts: {
key: string;
fn: () => Promise<T> | T;
}): Promise<T> {
async checkpoint<T extends JsonValue | void>(
opts: CheckpointOptions<T>,
): Promise<T> {
return opts.fn();
},
getInitiatorCredentials: () => Promise.resolve(credentials),