Merge pull request #3057 from quay/joseph.schorr/QUAY-893/blob-mount

Implement support for blob mounting via the `mount` parameter on blob uploads
This commit is contained in:
Joseph Schorr 2018-06-06 13:13:39 -04:00 committed by GitHub
commit e22b0ce004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 291 additions and 63 deletions

View file

@ -796,6 +796,43 @@ def test_squashed_images(use_estimates, pusher, sized_images, liveserver_session
tarfile.open(fileobj=tar.extractfile(tar.getmember('%s/layer.tar' % expected_image_id)))
@pytest.mark.parametrize('push_user, push_namespace, push_repo, mount_repo_name, expected_failure', [
# Successful mount, same namespace.
('devtable', 'devtable', 'baserepo', 'devtable/baserepo', None),
# Successful mount, cross namespace.
('devtable', 'buynlarge', 'baserepo', 'buynlarge/baserepo', None),
# Unsuccessful mount, unknown repo.
('devtable', 'devtable', 'baserepo', 'unknown/repohere', Failures.UNAUTHORIZED_FOR_MOUNT),
# Unsuccessful mount, no access.
('public', 'public', 'baserepo', 'public/baserepo', Failures.UNAUTHORIZED_FOR_MOUNT),
])
def test_blob_mounting(push_user, push_namespace, push_repo, mount_repo_name, expected_failure,
manifest_protocol, pusher, puller, basic_images, liveserver_session,
app_reloader):
# Push an image so we can attempt to mount it.
pusher.push(liveserver_session, push_namespace, push_repo, 'latest', basic_images,
credentials=(push_user, 'password'))
# Push again, trying to mount the image layer(s) from the mount repo.
options = ProtocolOptions()
options.scopes = ['repository:devtable/newrepo:push,pull',
'repository:%s:pull' % (mount_repo_name)]
options.mount_blobs = {image.id: mount_repo_name for image in basic_images}
manifest_protocol.push(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
credentials=('devtable', 'password'),
options=options,
expected_failure=expected_failure)
if expected_failure is None:
# Pull to ensure it worked.
puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
credentials=('devtable', 'password'))
def get_robot_password(api_caller):
api_caller.conduct_auth('devtable', 'password')
resp = api_caller.get('/api/v1/organization/buynlarge/robots/ownerbot')