def create_tagged_manifest(self, tag_dc, manifest_data, raw_data): """ Create an Image Manifest. Args: tag_dc (pulpcore.plugin.stages.DeclarativeContent): dc for a Tag manifest_data (dict): Data about a single new ImageManifest. raw_data: (str): The raw JSON representation of the ImageManifest. """ media_type = manifest_data.get('mediaType', MEDIA_TYPE.MANIFEST_V1) if media_type == MEDIA_TYPE.MANIFEST_V2: digest = "sha256:{digest}".format( digest=tag_dc.d_artifacts[0].artifact.sha256) else: digest = self._calculate_digest(raw_data) manifest = Manifest(digest=digest, schema_version=manifest_data['schemaVersion'], media_type=media_type) relative_url = '/v2/{name}/manifests/{digest}'.format( name=self.remote.namespaced_upstream_name, digest=digest, ) url = urljoin(self.remote.url, relative_url) da = DeclarativeArtifact(artifact=tag_dc.d_artifacts[0].artifact, url=url, relative_path=digest, remote=self.remote, extra_data={'headers': V2_ACCEPT_HEADERS}) man_dc = DeclarativeContent(content=manifest, d_artifacts=[da]) return man_dc
def create_manifest(self, list_dc, manifest_data): """ Create an Image Manifest from manifest data in a ManifestList. Args: list_dc (pulpcore.plugin.stages.DeclarativeContent): dc for a ManifestList manifest_data (dict): Data about a single new ImageManifest. """ digest = manifest_data['digest'] relative_url = '/v2/{name}/manifests/{digest}'.format( name=self.remote.namespaced_upstream_name, digest=digest) manifest_url = urljoin(self.remote.url, relative_url) da = DeclarativeArtifact(artifact=Artifact(), url=manifest_url, relative_path=digest, remote=self.remote, extra_data={'headers': V2_ACCEPT_HEADERS}) manifest = Manifest( digest=manifest_data['digest'], schema_version=2 if manifest_data['mediaType'] == MEDIA_TYPE.MANIFEST_V2 else 1, media_type=manifest_data['mediaType'], ) man_dc = DeclarativeContent( content=manifest, d_artifacts=[da], extra_data={'relation': list_dc}, does_batch=False, ) return man_dc
def create_tagged_manifest_list(self, tag_dc, manifest_list_data): """ Create a ManifestList. Args: tag_dc (pulpcore.plugin.stages.DeclarativeContent): dc for a Tag manifest_list_data (dict): Data about a ManifestList """ digest = "sha256:{digest}".format( digest=tag_dc.d_artifacts[0].artifact.sha256) relative_url = '/v2/{name}/manifests/{digest}'.format( name=self.remote.namespaced_upstream_name, digest=digest, ) url = urljoin(self.remote.url, relative_url) manifest_list = Manifest( digest=digest, schema_version=manifest_list_data['schemaVersion'], media_type=manifest_list_data['mediaType'], ) da = DeclarativeArtifact(artifact=tag_dc.d_artifacts[0].artifact, url=url, relative_path=digest, remote=self.remote, extra_data={'headers': V2_ACCEPT_HEADERS}) list_dc = DeclarativeContent(content=manifest_list, d_artifacts=[da]) return list_dc
def create_pulp3_content(self): """ Create a Pulp 3 Manifest unit for saving it later in a bulk operation. """ return Manifest(digest=self.digest, media_type=self.media_type, schema_version=self.schema_version)