Skip to content

Protected packages: GraphQL api for querying package protection rules

What does this MR do and why?

🛠 with at Siemens

Screenshots or screen recordings

With this MR it is possible to send graphql request in order to query package protection rules.

The body of the graphql request looks like this. Note: Including the field packagesCleanupPolicy is only for testing purpose.

query {
	project(fullPath: "flightjs/Flight") {
		packagesProtectionRules {
			nodes {
				packageNamePattern
				packageType
				pushProtectedUpToAccessLevel
			}
		}
	}
}

image

How to set up and validate locally

  1. rails db:migrate
  2. Enable feature flag via rails c
Feature.enable(:packages_protected_packages)
  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' \
  --data '{"query":"query {\n\tproject(fullPath: \"flightjs/Flight\") {\n\t\tpackagesProtectionRules {\n\t\t\tnodes {\n\t\t\t\tpackageNamePattern\n\t\t\t\tpackageType\n\t\t\t\tpushProtectedUpToAccessLevel\n\t\t\t}\n\t\t}\n\t\tpackagesCleanupPolicy {\n\t\t\tkeepNDuplicatedPackageFiles\n\t\t}\t\t\n\t}\n}\n"}'

Todos

  • Integrate feature flag (incl. tests)
  • Add more tests regarding authorization
  • Think about integrating a rails enum for the field push_protected_up_to_access_level

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #416381 (closed)

Edited by Gerardo Navarro

Merge request reports