Skip to content

feat(cli): configure single-tenant servers from the register response - #129

Merged
geekgonecrazy merged 1 commit into
devfrom
feat/single-tenant-cli
Jul 28, 2026
Merged

geekgonecrazy merged 1 commit into
devfrom
feat/single-tenant-cli

Conversation

@geekgonecrazy

@geekgonecrazy geekgonecrazy commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

What

Companion to atomicdotdev/atomic-storage#78 (single-tenant mode). Registration
responses now carry mode/role; when mode == "single" the CLI configures
itself correctly from the response alone — no manual URL/org fixups.

  • ServerConfig.single_tenant (serde-default false, skipped when false).
    Existing configs and pre-mode servers keep multi-tenant semantics — no
    migration, no config churn.
  • org_base_url() returns the bare host unchanged for single-tenant
    servers. They're already tenant-scoped server-side, so the {org}. prefix
    would produce bogus hosts like org.org.example.com.
  • identity register writes a correct profile straight from the response:
    typed URL kept verbatim, default_org from the response slug, identity
    bound, single_tenant set — including the default-identity (legacy
    [server]) path.

Usage

Register with a single-tenant server

atomic identity new alice --email alice@customer.com --set-default
atomic identity register https://storage.customer.com --identity alice --server-name customer

The server responds mode: "single", and the CLI writes a ready-to-use
profile (URLs are used as-is, no {org}. prefix):

[servers.customer]
url = "https://storage.customer.com"
default_org = "customer"     # from the response slug
identity = "alice"
single_tenant = true
default_server = "customer"  # activated automatically when it's your first server

Tip: pass --server-name — the auto-derived name is the first host label
(storage.customer.com → storage), which is rarely what you want.

Already on multi-tenant atomic.storage, adding a single-tenant server

Existing multi-tenant setup is left untouched. Registering a single-tenant
server adds a profile but does not silently switch your active server:

atomic identity register https://storage.customer.com --identity alice-customer --server-name customer
#   Profile:   'customer' added (activate with: atomic server set customer)
[server]                       # unchanged — still multi-tenant
url = "https://atomic.storage"
default_org = "alice"

[servers.customer]             # new — single-tenant
url = "https://storage.customer.com"
default_org = "customer"
identity = "alice-customer"
single_tenant = true

Switch between them:

atomic server list             # shows both; marks the active one
atomic server set customer     # activate the single-tenant server
atomic server unset            # revert to the legacy [server] (atomic.storage)
atomic <cmd> --server customer # or target per-command without switching

Backwards compatibility

Multi-tenant is the default on both axes, so nothing changes for existing users:

  • Config: single_tenant deserializes to false for configs written
    before the field existed; it's omitted from output when false. No migration.
  • Server: a missing mode field (older servers) is treated as multi-tenant,
    preserving org-prefixed URLs.

Test plan

  • atomic-config: org_base_url single-tenant (no prefix, trailing slash
    stripped); legacy TOML deserialization defaults to multi.
  • atomic-cli: tenancy parsing for single / multi / missing-field responses.
  • Full suites green, clippy -D warnings, fmt.

Verified end-to-end against a live single-tenant deployment on GKE (push/pull as
owner; member joins with zero implicit access).

Registration responses now carry mode/role (atomic-storage SERVER_TENANT_SLUG
servers). When mode == "single":

- ServerConfig gains single_tenant (serde-default false, so existing configs
  and pre-mode servers keep multi-tenant semantics with no migration).
- org_base_url() returns the bare host unchanged — single-tenant servers are
  already tenant-scoped server-side, so the {org}. prefix would produce
  bogus hosts (org.org.atomic.storage).
- identity register writes a correct profile from the response: typed URL
  kept verbatim, default_org from the response slug, identity bound,
  single_tenant set — registration against a single-tenant server now just
  works, including the default-identity path (legacy [server] block).

Tests: org_base_url single-tenant (no prefix, trailing slash), legacy TOML
deserialization defaults to multi, register tenancy parsing for
single/multi/missing-field responses. Full atomic-cli + atomic-config
suites, clippy -D warnings, and fmt are green.
@geekgonecrazy
geekgonecrazy force-pushed the feat/single-tenant-cli branch from d8f9963 to 233c95d Compare July 28, 2026 19:45
@geekgonecrazy
geekgonecrazy merged commit 1476f20 into dev Jul 28, 2026
8 checks passed
@geekgonecrazy
geekgonecrazy deleted the feat/single-tenant-cli branch July 28, 2026 20:05
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.

1 participant