Skip to content

GraphQL for dependency proxy TTL policy

Steve Abrams requested to merge 2941870-ttl-policy-graphql into master

🌳 What does this MR do?

Adds GraphQL endpoints and the update service to query and update the DependencyProxy::ImageTtlGroupPolicy model. This is part of the effort to add TTL policies to the Dependency Proxy in #294187 (closed).

📸 Screenshots or Screencasts (strongly suggested)

Query on group without settings created Update mutation
Screen_Shot_2021-09-03_at_2.38.48_PM Screen_Shot_2021-09-03_at_2.36.25_PM

🐘 Database

These are the queries generated when running the queries shown in the screenshots above for the gitlab-org group.

Select query: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/6386/commands/21755

SELECT "dependency_proxy_image_ttl_group_policies".* FROM "dependency_proxy_image_ttl_group_policies" WHERE "dependency_proxy_image_ttl_group_policies"."group_id" = 9970;

Update Mutation: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/6386/commands/21756

UPDATE "dependency_proxy_image_ttl_group_policies" SET "ttl" = 30, "enabled" = false WHERE "dependency_proxy_image_ttl_group_policies"."group_id" = 9970;

📝 How to setup and validate locally (strongly suggested)

  1. Create a group

  2. Query the data:

    GraphQL queries

    Query:

     {
       group(fullPath: "<your-group-path") {
         id
         dependencyProxyImageTtlPolicy {
           enabled
           ttl
           createdAt
           updatedAt
         }
       }
     }

    Update:

    mutation updateDependencyProxyImageTtlGroupPolicyMutation($dependencyProxyImageTtlPolicy: 
    UpdateDependencyProxyImageTtlGroupPolicyInput!) {
      updateDependencyProxyImageTtlGroupPolicy(input:$dependencyProxyImageTtlPolicy) {
        dependencyProxyImageTtlPolicy {
          enabled,
          ttl
        }
      }
    }
    
    # Query variables
    {
      "dependencyProxyImageTtlPolicy": {
        "groupPath": "<your-group-path",
        "enabled": true,
        "ttl": 14
      }
    }

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Steve Abrams

Merge request reports