Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Proposal: Add Minimum and Maximum Retention Policies to Acr Purge

Đang mở
#670 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@gildardogmsft đang làm issue này rồi.

Từ ngày 28/9/2026.

  • #693 của @gildardogmsft — đang mở

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu với entry point của acr purge và lần theo hành vi hiện có của --keep, việc lọc tag và dangling manifest, xếp hạng, phân trang và báo cáo dry-run. Sử dụng các tiêu chí chấp nhận làm định nghĩa done: duy trì khả năng tương thích, xác thực các tổ hợp flag, áp dụng độc lập các chính sách tối thiểu/tối đa và bao quát phân trang, bộ lọc, các mục bị khóa, các timestamp bằng nhau và những manifest mới trở thành dangling.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

What is the problem you're trying to solve

Customers need to combine age-based retention with minimum and maximum count limits.

For example, customers may want either of these behaviors:

  • Delete tags older than 3 days or outside the 10 most recent matching tags.
  • Delete tags older than 3 days only when they are outside the 10 most recent matching tags.

The existing --keep option does not express either policy consistently because it preserves items only from the set already eligible for age-based deletion. Changing its behavior would break existing purge configurations.

Describe the solution you'd like

Add explicit minimum and maximum retention options:

Option Behavior
--min-tags N Protect the newest N matching tags from age-based deletion
--max-tags N Retain no more than N matching tags per repository
--min-untagged-manifests N Protect the newest N dangling manifests from age-based deletion
--max-untagged-manifests N Retain no more than N dangling manifests per repository
Maximum retention: OR behavior
acr purge \
    --registry example \
    --filter "repository:.*" \
    --ago 3d \
    --max-tags 10

A matching tag is deleted when it is older than 3 days or outside the 10 most recent matching tags. This is a hard ceiling; fewer than 10 tags may remain after applying the age policy.

Minimum retention: AND behavior
acr purge \
    --registry example \
    --filter "repository:.*" \
    --ago 3d \
    --min-tags 10

A matching tag is deleted only when it is older than 3 days and outside the 10 most recent matching tags. The newest 10 matching tags are protected from age-based deletion.

The same behavior applies independently to dangling manifests:

acr purge \
    --registry example \
    --untagged-only \
    --ago 3d \
    --min-untagged-manifests 20 \
    --max-untagged-manifests 100
Combining minimum and maximum retention

Minimum and maximum options may be combined:

acr purge \
    --registry example \
    --filter "repository:.*" \
    --ago 3d \
    --min-tags 10 \
    --max-tags 50

This creates three retention zones:

  1. The newest 10 matching tags are protected from age pruning.
  2. Tags 11 through 50 are retained only while newer than 3 days.
  3. Tags beyond 50 are deleted regardless of age.

Equivalent selection logic:

delete :=
    rank > maxTags
    OR
    (olderThanAgo AND rank > minTags)

Compatibility and validation

  • Existing --keep behavior remains unchanged.
  • --keep cannot be combined with the new count policies for the same resource.
  • --min-* requires --ago, because it guards age-based deletion and does not select items independently.
  • --max-* works with or without --ago.
  • When both are supplied, the minimum must not exceed the maximum.
  • Limits apply per repository and effective filter.
  • Tag and dangling-manifest limits are independent.
  • Items are ranked by LastUpdateTime, newest first, with deterministic tie-breaking.
  • When using --untagged, manifest retention is evaluated after tag deletion.
  • Locked items that prevent satisfying a maximum are reported clearly.
  • Dry-run output identifies whether deletion is caused by age, maximum count, or both.

Repository-level conditions that determine whether purge runs at all, such as --purge-if-tags-exceed, are a separate feature and are not part of this retention proposal.

Acceptance criteria

  • Age-only, minimum, maximum, and combined policies work for tags and dangling manifests.
  • Minimum options provide AND behavior and maximum options provide OR behavior.
  • Ranking works across paginated results.
  • Existing filters and --keep behavior remain compatible.
  • Invalid flag combinations produce clear errors.
  • Tests cover pagination, filters, locked items, equal timestamps, and manifests made dangling during the purge.
Ngôn ngữ chính
Go
Star
71
Fork
52
Merge trung bình
8 ngày 10 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/acr-cli

Tất cả issue của Azure/acr-cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.