Skip to content

Commit 2bf862c

Browse files
committed
Don't check required rclone options with default values
1 parent e524457 commit 2bf862c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

components/renku_data_services/storage/rclone.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ def validate_config(
304304
and self.exclusive
305305
and not any(e.value == str(value) and (not e.provider or e.provider == provider) for e in self.examples)
306306
):
307-
raise errors.ValidationError(message=f"Value '{value}' is not valid for field {self.name}")
307+
valid_values = ", ".join([v.value for v in self.examples])
308+
raise errors.ValidationError(
309+
message=f"Value '{value}' is not valid for field {self.name}. Valid values are: {valid_values}"
310+
)
308311
return cast(int | bool | dict | str, value)
309312

310313

@@ -323,7 +326,7 @@ class RCloneProviderSchema(BaseModel):
323326
@property
324327
def required_options(self) -> list[RCloneOption]:
325328
"""Returns all required options for this provider."""
326-
return [o for o in self.options if o.required]
329+
return [o for o in self.options if o.required and not o.default]
327330

328331
@property
329332
def sensitive_options(self) -> list[RCloneOption]:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Tests for the rclone module."""
2+
3+
from renku_data_services.storage.rclone import RCloneValidator
4+
5+
6+
def test_validate_switch_s3_no_endpoint() -> None:
7+
"""Endpoint has a default value and is not required to specify."""
8+
validator = RCloneValidator()
9+
cfg = {"provider": "Switch", "type": "s3"}
10+
validator.validate(cfg, keep_sensitive=True)

0 commit comments

Comments
 (0)