Skip to content

Commit

Permalink
fix: add vendor for polybox storage
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Jan 15, 2025
1 parent fce24d6 commit e684d3f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/renku_data_services/storage/rclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def __add_webdav_based_storage(
description: str,
url_value: str,
public_link_help: str,
vendor: str | None = None,
) -> None:
"""Create a modified copy of WebDAV storage and add it to the schema."""
# Find WebDAV storage schema and create a modified copy
Expand Down Expand Up @@ -238,17 +239,21 @@ def __add_webdav_based_storage(
]
storage_copy["Options"].extend(custom_options)

# use provider to indicate if the option is for an personal o shared storage
# use provider to indicate if the option is for a personal or shared storage
for option in storage_copy["Options"]:
if option["Name"] == "url":
option.update({"Provider": "personal", "Default": url_value, "Required": False})
elif option["Name"] in ["bearer_token", "bearer_token_command", "headers", "user"]:
option["Provider"] = "personal"

# NOTE: if the vendor field is omitted it can result in the modified timestamps for mounted files
# being weird and causing text editors to keep asking if you want to overwrite the file when
# trying to write any changes.
if option["Name"] == "vendor" and vendor:
option["Default"] = vendor

# Remove obsolete options no longer applicable for Polybox or SwitchDrive
storage_copy["Options"] = [
o for o in storage_copy["Options"] if o["Name"] not in ["vendor", "nextcloud_chunk_size"]
]
storage_copy["Options"] = [o for o in storage_copy["Options"] if o["Name"] not in ["nextcloud_chunk_size"]]

spec.append(storage_copy)

Expand All @@ -271,6 +276,7 @@ def apply_patches(self, spec: list[dict[str, Any]]) -> None:
description="Polybox",
url_value="https://polybox.ethz.ch/remote.php/webdav/",
public_link_help="Shared folder link. E.g., https://polybox.ethz.ch/index.php/s/8NffJ3rFyHaVyyy",
vendor="owncloud",
)

self.__add_webdav_based_storage(
Expand All @@ -280,6 +286,7 @@ def apply_patches(self, spec: list[dict[str, Any]]) -> None:
description="SwitchDrive",
url_value="https://drive.switch.ch/remote.php/webdav/",
public_link_help="Shared folder link. E.g., https://drive.switch.ch/index.php/s/OPSd72zrs5JG666",
vendor="owncloud",
)

def validate(self, configuration: Union["RCloneConfig", dict[str, Any]], keep_sensitive: bool = False) -> None:
Expand Down

0 comments on commit e684d3f

Please sign in to comment.