feat(scaffolder-backend-module-gitlab): createGitlabProjectMigrateAction returns migration id
Signed-off-by: mpsanchis <33475618+mpsanchis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
|
||||
---
|
||||
|
||||
Action createGitlabProjectMigrateAction writes migration Id to its output
|
||||
+3
-1
@@ -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}`,
|
||||
);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user