PR feedback
* Use only the ID returned from the group create method, to avoid unnecessary cast * Better changeset Signed-off-by: Thorsten Lanfer <tlanfer@gmail.com>
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
|
||||
---
|
||||
|
||||
Allow the usage of oauth tokens for the gitlab:group:ensureExists action
|
||||
Updated `gitlab:group:ensureExists` action to instead use oauth client.
|
||||
|
||||
@@ -66,7 +66,7 @@ export const createGitlabGroupEnsureExistsAction = (options: {
|
||||
const api = getClient({ host, integrations, token });
|
||||
|
||||
let currentPath: string | null = null;
|
||||
let parent: GroupSchema | null = null;
|
||||
let parentId: number | null = null;
|
||||
for (const pathElement of path) {
|
||||
const fullPath: string = currentPath
|
||||
? `${currentPath}/${pathElement}`
|
||||
@@ -79,22 +79,24 @@ export const createGitlabGroupEnsureExistsAction = (options: {
|
||||
);
|
||||
if (!subGroup) {
|
||||
ctx.logger.info(`creating missing group ${fullPath}`);
|
||||
parent = (await api.Groups.create(
|
||||
pathElement,
|
||||
pathElement,
|
||||
parent
|
||||
? {
|
||||
parentId: parent.id,
|
||||
}
|
||||
: {},
|
||||
)) as GroupSchema;
|
||||
parentId = (
|
||||
await api.Groups.create(
|
||||
pathElement,
|
||||
pathElement,
|
||||
parentId
|
||||
? {
|
||||
parentId: parentId,
|
||||
}
|
||||
: {},
|
||||
)
|
||||
)?.id;
|
||||
} else {
|
||||
parent = subGroup;
|
||||
parentId = subGroup.id;
|
||||
}
|
||||
currentPath = fullPath;
|
||||
}
|
||||
if (parent !== null) {
|
||||
ctx.output('groupId', parent?.id);
|
||||
if (parentId !== null) {
|
||||
ctx.output('groupId', parentId);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user