Skip to content

Sorting for repository tags in GraphQL

Steve Abrams requested to merge 336497-containerrepository-tag-resolver into master

What does this MR do and why?

This adds the ability to:

  • sort container_repository tags by name using GraphQL
  • filter container_repository tags by name using GraphQL

📸 Screenshots or screen recordings

Sort by name_asc sort by name_desc with filter on name
Screen_Shot_2021-11-22_at_4.14.28_PM Screen_Shot_2021-11-22_at_4.14.47_PM Screen_Shot_2021-11-22_at_4.15.30_PM

How to set up and validate locally

  1. Ensure your container registry is working with your GDK.
  2. In a separate folder, create a Docker file:
    FROM scratch
    
    copy foo /etc/var/foo
    and a file foo with some random text inside of it.
  3. From a project in your local instance, navigate to Packages & Registries => Container Registry
  4. Copy the docker build command.
  5. Build a Docker image, adding a tag to the end of it (aaa in this example):
    docker build -t gdk.test:5000/my-proj:aaa .
  6. Repeat, building a variety of tags with different names.
  7. Push the tags:
    docker push 
    
    gdk.test:5000/my-proj:aaa
  8. Visit the graphql explorer page: http://gdk.test:3001/-/graphql-explorer
  9. Query the tags with the queries from the above screenshots (your repository ID may be different if you already have other existing container repositories):
    {
      containerRepository(id:"gid://gitlab/ContainerRepository/1") {
        tags(sort: NAME_DESC) {
          nodes {
            name
          }
        }
      }
    }

📓 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 #336497 (closed)

Edited by Steve Abrams

Merge request reports