From 80d9170114e95c4df5f447b136c24a9a75c947b3 Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:44:27 -0300 Subject: [PATCH] draft/wip build task configblob bytes --- pulp_container/app/tasks/builder.py | 33 ++++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/pulp_container/app/tasks/builder.py b/pulp_container/app/tasks/builder.py index e15f6052a..f805dd34a 100644 --- a/pulp_container/app/tasks/builder.py +++ b/pulp_container/app/tasks/builder.py @@ -34,28 +34,21 @@ def get_or_create_blob(layer_json, manifest, path): blob.touch() except Blob.DoesNotExist: layer_file_name = os.path.join(path, layer_json["digest"][7:]) - layer_artifact = Artifact.init_and_validate(layer_file_name) - layer_artifact.save() blob = Blob(digest=layer_json["digest"]) - blob.save() - ContentArtifact( - artifact=layer_artifact, content=blob, relative_path=layer_json["digest"] - ).save() - #if layer_json["mediaType"] in [MEDIA_TYPE.CONFIG_BLOB_OCI, MEDIA_TYPE.CONFIG_BLOB]: - # with open(layer_file_name, "r") as content_file: - # raw_data = content_file.read() - # blob.data = raw_data - # blob.save() - #else: - # layer_artifact = Artifact.init_and_validate(layer_file_name) - # layer_artifact.save() - # ContentArtifact( - # artifact=layer_artifact, content=blob, relative_path=layer_json["digest"] - # ).save() - # BlobManifest(manifest=manifest, manifest_blob=blob).save() + if layer_json["mediaType"] in [MEDIA_TYPE.CONFIG_BLOB_OCI, MEDIA_TYPE.CONFIG_BLOB]: + with open(layer_file_name, "r") as content_file: + raw_data = content_file.read() + blob.data = raw_data.encode('utf-8') + blob.save() + else: + layer_artifact = Artifact.init_and_validate(layer_file_name) + layer_artifact.save() + blob.save() + ContentArtifact( + artifact=layer_artifact, content=blob, relative_path=layer_json["digest"] + ).save() + BlobManifest(manifest=manifest, manifest_blob=blob).save() - if layer_json["mediaType"] != MEDIA_TYPE.CONFIG_BLOB_OCI: - BlobManifest(manifest=manifest, manifest_blob=blob).save() return blob