Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't upload RPM packages to Pulp as artifacts #3391

Merged
merged 1 commit into from
Sep 2, 2024
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
21 changes: 5 additions & 16 deletions backend/copr_backend/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,28 +151,17 @@ def update_distribution(self, distribution, publication):
}
return requests.patch(url, json=data, **self.request_params)

def create_content(self, repository, artifact, relative_path):
def create_content(self, repository, path):
"""
Create content for a given artifact
https://docs.pulpproject.org/pulp_rpm/restapi.html#tag/Content:-Packages/operation/content_rpm_packages_create
"""
url = self.url("api/v3/content/rpm/packages/")
data = {
"repository": repository,
"artifact": artifact,
"relative_path": relative_path,
}
return requests.post(url, json=data, **self.request_params)

def upload_artifact(self, path):
"""
Create an artifact
https://docs.pulpproject.org/pulpcore/restapi.html#tag/Artifacts/operation/artifacts_create
"""
with open(path, "rb") as fp:
url = self.url("api/v3/artifacts/")
data = {"file": fp}
return requests.post(url, files=data, **self.request_params)
data = {"repository": repository}
files = {"file": fp}
return requests.post(
url, data=data, files=files, **self.request_params)

def delete_repository(self, repository):
"""
Expand Down
12 changes: 1 addition & 11 deletions backend/copr_backend/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,8 @@ def upload_build_results(self, chroot, results_dir, target_dir_name):
continue

path = os.path.join(root, name)
response = self.client.upload_artifact(path)
if not response.ok:
self.log.error("Failed to upload %s to Pulp", path)
continue

artifact = response.json()["pulp_href"]
relative_path = os.path.join(
self.owner, self.project, target_dir_name)

repository = self._get_repository(chroot)
response = self.client.create_content(
repository, artifact, relative_path)
response = self.client.create_content(repository, path)

if not response.ok:
self.log.error("Failed to create Pulp content for: %s, %s",
Expand Down