Skip to content

feat: added exclude filter for purge command #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sashokbg
Copy link

Purpose of the PR

Adds a new parameter "--exclude-filter" that will override any matches in the "--filter".
Useful when we want to purge everything except some tags (ex: dev, prod, release etc)

Fixes #

#60 #59

@sashokbg sashokbg force-pushed the feat/added_purge_exclude_filter branch from a0b56e1 to b91358e Compare March 20, 2025 15:49
Copy link
Contributor

@estebanreyl estebanreyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an awesome contribution and a great addition, it does seem like it would make things easier for users. Left some minor comments, will bring it up internally but it looks good to me with some minor adjustments

@@ -355,11 +396,21 @@ func dryRunPurge(ctx context.Context, acrClient api.AcrCLIClientInterface, login
return -1, -1, err
}

var excludeRegex *regexp2.Regexp = nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Assigning nil to a pointer is unnecessary

@@ -127,6 +127,18 @@ Examples of filters
| Untag all tags that are older than the duration in app repository | --filter `"app:.*"` |
| Untag all tags that are older than the duration in all repositories | --filter `".*:.*"` |

##### Exclude filter tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep this at 4#

@@ -127,6 +127,18 @@ Examples of filters
| Untag all tags that are older than the duration in app repository | --filter `"app:.*"` |
| Untag all tags that are older than the duration in all repositories | --filter `".*:.*"` |

##### Exclude filter tag

To exclude tags from the purging, use the --exclude-filter parameter. Exclude filters take precedence over filters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you note that these are optional?

if excludeFilter != "" {
res, err := common.BuildRegexFilter(excludeFilter, regexMatchTimeout)
if err != nil {
return -1, -1, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, can you add the error wrap?

var excludeRegex *regexp2.Regexp = nil

if excludeFilter != "" {
res, err := common.BuildRegexFilter(excludeFilter, regexpMatchTimeoutSeconds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an error wrap, just to make it clearer? Like fmt.Errorf("could not build excludeFilter regex: %w:" same for the actual filter since this change will make it a little unclear as to which failed to build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants