ContainerTagRemover 0.1.14

This package has a SemVer 2.0.0 package version: 0.1.14+1.
dotnet tool install --global ContainerTagRemover --version 0.1.14                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local ContainerTagRemover --version 0.1.14                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ContainerTagRemover&version=0.1.14                
nuke :add-package ContainerTagRemover --version 0.1.14                

Container Tag Remover

Container Tag Remover is a .NET tool written in C# to remove old image tags from container registries. It supports Dockerhub and Azure Container Registry and can be easily extended to support new container registries in the future. The tool determines which tags to remove based on SemVer and a configuration file that specifies the number of tags to keep for Major and Minor versions.

Features

  • Supports Dockerhub (experimental) and Azure Container Registry
  • Easily extensible to support new container registries
  • Removes old image tags based on SemVer and configuration file
  • Follows SOLID principles
  • 100% code coverage in tests
  • Uses xUnit as the test framework
  • Uses Moq as the mocking library
  • Uses Shouldly for assertions
  • Tests are in a separate project from the main tool code

Configuration File

The configuration file is a JSON file that specifies the number of tags to keep for Major and Minor versions. Example structure:

{
  "Major": 5,
  "Minor": 10
}

If the configuration file is not specified, the tool will use the default values: Major: 2, Minor: 2.

Environment Variables

To authenticate with Azure Container Registry and Dockerhub, you need to set the following environment variables:

Azure Container Registry

  • AZURE_TENANT_ID: Your Azure tenant ID.
  • AZURE_CLIENT_ID: Your Azure client ID.
  • AZURE_CLIENT_SECRET: Your Azure client secret (optional, if not set, DefaultAzureCredential will be used).

Example:

export AZURE_TENANT_ID=your-tenant-id
export AZURE_CLIENT_ID=your-client-id
export AZURE_CLIENT_SECRET=your-client-secret

Dockerhub

  • DOCKERHUB_USERNAME: Your Dockerhub username.
  • DOCKERHUB_PASSWORD: Your Dockerhub password.

Note: Dockerhub implementation is experimental.

Example:

export DOCKERHUB_USERNAME=your-username
export DOCKERHUB_PASSWORD=your-password

Running the Tool

To run the Container Tag Remover tool, follow these steps:

  1. Install the tool as a .NET global tool:
dotnet tool install --global ContainerTagRemover
  1. Run the tool using the following command:
containertagremover <registry-url> <image> <config-file> [--output-file <output-file>]

Replace <registry-url>, <image>, and <config-file> with the appropriate values. Optionally, specify <output-file> to output the list of removed and kept tags to a JSON file.

If the configuration file is not specified, the tool will use the default values: Major: 2, Minor: 2.

If any of the required arguments are not provided, the tool will prompt you to enter them during execution.

Note

Azure container registry image names must be lowercase.

Contributing

We welcome contributions to this project! Please see the Contributing Guidelines for more information on how to get started.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
0.1.14 37 12/13/2024
0.1.13 37 12/13/2024
0.1.12 41 12/13/2024
0.1.11 43 12/12/2024
0.1.10 38 12/12/2024
0.1.9 42 12/12/2024
0.1.8 36 12/12/2024
0.1.7 38 12/12/2024
0.1.6 37 12/12/2024
0.1.5 36 12/12/2024
0.1.4 43 12/11/2024
0.1.3 40 12/11/2024
0.1.2 41 12/11/2024
0.1.1 39 12/11/2024
0.1.0 41 12/11/2024