You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(purge): add --include-locked flag to purge command (#479)
* feat: add --include-locked flag to annotate command
- Add --include-locked flag to annotate command to handle locked manifests/tags
- Skip locked manifests and tags when --include-locked is not set
- Display "x manifests/tags skipped as they are locked" messages
- Update function signatures to include includeLocked parameter and return skip counts
- Add comprehensive test coverage for new functionality
- Update documentation in README.md and CLAUDE.md
* feat: rename --force flag to --include-locked in purge command
- Rename --force flag to --include-locked across the entire codebase
- Update purge command help text and examples
- Update function signatures and parameter names throughout:
- purgeParams.force -> purgeParams.includeLocked
- force parameter -> includeLocked parameter
- Update all tests to use new flag name
- Maintain same functionality: unlock locked manifests/tags before deletion
* fix: improve dry run output messages in purge command
Change "Deleting" to "Would delete" in dry run mode to make output less scary and more accurate.
* docs: add warning to readme
Signed-off-by: Dávid Balatoni <[email protected]>
* refactor: change GetUntaggedManifests to return ManifestAttributesBase objects
Changes GetUntaggedManifests function signature from returning []string to
[]acr.ManifestAttributesBase to provide full manifest attributes to callers.
This enables optimization by avoiding extra API calls for manifest attributes
in downstream functions.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* feat: optimize PurgeManifests to use existing manifest attributes
Eliminates extra GetAcrManifestAttributes API call per manifest by using
the manifest attributes already provided by GetUntaggedManifests. This
significantly improves performance when purging many locked manifests
with the --include-locked flag.
Also improves error handling by continuing with deletion attempts even
when unlock operations fail.
* fix: update callers to handle new GetUntaggedManifests return type
Updates purge.go and annotate.go to handle the new ManifestAttributesBase
return type from GetUntaggedManifests. The annotate command converts the
manifest objects to digest strings for compatibility with the existing
Annotate method.
* test: update tests to reflect PurgeManifests optimization
Removes expectation for GetAcrManifestAttributes call in purge_test.go
since the optimization eliminates this API call. The test now correctly
validates that the function works with the manifest attributes already
provided by GetUntaggedManifests.
* test: add tests for --include-locked flag in annotate command
Adds comprehensive tests for the --include-locked flag functionality
in the annotate command, including:
- Test that locked tags are included when flag is set
- Test that locked tags are skipped when flag is not set
- Test that locked untagged manifests are included when flag is set
- Test dry run behavior with locked manifests
Note: Unlike the purge command, annotate does not currently unlock
manifests before annotating them. The tests document the current
behavior of filtering locked manifests.
* fix: uneccessary singleSkippedManifestsCount
* fix: handle HTTP 405 responses gracefully in purger deletion operations
* test: add functional test script
* refactor: move testing scripts to scripts/experimental
* fix: testing README
* test: improve test scripts with hyperfine
* test: faster image generation
* test: image generation fix
* test: use more images by default
* test: no warmups and only run everything once
* test: compare locked and unlocked
---------
Signed-off-by: Dávid Balatoni <[email protected]>
Co-authored-by: Claude <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,19 @@ acr purge \
208
208
--repository-page-size 10
209
209
```
210
210
211
+
#### Include-locked flag
212
+
To delete locked manifests and tags (where deleteEnabled or writeEnabled is false), the `--include-locked` flag should be set. This will unlock them before deletion.
213
+
214
+
**Warning:** The `--include-locked` flag will unlock and delete images that have been locked for protection. Use this flag with caution as it bypasses the image lock mechanism. For more information about image locking, see [Lock a container image in an Azure container registry](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-image-lock).
cmd.Flags().StringSliceVarP(&annotateParams.annotations, "annotations", "a", []string{}, "The configurable annotation key value that can be specified one or more times")
142
152
cmd.Flags().BoolVar(&annotateParams.untagged, "untagged", false, "If the untagged flag is set, all the manifests that do not have any tags associated to them will also be annotated, except if they belong to a manifest list that contains at least one tag")
143
153
cmd.Flags().BoolVar(&annotateParams.dryRun, "dry-run", false, "If the dry-run flag is set, no manifest or tag will be annotated. The output would be the same as if they were annotated")
154
+
cmd.Flags().BoolVar(&annotateParams.includeLocked, "include-locked", false, "If the include-locked flag is set, locked manifests and tags (where writeEnabled is false) will be annotated")
0 commit comments