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

[redhat|policy] Provide a URL message for S3 bucket based uploads #3891

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions sos/policies/distros/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ def get_upload_url(self):
return self.commons['cmdlineopts'].upload_url
if self.commons['cmdlineopts'].upload_protocol == 'sftp':
return RH_SFTP_HOST
if self.commons['cmdlineopts'].upload_protocol == 's3':
endpoint = self.get_upload_s3_endpoint()
bucket = self.get_upload_s3_bucket()
if self.commons['cmdlineopts'].case_id:
rh_case_api = "/support/v1/cases/%s/attachments"
return f"{endpoint}/{bucket}" + rh_case_api % self.case_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this all f-string formatting, mixing the two syntax is a little awkward.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll adjust this accordingly once I have additional feedback to #3891 (comment)

prefix = self.get_upload_s3_object_prefix()
return f"{endpoint}/{bucket}/{prefix}"
if not self.commons['cmdlineopts'].case_id:
self.ui_log.info("No case id provided, uploading to SFTP")
return RH_SFTP_HOST
Expand Down
Loading