Skip to content

Protected containers: Add DELETE REST API for container protection rules

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

Protected containers: Add DELETE REST API for container protection rules

This MR adds the DELETE route to the REST API for container protection rules to allow deleting existing container protection rules.

This is part of #457518 (closed) and still behind a feature flag.

It's the equivalent to the DELETE endpoint for package protection rules, but for the container registry.

🛠 with at Siemens

MR acceptance checklist

MR Checklist ( @nwittstruck)

How to set up and validate locally

  1. Enable feature flag via rails c:
Feature.enable(:container_registry_protected_containers)
  1. Create a new container protection rule:
curl -k --request POST \
  --url https://gdk.test:3443/api/v4/projects/7/registry/protection/rules \
  --header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA' \
  --header 'Content-Type: application/json' \
  --data '{
	"repository_path_pattern": "flightjs/flight-needs-to-be-a-unique-path",
	"minimum_access_level_for_push": "maintainer",
        "minimum_access_level_for_delete": "maintainer"
    }'
  1. Now you can delete this rule - just adjust the id to the id returned by the previous command:
curl -k --request DELETE \                                                                                                                                                                 
  --url https://gdk.test:3443/api/v4/projects/7/registry/protection/rules/1 \
  --header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA'

Related to #457518 (closed)

Edited by Kamil Trzciński (Back 2025-01-01)

Merge request reports

Loading