Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 50,428
    • Issues 50,428
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,550
    • Merge requests 1,550
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #209916
Closed
Open
Issue created Mar 10, 2020 by Nicolò Maria Mezzopera@nmezzoperaDeveloper

Use the Container Registry API to fetch image details based on image_id

Problem to solve

Currently, the Container Registry API is able to:

  • List container repository for a project: https://docs.gitlab.com/ee/api/container_registry.html#within-a-project
  • List container repository for a group: https://docs.gitlab.com/ee/api/container_registry.html#within-a-group

But we need a way to fetch the container repository details based on id, both for project and groups

Proposal

Fetch the container repository details (with the tag list included) with the following URL:

  • /registry/repositories/:repository_id (any level)

Further details

Implementation

@10io says:

By providing the :repository_id (the container repository id), we can find the linked GitLab project object (the container repository model is linked to project). With it, we can run all the permission checks against current_user. The only caution to have here is to not reply 404 Not found when the container repo or the project is not found but something like 403 Forbidden.

This new API endpoint should return the same payload as: Entities::ContainerRegistry::Repository, tags: true and in addition have the bulk delete path ( the one returned by this: https://gitlab.com/gitlab-org/gitlab/blob/22c19861a6b2137e5b57ab04798b81c721349cf0/app/controllers/projects/registry/repositories_controller.rb#L34-35 )

Most probably we want to hide that path for non-ui requests ( if is possible )

POC

In the POC, we made: !26503 (closed)

The API is provisorily implemented with:

      desc 'Get repository details' do
        detail 'This feature was introduced in GitLab 12.9.'
        success Entities::ContainerRegistry::Repository
      end
      params do
        requires :repository_id, type: Integer, desc: 'The ID of the repository'
      end
      get ':id/registry/repositories/:repository_id' do
        present repository, with: Entities::ContainerRegistry::Repository, tags: true
      end

in lib/api/project_container_repositories.rb

Why it's important

By expanding the API to allow listing images by ID, we will be able to implement:

  • #208469 (closed)
  • #216795 (closed)
  • #216761 (closed)

Testing and Availability

Need to refactor:

  • spec/requests/api/group_container_repositories_spec.rb
  • spec/requests/api/project_container_repositories_spec.rb

This change can also impact the test design for the API tests at the feature/end-to-end level for the Container Registry

Edited Oct 12, 2020 by Sofia Vistas
Assignee
Assign to
Time tracking