Skip to content

Move creation of security policy project to background worker

What does this MR do and why?

This MR adds:

  1. A new mutation that can be used as an alternative to the securityPolicyProjectCreate mutation. It triggers a background worker that creates the security policy project.
  2. A GraphQL subscription to track the created of the security policy project of a group or project.
  3. A GraphQL trigger that is triggered when the new project is created

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.

How to set up and validate locally

  1. Create a new group or project and note the full path.
  2. Subscribe to the subscription, you can use graphql-susbcription-client for this.:
    subscription {
        securityPolicyProjectCreated(fullPath: "full-path-to-your-group-or-project") {
            project {
                name
            },
            status,
            errorMessage
        }
    }
  3. call the securityPolicyProjectCreateAsync mutation:
    mutation SecurityPolicyProjectCreateAsync {
        securityPolicyProjectCreateAsync(input: { fullPath: "full-path-to-your-group-or-project"} ) {
            errors
        }
    }
    # cURL command
    curl --location 'http://localhost:3000/api/graphql' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer YOUR_API_TOKEN' \
    --data '{"query":"mutation {\n  securityPolicyProjectCreateAsync(input: {\n      fullPath: \"full-path-to-your-group-or-project\"\n    }) {\n    errors\n  }\n}","variables":{}}'
  4. After a few seconds the subscription should be triggered sending the project name:
    {"result":{"data":{"securityPolicyProjectCreated":{"name":"verify-issue-464329 - Security policy project"}}},"more":true}

Related to #464329 (closed)

Edited by Andy Schoenen

Merge request reports

Loading