Skip to content

Protected containers: GraphQL query for container protection rules

What does this MR do and why?

Changelog: added

🛠 with at Siemens

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

MR Checklist (@gerardo-navarro)

Screenshots or screen recordings

With this MR, it is possible to send graphql request in order to query container protection rules. The body of the graphql request looks like this.

query {
	project(fullPath: "flightjs/Flight") {
		containerRegistryProtectionRules {
			nodes {
				repositoryPathPattern
				pushProtectedUpToAccessLevel
				deleteProtectedUpToAccessLevel
			}
		}
	}
}

grafik

How to set up and validate locally

  1. Enable feature flag via rails c
Feature.enable(:container_regsitry_protected_containers)
  1. Create some container protection rules
15.times { |i| ContainerRegistry::Protection::Rule.create(project: Project.find(7), repository_path_pattern: "flightjs/flight#{i}", push_protected_up_to_access_level: :maintainer, delete_protected_up_to_access_level: :developer) }
  1. Now, you should be able to send mutation requests via the graphql api
curl --request POST \
  --url http://gdk.test:3000/api/graphql \
  --header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA' \
  --header 'Content-Type: application/json' \
  --cookie 'perf_bar_enabled=true; BetterErrors-2.10.1-CSRF-Token=0b882179-5e4a-431b-a420-2be3701cece8; preferred_language=en' \
  --data '{"query":"query {\n\tproject(fullPath: \"flightjs/Flight\") {\n\t\tcontainerRegistryProtectionRules(first: 10) {\n\t\t\tnodes {\n\t\t\t\tid\n\t\t\t\trepositoryPathPattern\n\t\t\t\tpushProtectedUpToAccessLevel\n\t\t\t\tdeleteProtectedUpToAccessLevel\n\t\t\t}\n\t\t\tpageInfo {\n\t\t\t\tstartCursor\n\t\t\t\tendCursor\n\t\t\t\thasNextPage\n\t\t\t\thasPreviousPage\n\t\t\t}\n\t\t}\n\t}\n}\n"}'

Related to #427547 (closed)

Edited by Gerardo Navarro

Merge request reports

Loading