Code review small fixes
This commit is contained in:
parent
492934de3c
commit
63f9043312
4 changed files with 20 additions and 18 deletions
|
@ -62,9 +62,9 @@ def fetch_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
|
||||||
logger.exception('Got exception when trying to parse manifest `%s`', manifest_ref)
|
logger.exception('Got exception when trying to parse manifest `%s`', manifest_ref)
|
||||||
raise ManifestInvalid()
|
raise ManifestInvalid()
|
||||||
|
|
||||||
manifest = _rewrite_to_schema1_if_necessary(namespace_name, repo_name, manifest_ref, manifest,
|
supported = _rewrite_to_schema1_if_necessary(namespace_name, repo_name, manifest_ref, manifest,
|
||||||
parsed)
|
parsed)
|
||||||
if manifest is None:
|
if supported is None:
|
||||||
raise ManifestUnknown()
|
raise ManifestUnknown()
|
||||||
|
|
||||||
track_and_log('pull_repo', repository_ref, analytics_name='pull_repo_100x', analytics_sample=0.01,
|
track_and_log('pull_repo', repository_ref, analytics_name='pull_repo_100x', analytics_sample=0.01,
|
||||||
|
@ -72,11 +72,11 @@ def fetch_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
|
||||||
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True])
|
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True])
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
manifest.bytes,
|
supported.bytes,
|
||||||
status=200,
|
status=200,
|
||||||
headers={
|
headers={
|
||||||
'Content-Type': manifest.media_type,
|
'Content-Type': supported.media_type,
|
||||||
'Docker-Content-Digest': manifest.digest,
|
'Docker-Content-Digest': supported.digest,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -101,17 +101,17 @@ def fetch_manifest_by_digest(namespace_name, repo_name, manifest_ref):
|
||||||
logger.exception('Got exception when trying to parse manifest `%s`', manifest_ref)
|
logger.exception('Got exception when trying to parse manifest `%s`', manifest_ref)
|
||||||
raise ManifestInvalid()
|
raise ManifestInvalid()
|
||||||
|
|
||||||
manifest = _rewrite_to_schema1_if_necessary(namespace_name, repo_name, '$digest', manifest,
|
supported = _rewrite_to_schema1_if_necessary(namespace_name, repo_name, '$digest', manifest,
|
||||||
parsed)
|
parsed)
|
||||||
if manifest is None:
|
if supported is None:
|
||||||
raise ManifestUnknown()
|
raise ManifestUnknown()
|
||||||
|
|
||||||
track_and_log('pull_repo', repository_ref, manifest_digest=manifest_ref)
|
track_and_log('pull_repo', repository_ref, manifest_digest=manifest_ref)
|
||||||
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True])
|
metric_queue.repository_pull.Inc(labelvalues=[namespace_name, repo_name, 'v2', True])
|
||||||
|
|
||||||
return Response(manifest.bytes, status=200, headers={
|
return Response(supported.bytes, status=200, headers={
|
||||||
'Content-Type': manifest.media_type,
|
'Content-Type': supported.media_type,
|
||||||
'Docker-Content-Digest': manifest.digest,
|
'Docker-Content-Digest': supported.digest,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,14 @@ class ManifestInterface(object):
|
||||||
def blob_digests(self):
|
def blob_digests(self):
|
||||||
""" Returns an iterator over all the blob digests referenced by this manifest,
|
""" Returns an iterator over all the blob digests referenced by this manifest,
|
||||||
from base to leaf. The blob digests are strings with prefixes. For manifests that reference
|
from base to leaf. The blob digests are strings with prefixes. For manifests that reference
|
||||||
config as a blob, the blob will be included here.
|
config as a blob, the blob will be included here as the last entry.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractproperty
|
@abstractproperty
|
||||||
def local_blob_digests(self):
|
def local_blob_digests(self):
|
||||||
""" Returns an iterator over all the *non-remote* blob digests referenced by this manifest,
|
""" Returns an iterator over all the *non-remote* blob digests referenced by this manifest,
|
||||||
from base to leaf. The blob digests are strings with prefixes. For manifests that reference
|
from base to leaf. The blob digests are strings with prefixes. For manifests that reference
|
||||||
config as a blob, the blob will be included here.
|
config as a blob, the blob will be included here as the last entry.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
|
@ -172,8 +172,9 @@ class DockerSchema1Manifest(ManifestInterface):
|
||||||
raise MalformedSchema1Manifest('manifest data does not match schema: %s' % ve)
|
raise MalformedSchema1Manifest('manifest data does not match schema: %s' % ve)
|
||||||
|
|
||||||
self._signatures = self._parsed.get(DOCKER_SCHEMA1_SIGNATURES_KEY)
|
self._signatures = self._parsed.get(DOCKER_SCHEMA1_SIGNATURES_KEY)
|
||||||
|
self._architecture = self._parsed.get(DOCKER_SCHEMA1_ARCH_KEY)
|
||||||
|
|
||||||
self._tag = self._parsed[DOCKER_SCHEMA1_REPO_TAG_KEY]
|
self._tag = self._parsed[DOCKER_SCHEMA1_REPO_TAG_KEY]
|
||||||
self._architecture = self._parsed[DOCKER_SCHEMA1_ARCH_KEY]
|
|
||||||
|
|
||||||
repo_name = self._parsed[DOCKER_SCHEMA1_REPO_NAME_KEY]
|
repo_name = self._parsed[DOCKER_SCHEMA1_REPO_NAME_KEY]
|
||||||
repo_name_tuple = repo_name.split('/')
|
repo_name_tuple = repo_name.split('/')
|
||||||
|
|
|
@ -291,7 +291,7 @@ class DockerSchema2Manifest(ManifestInterface):
|
||||||
if self.has_remote_layer:
|
if self.has_remote_layer:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return list(self._manifest_image_layers(content_retriever))[-1].v1_id
|
return self.get_legacy_image_ids(content_retriever)[-1].v1_id
|
||||||
|
|
||||||
def get_legacy_image_ids(self, content_retriever):
|
def get_legacy_image_ids(self, content_retriever):
|
||||||
if self.has_remote_layer:
|
if self.has_remote_layer:
|
||||||
|
@ -344,8 +344,9 @@ class DockerSchema2Manifest(ManifestInterface):
|
||||||
raise MalformedSchema2Manifest('Could not load config blob for manifest')
|
raise MalformedSchema2Manifest('Could not load config blob for manifest')
|
||||||
|
|
||||||
if len(config_bytes) != self.config.size:
|
if len(config_bytes) != self.config.size:
|
||||||
raise MalformedSchema2Manifest('Size of config does not match that retrieved: %s vs %s',
|
msg = 'Size of config does not match that retrieved: %s vs %s' % (len(config_bytes),
|
||||||
len(config_bytes), self.config.size)
|
self.config.size)
|
||||||
|
raise MalformedSchema2Manifest(msg)
|
||||||
|
|
||||||
self._cached_built_config = DockerSchema2Config(config_bytes)
|
self._cached_built_config = DockerSchema2Config(config_bytes)
|
||||||
return self._cached_built_config
|
return self._cached_built_config
|
||||||
|
|
Reference in a new issue