-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: main
Are you sure you want to change the base?
Conversation
a0b56e1
to
b91358e
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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