Skip to content

Add ability to "protect" images#1

Open
jmloeffler wants to merge 5 commits intocavemandaveman:masterfrom
xplor-pay:master
Open

Add ability to "protect" images#1
jmloeffler wants to merge 5 commits intocavemandaveman:masterfrom
xplor-pay:master

Conversation

@jmloeffler
Copy link

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.

Jason Loeffler and others added 3 commits August 1, 2018 13:42
* remove dependence on Enum
* add argument to specify file containing protected images
* use image digests to protect images from deletion
from enum import Enum

__version_info__ = ('17', '06', '2')
__version_info__ = ('18', '07', '31')
Copy link
Owner

Choose a reason for hiding this comment

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

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()
Copy link
Owner

Choose a reason for hiding this comment

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

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
Copy link
Owner

@cavemandaveman cavemandaveman Aug 27, 2018

Choose a reason for hiding this comment

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

Can you update the usage part with this option, similiar to line 14. Should like the output of python ./harbor-cleanup.py

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