Merge pull request #2718 from coreos-inc/tag-expiration

Formal tag expiration support
This commit is contained in:
josephschorr 2017-07-19 17:48:11 -04:00 committed by GitHub
commit a6db05e8b5
32 changed files with 621 additions and 117 deletions

Binary file not shown.

View file

@ -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'