Skip to content

cli: add default tenant to config#2904

Merged
elitegreg merged 4 commits intomainfrom
gm/tenant_config
Feb 10, 2026
Merged

cli: add default tenant to config#2904
elitegreg merged 4 commits intomainfrom
gm/tenant_config

Conversation

@elitegreg
Copy link
Copy Markdown
Contributor

Summary of Changes

  • Adds the ability to set a default tenant in config
  • doublezero config set --tenant XXX
  • doublezero config set --no-tenant

Testing Verification

  • new unit tests

@elitegreg elitegreg requested a review from Copilot February 10, 2026 19:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for storing a “default tenant” in CLI config and using it as the implicit tenant filter unless explicitly overridden.

Changes:

  • Add tenant to persisted ClientConfig and expose it via config get/set.
  • Add --tenant / --no-tenant behavior to user listing (and default to config tenant when unspecified).
  • Use config tenant as a fallback during provisioning/connect flow.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
smartcontract/sdk/rs/src/config.rs Add tenant to config model and adjust config path resolution behavior.
smartcontract/cli/src/user/list.rs Add --no-tenant and default tenant-from-config filtering logic + test.
smartcontract/cli/src/config/set.rs Allow setting/clearing default tenant and display it in output + tests.
smartcontract/cli/src/config/get.rs Display configured default tenant in config get output.
client/doublezero/src/command/connect.rs Fall back to config tenant when CLI tenant isn’t provided.
CHANGELOG.md Document default tenant support addition.
Comments suppressed due to low confidence (2)

smartcontract/cli/src/config/set.rs:1

  • unwrap_or(...) here consumes config.websocket_url, config.program_id, and config.tenant (moves them out of config). It works today because config isn’t used afterwards, but it’s brittle and makes future edits error-prone. Prefer formatting without moving fields (e.g., as_deref()/as_ref() + unwrap_or(...), or clone().unwrap_or_else(...)), and use unwrap_or_else/as_deref to avoid allocating \"(not set)\" each time.
use crate::doublezerocommand::CliCommand;

smartcontract/cli/src/config/get.rs:1

  • Same issue as config set: formatting via unwrap_or(...) moves values out of config and allocates a new String for \"(not set)\". Prefer as_deref()/as_ref() + unwrap_or(...) (or unwrap_or_else) to keep config intact and avoid unnecessary allocations.
use crate::doublezerocommand::CliCommand;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread smartcontract/cli/src/user/list.rs Outdated
Comment thread smartcontract/cli/src/user/list.rs
Comment thread smartcontract/sdk/rs/src/config.rs
@elitegreg elitegreg marked this pull request as ready for review February 10, 2026 20:07
@elitegreg elitegreg enabled auto-merge (squash) February 10, 2026 20:09
@elitegreg elitegreg requested a review from vihu February 10, 2026 20:17
Add a persistent `tenant` field to the CLI config so users don't need to
specify --tenant on every command. The config tenant is used as a fallback
when no tenant is provided via CLI args in `connect` and `user list`.
@elitegreg elitegreg merged commit 397cc65 into main Feb 10, 2026
29 checks passed
@elitegreg elitegreg deleted the gm/tenant_config branch February 10, 2026 20:50
ben-dz pushed a commit that referenced this pull request Feb 10, 2026
## Summary of Changes
* Adds the ability to set a default tenant in config
* `doublezero config set --tenant XXX`
* `doublezero config set --no-tenant`

## Testing Verification
* new unit tests

---------

Co-authored-by: Juan Olveira <juan@malbeclabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants