Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Proposal: Add Minimum and Maximum Retention Policies to Acr Purge

未关闭
#670 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@gildardogmsft 已经在做这个了。

开始于 2026年9月28日。

  • #693 来自 @gildardogmsft —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
cli

调研方向

从 acr purge 入口点开始,追踪现有的 --keep 行为、tag 和 dangling manifest 过滤、排序、分页以及 dry-run 报告。将验收标准作为完成定义:保持兼容性,验证 flag 组合,独立应用最小值/最大值策略,并覆盖分页、过滤器、已锁定项、相同时间戳以及新变为 dangling 的 manifest。

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
Go
星标
71
派生
52
平均合并
8 天 10 小时
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/acr-cli 的其他 Issue

查看 Azure/acr-cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。