feat(container-registry): add container registry repository and tag commands

Summary

This MR introduces a new container-registry command (alias registry), for listing, viewing, and deleting container registry repositories and tags.

What does this MR do?

Adds support to interact with the GitLab Container Registry via glab.

  • Adds glab container-registry repository commands:
    • list
    • view
    • delete
  • Adds glab container-registry tag commands:
    • list
    • view
    • delete
    • delete-tags
  • Supports project-level repository listing with pagination, tag counts, optional embedded tags, JSON output
  • Supports group-level repository listing
  • Supports tag listing and detailed lookup
  • Support tag deletion (single tag and multiple tag, as offered by the Container Registry API)
  • Adds documentation for the new commands
  • Includes unit tests

Resolves #8314 (closed)

How has this been tested?

Included unit tests for all commands added and ran various automated checks:

go test ./internal/commands/container_registry/...
make lint
make gen-docs

Manual testing was performed against a GitLab Self-Managed instance with real container registry repositories and tags. The following flows were verified:

  • project and group repository listing + deletion
  • JSON output with --include-tags and --include-tag-details
  • tag listing with and without --details
  • single tag deletion
  • multi-tag deletion

Usage examples

List container registry repositories for a specific project:

glab container-registry repository list -R gitlab-org/cli

View a single container registry repository, including tags:

glab container-registry repository view <repo-id> --include-tags

List tags for a specific repository with detailed metadata:

glab container-registry tag list <repo-id> --details

View a single tag:

glab container-registry tag view <repo-id> latest

Delete a single tag:

glab container-registry tag delete <repo-id> latest

Delete tags in bulk (no confirmation):

glab container-registry tag delete-tags <repo-id> --name-regex-delete '^my-branch-.*' --keep-n 5 --older-than 30d -y

Files

Command registration and root command:

  • internal/commands/root.go
  • internal/commands/container_registry/container_registry.go
  • internal/commands/container_registry/container_registry_test.go

Repository commands:

  • internal/commands/container_registry/repository/repository.go
  • internal/commands/container_registry/repository/repository_test.go
  • internal/commands/container_registry/repository/list/list.go
  • internal/commands/container_registry/repository/list/list_test.go
  • internal/commands/container_registry/repository/view/view.go
  • internal/commands/container_registry/repository/view/view_test.go
  • internal/commands/container_registry/repository/delete/delete.go
  • internal/commands/container_registry/repository/delete/delete_test.go

Tag commands:

  • internal/commands/container_registry/tag/tag.go
  • internal/commands/container_registry/tag/tag_test.go
  • internal/commands/container_registry/tag/list/list.go
  • internal/commands/container_registry/tag/list/list_test.go
  • internal/commands/container_registry/tag/view/view.go
  • internal/commands/container_registry/tag/view/view_test.go
  • internal/commands/container_registry/tag/delete/delete.go
  • internal/commands/container_registry/tag/delete/delete_test.go
  • internal/commands/container_registry/tag/delete_tags/delete_tags.go
  • internal/commands/container_registry/tag/delete_tags/delete_tags_test.go

Shared helpers:

  • internal/commands/container_registry/registryutils/registryutils.go
  • internal/commands/container_registry/registryutils/registryutils_test.go

Documentation:

  • README.md
  • docs/source/_index.md
  • docs/source/container-registry/_index.md
  • docs/source/container-registry/repository/_index.md
  • docs/source/container-registry/repository/list.md
  • docs/source/container-registry/repository/view.md
  • docs/source/container-registry/repository/delete.md
  • docs/source/container-registry/tag/_index.md
  • docs/source/container-registry/tag/list.md
  • docs/source/container-registry/tag/view.md
  • docs/source/container-registry/tag/delete.md
  • docs/source/container-registry/tag/delete-tags.md
Edited by Jeroen Monteban

Merge request reports

Loading