feat: discover contexts on login, select with ctx use#149
Merged
Conversation
Collaborator
|
this looks good to me, do you want to get it out of draft so we can move it over and merge? |
459d18b to
7241d91
Compare
073453d to
692ba86
Compare
Replace the per-command --project/--organization flow with a context
system. `datumctl login` now authenticates and picks a default org or
project in one step, and subsequent commands use it automatically.
New top-level commands:
- datumctl login / logout / whoami
- datumctl ctx (list, use, --refresh)
Auth group:
- auth list and auth switch are session-aware; switching users
restores each session's last-used context
- auth login and auth logout removed; use the top-level commands
login supports all previous auth modes: PKCE, device flow
(--no-browser) for headless environments, and machine accounts
(--credentials FILE).
Config moves to a v1beta1 format with session-keyed credentials.
Pre-existing keyring entries are bootstrapped on first run so
previously-authenticated users don't have to log in again. Env vars
(DATUM_PROJECT / DATUM_ORGANIZATION) and the --project /
--organization flags continue to override the active context
per-invocation for scripts and CI.
The kubectl exec plugin args now reference session names, so existing
kubeconfigs produced by 'datumctl auth update-kubeconfig' need to be
regenerated.
9f060e2 to
8a3a899
Compare
5 tasks
Distinguish org vs project contexts in the post-login and ctx-use confirmation by adding a ContextDescription helper that produces "org <name> (<id>)" or "project <name> in <org> (<ref>)" output. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Only print the auth URL and --no-browser hint when the browser fails to open, keeping the happy-path output clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gianarb
approved these changes
Apr 16, 2026
Collaborator
gianarb
left a comment
There was a problem hiding this comment.
Pretty nice!! It works with the various tests I made and ctx --refresh migrates my configuration as well 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Logging in and picking a project should be one step, and datumctl should remember your choice so you don't have to repeat it on every command. This PR makes that the default. Switching to a different project — or to another account — takes one command, and drops you right where you left off.
First run: log in and pick a context
datumctl loginhandles authentication and context selection in one step. A browser opens, then the CLI fetches your orgs and projects and shows a picker:If you only have one project, the picker is skipped. From there, resource commands (
get,apply,create, etc.) automatically use the active context —datumctl get dnszonesjust works, no--projector--organizationflags required. To list, inspect, or change your active context:Switching accounts without losing your place
Each login session remembers its last-used context, so switching users drops you right back where you left off:
Scripts, CI, and machine accounts
For non-interactive use, environment variables override the active context per-invocation:
--projectand--organizationflags still work too. For machine-to-machine auth:Tip
Run
datumctl --helpfor the full command list.Upgrading from earlier versions
datumctl auth loginanddatumctl auth logouthave been removed — usedatumctl loginanddatumctl logoutinstead.datumctl loginsupports all the same auth modes (PKCE,--no-browserfor device flow,--credentialsfor machine accounts).Pre-existing keyring credentials are bootstrapped into a v1beta1 session on first run, so previously authenticated users won't have to log in again. They will, however, want to run
datumctl ctx use(or rely onDATUM_PROJECT/DATUM_ORGANIZATION) to pick a context.Anyone with a kubeconfig generated by an earlier
datumctl auth update-kubeconfigwill need to re-run the command — the kubectl exec plugin args now reference session names rather than the legacy format.🤖 Generated with Claude Code