Add ability to "protect" images#1
Open
jmloeffler wants to merge 5 commits intocavemandaveman:masterfrom
Open
Conversation
* remove dependence on Enum * add argument to specify file containing protected images * use image digests to protect images from deletion
harbor-cleanup.py
Outdated
| from enum import Enum | ||
|
|
||
| __version_info__ = ('17', '06', '2') | ||
| __version_info__ = ('18', '07', '31') |
Owner
There was a problem hiding this comment.
Versioning should be yy.MM.X, where X is 0 if it's the first release of the month, then increments with every release throughout the month. Similar to Docker's versioning schema.
| parser.add_argument('project', type=str, help="name of the Harbor project to clean") | ||
|
|
||
| if len(sys.argv[1:])==0: | ||
| parser.print_version() |
Owner
There was a problem hiding this comment.
Why get rid of displaying the version here and line 18?
| -c PRESERVE_COUNT, --preserve-count PRESERVE_COUNT | ||
| keep the last n number of image tags (by reverse | ||
| alphanumerical order); defaults to 5 | ||
| -k FILE_PATH, --keep-file FILE_PATH |
Owner
There was a problem hiding this comment.
Can you update the usage part with this option, similiar to line 14. Should like the output of python ./harbor-cleanup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We sometimes need to clean our registry of old images but want to protect certain images that may be running in prod or serve as a rollback point that we want to keep around. Unfortunately, deleting tags will also delete other tags that are based on the same image sha/digest and the image will disappear.
These changes let you pass in an optional file of tags that you want to keep and then does a comparison of the image digests to protect those images from deletion. Comparing the image sha/digests also handles the case when there's a tag not specified for protection that points at the same image as a tag that was specified to keep. In that case both tags will be kept.