Skip to content

Commit 7acd71b

Browse files
committed
fix: 🐛 fix gitlab deletion API request
1 parent 181d649 commit 7acd71b

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

plugins/gitlab/src/class.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ export class GitlabApi extends PluginApi {
181181
}
182182
}
183183

184-
public async deleteRepository(repoId: number) {
185-
return this.api.Projects.remove(repoId, { permanentlyRemove: true })
184+
public async deleteRepository(repoId: number, fullPath: string) {
185+
await this.api.Projects.remove(repoId) // Marks for deletion
186+
return this.api.Projects.remove(repoId, { permanentlyRemove: true, fullPath }) // Effective deletion
186187
}
187188
}
188189

plugins/gitlab/src/functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const upsertDsoProject: StepCall<Project> = async (payload) => {
143143
export const deleteDsoProject: StepCall<Project> = async (payload) => {
144144
try {
145145
const group = await payload.apis.gitlab.getProjectGroup()
146-
if (group) await deleteGroup(group?.id)
146+
if (group) await deleteGroup(group.id, group.full_path)
147147

148148
return {
149149
status: {
@@ -208,7 +208,7 @@ export const deleteZone: StepCall<ZoneObject> = async (payload) => {
208208
try {
209209
const gitlabApi = payload.apis.gitlab
210210
const zoneRepo = await gitlabApi.getOrCreateInfraProject(payload.args.slug)
211-
await gitlabApi.deleteRepository(zoneRepo.id)
211+
await gitlabApi.deleteRepository(zoneRepo.id, zoneRepo.path_with_namespace)
212212
return returnResult
213213
} catch (error) {
214214
returnResult.error = parseError(cleanGitlabError(error))

plugins/gitlab/src/group.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { getApi } from './utils.js'
22

3-
export async function deleteGroup(groupId: number) {
3+
export async function deleteGroup(groupId: number, fullPath: string) {
44
const api = getApi()
5-
return api.Groups.remove(groupId)
5+
await api.Groups.remove(groupId) // Marks for deletion
6+
return api.Groups.remove(groupId, { permanentlyRemove: true, fullPath }) // Effective deletion
67
}

plugins/gitlab/src/repositories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function ensureRepositories(gitlabApi: GitlabProjectApi, project: P
2323
&& !gitlabRepository.topics?.includes(pluginManagedTopic)
2424
&& !project.repositories.find(repo => repo.internalRepoName === gitlabRepository.name,
2525
)))
26-
.map(gitlabRepository => gitlabApi.deleteRepository(gitlabRepository.id)),
26+
.map(gitlabRepository => gitlabApi.deleteRepository(gitlabRepository.id, gitlabRepository.path_with_namespace)),
2727
// create missing repositories
2828
...project.repositories.map(repo => ensureRepositoryExists(gitlabRepositories, repo, gitlabApi, projectMirrorCreds, vaultApi)),
2929
]

0 commit comments

Comments
 (0)