Add support for tag expiration based on a quay.expires-after
label
This commit is contained in:
parent
4663bf4194
commit
c5d8b5f86b
5 changed files with 88 additions and 4 deletions
|
@ -42,6 +42,7 @@ from image.docker.schema1 import DockerSchema1ManifestBuilder
|
|||
from initdb import wipe_database, initialize_database, populate_database
|
||||
from jsonschema import validate as validate_schema
|
||||
from util.security.registry_jwt import decode_bearer_header
|
||||
from util.timedeltastring import convert_to_timedelta
|
||||
|
||||
|
||||
try:
|
||||
|
@ -1535,6 +1536,38 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix
|
|||
self.assertTrue('text/plain' in media_types)
|
||||
self.assertTrue('application/json' in media_types)
|
||||
|
||||
def test_expiration_label(self):
|
||||
# Push a new repo with the latest tag.
|
||||
images = [{
|
||||
'id': 'someid',
|
||||
'config': {'Labels': {'quay.expires-after': '1d'}},
|
||||
'contents': 'somecontent'
|
||||
}]
|
||||
|
||||
(_, manifests) = self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
|
||||
self.conduct_api_login('devtable', 'password')
|
||||
tags = self.conduct('GET', '/api/v1/repository/devtable/newrepo/tag').json()
|
||||
tag = tags['tags'][0]
|
||||
|
||||
self.assertEqual(tag['end_ts'], tag['start_ts'] + convert_to_timedelta('1d').total_seconds())
|
||||
|
||||
def test_invalid_expiration_label(self):
|
||||
# Push a new repo with the latest tag.
|
||||
images = [{
|
||||
'id': 'someid',
|
||||
'config': {'Labels': {'quay.expires-after': 'blahblah'}},
|
||||
'contents': 'somecontent'
|
||||
}]
|
||||
|
||||
(_, manifests) = self.do_push('devtable', 'newrepo', 'devtable', 'password', images=images)
|
||||
|
||||
self.conduct_api_login('devtable', 'password')
|
||||
tags = self.conduct('GET', '/api/v1/repository/devtable/newrepo/tag').json()
|
||||
tag = tags['tags'][0]
|
||||
|
||||
self.assertIsNone(tag.get('end_ts'))
|
||||
|
||||
def test_invalid_manifest_type(self):
|
||||
namespace = 'devtable'
|
||||
repository = 'somerepo'
|
||||
|
|
Reference in a new issue