Migrate from cnr -> appr

This commit is contained in:
Antoine Legrand 2017-07-31 19:18:34 +02:00
parent fe6760749a
commit 6336a4a971
16 changed files with 106 additions and 68 deletions

View file

@ -1,8 +1,8 @@
from datetime import datetime
import cnr.semver
import appr.semver
from cnr.exception import raise_package_not_found, raise_channel_not_found
from appr.exception import raise_package_not_found, raise_channel_not_found
import data.model
@ -76,7 +76,7 @@ class OCIAppModel(AppRegistryDataInterface):
if not releases:
continue
available_releases = [
str(x) for x in sorted(cnr.semver.versions(releases, False), reverse=True)]
str(x) for x in sorted(appr.semver.versions(releases, False), reverse=True)]
channels = None
if with_channels:
channels = [
@ -173,19 +173,19 @@ class OCIAppModel(AppRegistryDataInterface):
MediaType.DoesNotExist):
raise_package_not_found(package_name, release, media_type)
def store_blob(self, cnrblob, content_media_type):
fp = cnrblob.packager.io_file
path = cnrblob.upload_url(cnrblob.digest)
def store_blob(self, apprblob, content_media_type):
fp = apprblob.packager.io_file
path = apprblob.upload_url(apprblob.digest)
locations = storage.preferred_locations
storage.stream_write(locations, path, fp, 'application/x-gzip')
db_blob = oci_model.blob.get_or_create_blob(cnrblob.digest, cnrblob.size, content_media_type,
db_blob = oci_model.blob.get_or_create_blob(apprblob.digest, apprblob.size, content_media_type,
locations)
return BlobDescriptor(mediaType=content_media_type,
digest=_strip_sha256_header(db_blob.digest), size=db_blob.size, urls=[])
def create_release(self, package, user, visibility, force=False):
""" Add an app-release to a repository
package is an instance of data.cnr.package.Package
package is an instance of data.appr.package.Package
"""
manifest = package.manifest()