feat(scaffolder-backend-module-gitlab): createGitlabProjectMigrateAction returns migration id

Signed-off-by: mpsanchis <33475618+mpsanchis@users.noreply.github.com>
This commit is contained in:
mpsanchis
2025-01-27 16:11:28 +01:00
parent cec92027c7
commit 9545c5f66e
4 changed files with 25 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
---
Action createGitlabProjectMigrateAction writes migration Id to its output
@@ -24,7 +24,9 @@ import yaml from 'yaml';
const mockGitlabClient = {
Migrations: {
create: jest.fn(),
create: jest.fn(() => ({
id: 0,
})),
},
};
@@ -22,7 +22,9 @@ import { createMockDirectory } from '@backstage/backend-test-utils';
const mockGitlabClient = {
Migrations: {
create: jest.fn(),
create: jest.fn(() => ({
id: 0,
})),
},
};
@@ -89,6 +89,10 @@ export const createGitlabProjectMigrateAction = (options: {
title: 'URL to the newly imported repo',
type: 'string',
},
migrationId: {
title: 'Id of the migration that imports the project',
type: 'number',
},
},
},
},
@@ -135,17 +139,21 @@ export const createGitlabProjectMigrateAction = (options: {
};
try {
await api.Migrations.create(sourceConfig, migrationEntity);
const { id: migrationId } = await api.Migrations.create(
sourceConfig,
migrationEntity,
);
ctx.output(
'importedRepoUrl',
`${destinationHost}/${destinationNamespace}/${destinationSlug}`,
);
ctx.output('migrationId', migrationId);
} catch (e: any) {
throw new InputError(
`Failed to transfer repo ${sourceFullPath}. Make sure that ${sourceFullPath} exists in ${sourceUrl}, and token has enough rights.\nError: ${e}`,
);
}
ctx.output(
'importedRepoUrl',
`${destinationHost}/${destinationNamespace}/${destinationSlug}`,
);
},
});
};