feat(nativedb): add native database cli support - #519
Conversation
|
🤖 Pull Request Artifacts (#25847513829) 🎉 |
There was a problem hiding this comment.
Pull request overview
Adds native database management support to the rio CLI by introducing a new rio database command group and registering Database as an rio apply-supported kind (backed by new SDK v2 database APIs).
Changes:
- Introduces
rio databasesubcommands for listing, inspecting, deleting databases, listing engine versions, and managing backups (list/inspect/delete/restore). - Registers
Databaseinrio applyand adds a sampledatabase.yamlmanifest template. - Switches
rapyuta-io-sdk-v2dependency to a Git branch providing native DB client support.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Locks rapyuta-io-sdk-v2 to a Git source for DB API support. |
| pyproject.toml | Updates dependency spec to use the Git-based rapyuta-io-sdk-v2. |
| riocli/model/base.py | Improves missing-name validation error message. |
| riocli/database/init.py | Adds database Click group and wires subcommands. |
| riocli/database/list.py | Implements rio database list (--wide). |
| riocli/database/inspect.py | Implements rio database inspect (YAML/JSON). |
| riocli/database/delete.py | Implements rio database delete (pattern/all, parallel workers). |
| riocli/database/versions.py | Implements rio database versions. |
| riocli/database/backup.py | Implements rio database backup subcommands. |
| riocli/database/util.py | Adds helpers for selecting/printing databases for confirmation. |
| riocli/database/model.py | Adds Database apply model for create/delete. |
| riocli/bootstrap.py | Registers database group at the top-level CLI. |
| riocli/apply/util.py | Registers Database in KIND_TO_CLASS for apply. |
| riocli/apply/manifests/database.yaml | Adds sample Database manifest template. |
| cli.add_command(role) | ||
| cli.add_command(service_account) | ||
| cli.add_command(permission) | ||
| cli.add_command(database) |
There was a problem hiding this comment.
New rio database command group is added to the root CLI, but there are no corresponding tests under tests/ (no database mentions in tests/main), while other command groups have integration/RBAC coverage. Add at least basic CLI tests (list/inspect/delete/backup/versions) and apply-kind coverage for Database to prevent regressions.
|
|
||
| @override | ||
| def list_dependencies(self) -> list[str] | None: | ||
| return None |
There was a problem hiding this comment.
Database.list_dependencies() always returns None, so rio apply can't order Database creation after the referenced primary/standby devices. Given the manifest schema references spec.postgres.primary.deviceName (and possibly standby devices), this can cause apply to attempt database creation before its device resources exist. Consider returning a dependency list (e.g., device:<name>) derived from the referenced deviceName fields (or delegating to the SDK model’s list_dependencies() if available).
| return None | |
| sdk_list_dependencies = getattr(self._obj, "list_dependencies", None) | |
| if callable(sdk_list_dependencies): | |
| sdk_dependencies = sdk_list_dependencies() | |
| if sdk_dependencies: | |
| return sdk_dependencies | |
| def _get_value(obj, key): | |
| if obj is None: | |
| return None | |
| if isinstance(obj, dict): | |
| return obj.get(key) | |
| return getattr(obj, key, None) | |
| def _append_device_dependency(dependencies: list[str], device_ref) -> None: | |
| device_name = _get_value(device_ref, "deviceName") | |
| if device_name: | |
| dependency = f"device:{device_name}" | |
| if dependency not in dependencies: | |
| dependencies.append(dependency) | |
| dependencies: list[str] = [] | |
| spec = _get_value(self, "spec") | |
| postgres = _get_value(spec, "postgres") | |
| _append_device_dependency(dependencies, _get_value(postgres, "primary")) | |
| standby = _get_value(postgres, "standby") | |
| if isinstance(standby, list): | |
| for standby_device in standby: | |
| _append_device_dependency(dependencies, standby_device) | |
| else: | |
| _append_device_dependency(dependencies, standby) | |
| standbys = _get_value(postgres, "standbys") | |
| if isinstance(standbys, list): | |
| for standby_device in standbys: | |
| _append_device_dependency(dependencies, standby_device) | |
| else: | |
| _append_device_dependency(dependencies, standbys) | |
| return dependencies or None |
34ea9f4 to
3afbbc3
Compare
Adds
rio databasecommand group for managing database resources on the platform.New Commands
rio database list— list all databases in the project (supports--wide)rio database inspect— inspect a database resource in YAML/JSONrio database delete— delete one or more databases by name or regex pattern (supports--all, parallel workers)rio database versions— list supported database engine versionsrio database backup list/inspect/delete/restore— manage database backupsApply Support
Databaseas a supported kind inrio applyriocli/apply/manifests/database.yamlas a sample manifest template