def _write_manifest_and_log(namespace_name, repo_name, tag_name, manifest_impl): repository_ref, manifest, tag = _write_manifest(namespace_name, repo_name, tag_name, manifest_impl) # Queue all blob manifests for replication. if features.STORAGE_REPLICATION: blobs = registry_model.get_manifest_local_blobs(manifest) if blobs is None: logger.error('Could not lookup blobs for manifest `%s`', manifest.digest) else: with queue_replication_batch( namespace_name) as queue_storage_replication: for blob_digest in blobs: queue_storage_replication(blob_digest) track_and_log('push_repo', repository_ref, tag=tag_name) spawn_notification(repository_ref, 'repo_push', {'updated_tags': [tag_name]}) metric_queue.repository_push.Inc( labelvalues=[namespace_name, repo_name, 'v2', True]) return Response( 'OK', status=202, headers={ 'Docker-Content-Digest': manifest.digest, 'Location': url_for('v2.fetch_manifest_by_digest', repository='%s/%s' % (namespace_name, repo_name), manifest_ref=manifest.digest), }, )
def _write_manifest_and_log(namespace_name, repo_name, tag_name, manifest_impl): repository_ref, manifest, tag = _write_manifest( namespace_name, repo_name, tag_name, manifest_impl ) # Queue all blob manifests for replication. if features.STORAGE_REPLICATION: blobs = registry_model.get_manifest_local_blobs(manifest) if blobs is None: logger.error("Could not lookup blobs for manifest `%s`", manifest.digest) else: with queue_replication_batch(namespace_name) as queue_storage_replication: for blob_digest in blobs: queue_storage_replication(blob_digest) track_and_log("push_repo", repository_ref, tag=tag_name) spawn_notification(repository_ref, "repo_push", {"updated_tags": [tag_name]}) metric_queue.repository_push.Inc(labelvalues=[namespace_name, repo_name, "v2", True]) return Response( "OK", status=202, headers={ "Docker-Content-Digest": manifest.digest, "Location": url_for( "v2.fetch_manifest_by_digest", repository="%s/%s" % (namespace_name, repo_name), manifest_ref=manifest.digest, ), }, )
def test_generate_url(initialized_db): try: application.register_blueprint(v2_bp, url_prefix="/v2") except: # Already registered. pass repo_ref = registry_model.lookup_repository("devtable", "simple") tag = registry_model.get_repo_tag(repo_ref, "latest") manifest = tag.manifest blobs = registry_model.get_manifest_local_blobs(manifest) retriever = BlobURLRetriever(storage, instance_keys, application) headers = retriever.headers_for_download(repo_ref, blobs[0]) identity, _ = identity_from_bearer_token(headers["Authorization"][0]) assert len(identity.provides) == 1 provide = list(identity.provides)[0] assert provide.role == "read" assert provide.name == "simple" assert provide.namespace == "devtable" assert provide.type == "repository" assert retriever.url_for_download(repo_ref, blobs[0]).startswith( "http://localhost:5000/v2/devtable/simple/blobs/" )