Add namespaces support (CRUD, RBAC, namespace-scoped users)#169
Add namespaces support (CRUD, RBAC, namespace-scoped users)#169
Conversation
Adds end-to-end CLI surface for the Weaviate namespaces feature (server >= 1.38.0, python-client jose/namespaces branch): - create/get/delete namespace subcommands backed by NamespaceManager - manage_namespaces:<name>[,<name>...] permission parsing, with the bare wildcard form rejected so every grant names an explicit namespace - --namespace flag on create user; create user JSON/text and get user output surface the namespace; create_user only forwards the kwarg when set so the CLI keeps working against non-namespaced clusters - get role text/JSON now renders namespaces_permissions - requirements-dev.txt temporarily points at the python-client jose/namespaces branch until that release ships Closes #168 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end CLI support for Weaviate “namespaces” (CRUD commands, RBAC permission parsing/rendering, and namespace-scoped DB user creation/output), plus accompanying unit tests and docs updates.
Changes:
- Introduces
NamespaceManagerand new CLI commands:create/get/delete namespace(with--jsonsupport). - Extends RBAC permission parsing/output to support
manage_namespaces:<name>[,<name>...]and rendersnamespaces_permissionsin role output. - Adds optional
--namespacetocreate userand surfaces the namespace inget useroutputs (text + JSON), with unit tests.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| weaviate_cli/utils.py | Adds manage_namespaces permission parsing + _create_permission support for namespaces. |
| weaviate_cli/managers/user_manager.py | Adds namespace forwarding on user creation; prints namespace in user outputs. |
| weaviate_cli/managers/role_manager.py | Renders namespaces_permissions in role JSON/text output. |
| weaviate_cli/managers/namespace_manager.py | New manager implementing namespace CRUD and printing. |
| weaviate_cli/defaults.py | Adds defaults dataclasses for namespace commands and create-user namespace default. |
| weaviate_cli/commands/get.py | Adds get namespace subcommand; includes namespace in get user --all JSON. |
| weaviate_cli/commands/delete.py | Adds delete namespace subcommand. |
| weaviate_cli/commands/create.py | Adds create namespace subcommand; adds --namespace to create user. |
| test/unittests/test_utils.py | Adds unit tests for manage_namespaces parsing + wildcard rejection. |
| test/unittests/test_managers/test_user_manager.py | Adds tests for namespace kwarg forwarding and namespace rendering. |
| test/unittests/test_managers/test_namespace_manager.py | New unit tests for NamespaceManager CRUD + output modes. |
| requirements-dev.txt | Temporarily pins weaviate-client to a Git branch for namespaces support. |
| .claude/skills/operating-weaviate-cli/SKILL.md | Documents namespace commands, namespace-scoped users, and RBAC permission usage. |
| .claude/skills/operating-weaviate-cli/references/rbac.md | Documents manage_namespaces permission. |
| .claude/skills/operating-weaviate-cli/references/namespaces.md | New reference page for namespaces feature. |
| .claude/skills/contributing-to-weaviate-cli/SKILL.md | Updates contributor docs to include namespace commands/manager module. |
| .claude/skills/contributing-to-weaviate-cli/references/architecture.md | Adds namespace_manager.py to the manager list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Reject empty namespace names in manage_namespaces permission parsing (manage_namespaces: or ns1,,ns2) - Add unit tests for empty namespace name edge cases - Fix namespace naming rule docs: underscores are not allowed per RFC ([a-z][a-z0-9]*) - Update all doc examples to use valid namespace names (tenantswest, tenantseast, tenantssouth) - Pin weaviate-client to git branch in setup.cfg so CI installs namespace-enabled client Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot review |
Agent-Logs-Url: https://github.com/weaviate/weaviate-cli/sessions/885f6e27-f122-407c-8e0b-e5228dacd9fc Co-authored-by: jfrancoa <23482278+jfrancoa@users.noreply.github.com>
Agent-Logs-Url: https://github.com/weaviate/weaviate-cli/sessions/885f6e27-f122-407c-8e0b-e5228dacd9fc Co-authored-by: jfrancoa <23482278+jfrancoa@users.noreply.github.com>
Addressed the two remaining unresolved review comments in commits
All 324 unit tests pass and lint is clean. |
Summary
End-to-end CLI surface for the Weaviate namespaces feature (server >= 1.38.0, paired with weaviate-python-client PR #2033 / branch
jose/namespaces):create namespace --name <ns>,get namespace --name <ns> | --all,delete namespace --name <ns>. All commands support--json. Backed by a newNamespaceManager.manage_namespaces:<name>[,<name>...]parses throughparse_permission→Permissions.namespaces(...). The baremanage_namespaceswildcard is rejected so every grant names an explicit namespace.get role(text and JSON) now rendersnamespaces_permissions.create user --user_name <u> --namespace <ns>forwards the newnamespacekwarg.UserManager.create_useronly sends the kwarg when set, so the CLI keeps working against non-namespaced clusters and older clients.get usertext and JSON output (single user and--all) surface the namespace when present.operating-weaviate-cligains a Namespaces section +references/namespaces.md;references/rbac.mddocumentsmanage_namespaces.contributing-to-weaviate-clilists the newnamespace_manager.pymodule.Tests
test/unittests/test_managers/test_namespace_manager.py(15 tests) — happy paths, errors, JSON output, missing-name validation.parse_permissioncases for single namespace, multi-namespace, and wildcard rejection intest_utils.py.create_usertests covering namespace forwarding (and the absence of the kwarg when not provided), plusprint_db_usernamespace rendering tests.make test→ 323 passed (was 308).make lintpasses.Note on requirements-dev.txt
weaviate-clientis temporarily pinned to thejose/namespacesbranch of the python client so the newweaviate.namespacesmodule resolves and CI can run. Revert to a normal version pin (weaviate-client>=4.21.xor whatever ships) once weaviate-python-client #2033 merges and a release is cut.Test plan
make lintpassesmake testpassesweaviate-cli create namespace --name demo_ns --jsonagainst a Weaviate 1.38.0+ clusterweaviate-cli create user --user_name u1 --namespace demo_ns --jsonweaviate-cli create role --role_name r1 -p manage_namespaces:demo_ns --jsonandweaviate-cli get role --role_name r1 --jsonCloses #168
🤖 Generated with Claude Code