Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/+sync_result.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow sync and build tasks to properly return the created repository_version (depends on pulpcore to support task results).
26 changes: 18 additions & 8 deletions pulp_container/app/tasks/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
import tempfile
from uuid import uuid4

from pulpcore.plugin.models import (
Artifact,
ContentArtifact,
Content,
PulpTemporaryFile,
)
from pulpcore.plugin.util import get_domain

from pulp_container.constants import MEDIA_TYPE
from pulp_container.app.models import (
Blob,
BlobManifest,
ContainerRepository,
Manifest,
Tag,
)
from pulp_container.constants import MEDIA_TYPE
from pulp_container.app.utils import calculate_digest
from pulpcore.plugin.models import (
Artifact,
ContentArtifact,
Content,
PulpTemporaryFile,
)
from pulpcore.plugin.util import get_domain


def get_or_create_blob(layer_json, manifest, path):
Expand Down Expand Up @@ -192,6 +193,15 @@ def build_image(
if isinstance(containerfile_artifact, PulpTemporaryFile):
containerfile_artifact.delete()

if repository_version:
try:
from pulpcore.plugin.serializers import RepositoryVersionSerializer

repository_version = RepositoryVersionSerializer(
instance=repository_version, context={"request": None}
).data
except ImportError:
pass
return repository_version


Expand Down
2 changes: 1 addition & 1 deletion pulp_container/app/tasks/download_image_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def download_image_data(repository_pk, remote_pk, raw_text_manifest_data, tag_na
log.info("Pulling cache: repository={r} remote={p}".format(r=repository.name, p=remote.name))
first_stage = ContainerPullThroughFirstStage(remote, raw_text_manifest_data, tag_name)
dv = ContainerDeclarativeVersion(first_stage, repository)
return dv.create()
dv.create()


class ContainerPullThroughFirstStage(ContainerFirstStage):
Expand Down
10 changes: 9 additions & 1 deletion pulp_container/app/tasks/synchronize.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ def synchronize(remote_pk, repository_pk, mirror, signed_only):
log.info("Synchronizing: repository={r} remote={p}".format(r=repository.name, p=remote.name))
first_stage = ContainerFirstStage(remote, signed_only)
dv = ContainerDeclarativeVersion(first_stage, repository, mirror)
return dv.create()
rv = dv.create()
if rv:
try:
from pulpcore.plugin.serializers import RepositoryVersionSerializer

rv = RepositoryVersionSerializer(instance=rv, context={"request": None}).data
except ImportError:
pass
return rv


class ContainerDeclarativeVersion(DeclarativeVersion):
Expand Down