Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add immediate deletion of groups #168

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

buehlmann
Copy link
Contributor

@buehlmann buehlmann commented Nov 24, 2024

Description of your changes

On GitLab Premium and Ultimate, the delete action on a group just marks the group as deleted. By default, the group will be deleted seven days in the future. To delete the group immediately two rest calls are needed:

  1. DELETE request to /groups/:id which marks the group in the "pending for deletion" state (docs)
  2. DELETE request to /groups/:id with attributes permanently_remove=true and full_path set. The group will be deleted immediate.

This change introduce the optional fields PermanentlyRemove and FullPath on the GitLab group resource. This allows the user to enforce an immediate deletion of GitLab groups.

The same behavior exist by deleting projects (see #121, #149) and could be implemented in the same way as done here for groups. Before this feature can be implemented for projects, one needs to extend the xanzy/go-gitlab client with DeleteProjectOptions along the lines of DeleteGroupOptions.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Provider has been built locally and deployed on a AKS cluster. Deletion of GitLab Groups has been successfully end to end tested with and without PermanentlyRemove and FullPath fields set.

@buehlmann buehlmann changed the title Implements immediate deletion of GitLab groups Add immediate deletion of GitLab groups Nov 24, 2024
@buehlmann buehlmann changed the title Add immediate deletion of GitLab groups feat: Add immediate deletion of groups Nov 24, 2024
@dariozachow
Copy link
Collaborator

dariozachow commented Nov 29, 2024

can you rebase on master?

@buehlmann
Copy link
Contributor Author

@dariozachow MR rebased on master

@dariozachow
Copy link
Collaborator

dariozachow commented Dec 3, 2024

Unfortunately this only works for subgroups. Is there some way we can filter for this error permanently_remove option is only available for subgroups after trying the full deletion once? Or ignore top level groups at all

@buehlmann
Copy link
Contributor Author

I would just skip the newly introduced deletion statement if the group to delete is on the root level. Determine if it's a root group, I would by testing group.path == group.full_path. If this condition is true, the group is on the root level. What do you think?

@dariozachow
Copy link
Collaborator

sounds good to me

@buehlmann
Copy link
Contributor Author

@dariozachow delete logic adjusted as discussed

@dariozachow dariozachow merged commit c33c853 into crossplane-contrib:master Dec 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants