Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 35,023
    • Issues 35,023
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 1,264
    • Merge Requests 1,264
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #209916

Closed
Open
Opened Mar 10, 2020 by Nicolò Maria Mezzopera@nmezzoperaMaintainer

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

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
13.6
Milestone
13.6 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: gitlab-org/gitlab#209916