Conversation
This commit contains the foundation of being able to connect to multiple Datum clusters and to switch in between projects and orgs via contexts.
5d0143a to
b7a94b1
Compare
|
Thanks for putting this together. After reviewing, I want to propose a shift in how contexts get created. Right now the path to having a working context is: login, then That's a lot of manual setup before someone can be productive — especially since the orgs and projects already exist on the platform. What if contexts were automatically discovered from the API instead of manually authored? What I think the experience should feel likeFirst login — you're productive immediately: $ datumctl login
Opening browser for authentication...
✓ Authenticated as Jane Doe (jane@acme.com)
You have access to 2 organizations:
acme-corp (3 projects)
personal (1 project)
? Select a context to work in:
acme-corp (org)
acme-corp/web-app (project)
acme-corp/billing-api (project)
> acme-corp/infra (project)
personal (org)
personal/sandbox (project)
✓ Context set to acme-corp/infraOne command. Auth and context selection happen together. If the user only has one project, skip the picker and auto-select. Day-to-day — no flags needed: $ datumctl get dnszones
NAME ZONE AGE
marketing marketing.acme 5d
api api.acme.dev 12d
$ datumctl create -f manifest.yaml
dnszone.networking/staging created
$ datumctl mcp
Starting MCP server for acme-corp/infra...Everything runs against the active context. Checking where you are: $ datumctl whoami
User: Jane Doe (jane@acme.com)
Context: acme-corp/infra
Organization: acme-corp
Project: infra (proj-9e4d...)Seeing who you're logged in as: $ datumctl auth list
USER STATUS
jane@acme.com Active
bob@acme.comIf you have logins across multiple endpoints, the endpoint column appears: $ datumctl auth list
USER ENDPOINT STATUS
jane@acme.com api.datum.net Active
jane@acme.com api.staging.datum.net
bob@acme.com api.datum.netSame for $ datumctl whoami
User: Jane Doe (jane@acme.com)
Endpoint: api.datum.net
Context: acme-corp/infra
Organization: acme-corp
Project: infra (proj-9e4d...)Seeing what's available and switching: $ datumctl ctx
ORGANIZATION PROJECT TYPE CURRENT
acme-corp org
acme-corp infra project *
acme-corp web-app project
acme-corp billing-api project
personal org
personal sandbox projectSwitch to a project: $ datumctl ctx use acme-corp/web-app
✓ Switched to acme-corp/web-app (project)Switch to an org: $ datumctl ctx use acme-corp
✓ Switched to acme-corp (org)
$ datumctl get projects
NAME ID AGE
infra proj-9e4d 30d
web-app proj-7f3a 25d
billing-api proj-2b1c 10dOr with an interactive picker when you don't pass an argument: $ datumctl ctx use
? Select a context:
acme-corp (org)
acme-corp/web-app (project, current)
> acme-corp/infra (project)
acme-corp/billing-api (project)
personal (org)
personal/sandbox (project)Overrides for scripts and CI: $ datumctl get dnszones --project proj-other
$ DATUM_PROJECT=proj-other datumctl get dnszonesActive context stays the same — the override is per-invocation only. (The env vars would be new — not implemented yet — but would give CI and scripting a clean override without mutating config.) Working at the org level: Sometimes you want to work at the org scope rather than inside a specific project — listing projects, managing org-wide settings, etc. $ datumctl ctx use acme-corp
✓ Switched to acme-corp (org)
$ datumctl get projects
NAME ID AGE
infra proj-9e4d 30d
web-app proj-7f3a 25d
billing-api proj-2b1c 10dSwitching between accounts: Each login session remembers its endpoint and last selected context. Switching users puts you right back where that user left off. $ datumctl auth switch jane@acme.com
✓ Switched to Jane Doe (jane@acme.com)
Context: acme-corp/infraIf the same email exists on multiple endpoints, the CLI prompts to disambiguate: $ datumctl auth switch jane@acme.com
? Which login session?
> jane@acme.com (api.datum.net)
jane@acme.com (api.staging.datum.net)Multiple deployments (staging, self-hosted): Most users just talk to production and never think about this. Each login is bound to a specific endpoint — $ datumctl login --endpoint https://api.staging.datum.net
Opening browser for authentication...
✓ Authenticated as Jane Doe (jane@acme.com) on api.staging.datum.net
✓ Context set to acme-corp/infraTo get back to production, just switch users: $ datumctl auth switch jane@acme.com
✓ Switched to Jane Doe (jane@acme.com)
Endpoint: api.datum.net
Context: acme-corp/infraHow I think about the command surface
All resource commands inherit the active context. Context resolution order
This user-experience should make it easier for users to immediately start interacting with their projects and organizations in datum cloud. |
|
Hello @scotwells ! wow there is a lot to unwrap here! I need to admit I already feel a bit confused about when I need to The Context struct is the core of the new config layer. It binds together three things:
This idea of mutually exclusive is because currently we need to specify if we want to work at org spec or project spec as you said. But this keeps a pretty flat structure you have context, and just need to remember the name for them, you do not need to think about "I am in Contexts are stored by name in the config file (~/.datumctl/config) and one is marked as current-context. The full resolution chain is: onboardingThe current code translates what you have in your keychain as context, so the onboarding is transparent for current users. I am not sure if you want to keep that or just discard and force re-login. For new users or to creae new context the interactivity you suggested can be the default solution for sure. this helps humans no agents 😄 conclusionLet me know what you think, as I said the UX on top or the interactive part can be a second step compared to how we want actually model the underline layer on disk. If you can help me understand a bit more what you have in mind there I will start from there. |
|
Your proposal with a double switch with context and use for org sounds a bit confusing but I will keep looking at it for a bit more |
This commit contains the foundation of being able to connect to multiple
Datum clusters and to switch in between projects and orgs via contexts.
This PR at the time you run this new version of the datumctl will create the
configuration file without breaking compatibility with your current authorized
login.
Every time you run login it will check if it knows the server you are connecting
to, if not it will add it to the list and create a context for you to use.
commands
A couple of new commands related to context and clusters are available under
configsubcommand.Now that authenticated user are related to context I don't think we need the
auth listand even less theauth switchin order to avoid confusions so I removed themLimitation:
Currently, we do not have a way to discriminate when to reach the organization
control plane or the project one. It means that we can not accept project AND
org into the same context, only one can be set. Right now we prioritize project
because most like it is the one you want to use for the most.
User who wants to quickly switch in between org and project needs to create
multiple context.
Fixes datum-cloud/enhancements#653