Skip to content

Commit 20b0e62

Browse files
committed
Use pushitem content() to upload
pushitem content method returns a file-like object with the item bits that may be used for upload. This decouples the source of the items and expectation to exist as a file on local fs
1 parent 202cb34 commit 20b0e62

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

requirements.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ pubtools>=0.3.0
22
pubtools-pulplib>=2.36.0
33
more_executors>=2.7.0
44
pushcollector>=1.2.0
5-
pushsource>=2.45.0
5+
pushsource>=2.51.0
66
monotonic; python_version < '3.3'

src/pubtools/_pulp/tasks/push/items/comps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class PulpCompsXmlPushItem(PulpDirectUploadPushItem):
1111
"""Handler for comps.xml files which are uploaded directly to each dest repo."""
1212

1313
def upload_to_repo(self, repo):
14-
return repo.upload_comps_xml(self.pushsource_item.src)
14+
return repo.upload_comps_xml(self.pushsource_item.content())

src/pubtools/_pulp/tasks/push/items/file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def upload_key(self):
7272

7373
def upload_to_repo(self, repo):
7474
return repo.upload_file(
75-
self.pushsource_item.src,
75+
self.pushsource_item.content(),
7676
relative_url=self.pushsource_item.name,
7777
description=self.pushsource_item.description,
7878
version=self.pushsource_item.version,

src/pubtools/_pulp/tasks/push/items/modulemd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class PulpModuleMdPushItem(PulpDirectUploadPushItem):
1111
"""Handler for modulemd YAML files which are uploaded directly to each dest repo."""
1212

1313
def upload_to_repo(self, repo):
14-
return repo.upload_modules(self.pushsource_item.src)
14+
return repo.upload_modules(self.pushsource_item.content())

src/pubtools/_pulp/tasks/push/items/productid.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def _product_versions_from_cert(self):
8484
return []
8585

8686
def upload_to_repo(self, repo):
87-
return repo.upload_metadata(self.pushsource_item.src, metadata_type="productid")
87+
return repo.upload_metadata(
88+
self.pushsource_item.content(), metadata_type="productid"
89+
)
8890

8991
def ensure_uploaded(self, ctx, repo_f=None):
9092
# Overridden to add the post-upload step of product_versions update.

src/pubtools/_pulp/tasks/push/items/rpm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ def ensure_uploaded(self, ctx, repo_f=None):
143143
return super(PulpRpmPushItem, self).ensure_uploaded(ctx, ctx.upload_repo)
144144

145145
def upload_to_repo(self, repo):
146-
return repo.upload_rpm(self.pushsource_item.src, cdn_path=self.cdn_path)
146+
return repo.upload_rpm(self.pushsource_item.content(), cdn_path=self.cdn_path)

tests/push/test_upload_sharing.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ def __init__(self, delegate, uploads):
1919
self.delegate = delegate
2020
self.uploads = uploads
2121

22-
def upload_rpm(self, path, *args, **kwargs):
23-
self.uploads.append(("rpm", path))
24-
return self.delegate.upload_rpm(path, *args, **kwargs)
22+
def upload_rpm(self, rpm, *args, **kwargs):
23+
# get the path/name if it's the file object as rpm
24+
# instead of rpm path
25+
rpm = rpm if isinstance(rpm, str) else rpm.name
26+
self.uploads.append(("rpm", rpm))
27+
return self.delegate.upload_rpm(rpm, *args, **kwargs)
2528

2629

2730
class ClientWrapper(object):

0 commit comments

Comments
 (0)