Made gitlab:group:ensureExists action idempotent.

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-02-06 19:18:45 +01:00
committed by blam
parent 275632c349
commit a0419a6c6c
2 changed files with 24 additions and 11 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
'@backstage/plugin-scaffolder-node-test-utils': patch
---
Made gitlab:group:ensureExists action idempotent
@@ -90,17 +90,24 @@ export const createGitlabGroupEnsureExistsAction = (options: {
);
if (!subGroup) {
ctx.logger.info(`creating missing group ${fullPath}`);
parentId = (
await api.Groups.create(
name,
slug,
parentId
? {
parentId: parentId,
}
: {},
)
)?.id;
parentId = await ctx.checkpoint({
key: `ensure.${name}.${slug}.${parentId}`,
// eslint-disable-next-line no-loop-func
fn: async () => {
return (
await api.Groups.create(
name,
slug,
parentId
? {
parentId: parentId,
}
: {},
)
)?.id;
},
});
} else {
parentId = subGroup.id;
}