Skip to content

Commit

Permalink
feat: convert openBIS cloud storage configurations into valid rclone …
Browse files Browse the repository at this point in the history
…configurations before starting a session
  • Loading branch information
olloz26 committed Dec 4, 2024
1 parent 03262ec commit 6ff60e2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions renku_notebooks/api/schemas/cloud_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,16 @@ def config_string(self, name: str) -> str:
"""
if not self.configuration:
raise ValidationError("Missing configuration for cloud storage")
if self.configuration["type"] == "s3" and self.configuration.get("provider", None) == "Switch":
real_config = dict(self.configuration)
if real_config["type"] == "s3" and real_config.get("provider") == "Switch":
# Switch is a fake provider we add for users, we need to replace it since rclone itself
# doesn't know it
self.configuration["provider"] = "Other"
real_config["provider"] = "Other"
elif real_config["type"] == "openbis":
real_config["type"] = "sftp"
real_config["port"] = "2222"
real_config["user"] = "?"
real_config["pass"] = real_config.pop("session_token")
parser = ConfigParser()
parser.add_section(name)

Expand All @@ -171,7 +177,7 @@ def _stringify(value):
return "true" if value else "false"
return str(value)

for k, v in self.configuration.items():
for k, v in real_config.items():
parser.set(name, k, _stringify(v))
stringio = StringIO()
parser.write(stringio)
Expand Down

0 comments on commit 6ff60e2

Please sign in to comment.