Skip to content

Commit

Permalink
draft/wip build task configblob bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hyagi committed Apr 17, 2024
1 parent 02ea286 commit 80d9170
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions pulp_container/app/tasks/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 80d9170

Please sign in to comment.