Repository navigation
feat: config, contexts, name resolution, proxy and CA bundle - #14
Open
RogerCecilpot wants to merge 2 commits into
Open
RogerCecilpot wants to merge 2 commits into
RogerCecilpot wants to merge 2 commits into
Conversation
- config.yaml in the config directory (0600 file, 0700 dir, atomic writes); unknown keys are kept when the CLI rewrites it. - Scope resolution with one precedence for every value: flag, then DEVLYFT_* variable, then the context (or the file for api_url and ca_bundle), then the default. --context / DEVLYFT_CONTEXT pick a context for one invocation. New global flags --context, --org, --project, --environment and --location (--environment, not --env, because `deploy --env K=V` sets environment variables). - `config get|set|list` for api_url, ca_bundle and current_context, with validation; `context use|list|show|delete`. `context use NAME` creates the context if needed and saves the scope flags given with it; `context show` without a name prints each resolved value and its source. config and context commands still run when the scope cannot resolve (e.g. a dangling current_context), so they can repair it. - internal/resolve: org by ID, slug or name; project and environment by ID or name; location by ID ignoring case. Ambiguous names are a usage error listing the matches; unknown names exit 4. - Factory.HTTPClient honours HTTPS_PROXY/HTTP_PROXY/NO_PROXY (read per invocation, not cached) and DEVLYFT_CA_BUNDLE / ca_bundle on top of the system roots, with a stderr notice whenever a bundle is in use. The API client uses it; the log stream can too. - Credentials are stored under the context's account, or "default". - Tests never read the developer's config: clitest uses a temp dir. Refs devlyft/devlyft#244 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
testscript leaves AppData unset on Windows, so os.UserConfigDir failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes devlyft/devlyft#244. Next in the stacked chain after #11 (base
feat/250-test-harness); retarget as the stack merges.What
internal/config):config.yamlin the config directory (~/.config/devlyft,%AppData%\devlyft), 0600 file in a 0700 directory, atomic writes. Schema:api_url,ca_bundle,current_context,contexts{name: {account, org, project, env, location}}. Unknown keys are preserved (top level and per context) so an older CLI never drops what a newer one wrote.config.ResolveScope): flag >DEVLYFT_*env > context (or the file forapi_url/ca_bundle) > default, for every value;--context/DEVLYFT_CONTEXToverride the current context for one invocation. Each value records its source.config get|set|list(validated; an empty value unsets),context use|list|show|delete.context use NAME [--org --project --environment --location --account]switches to NAME, creating it if missing, and saves the scope flags given on that command line;--project ""clears one. This keeps to the spec's verbs (no separatecreate/update).context showwith no name prints every resolved value and its source (flag/env/context/config/default), for debugging precedence;context show NAMEprints the saved context.context deleteconfirms or needs--yes; deleting the current context unsetscurrent_context.config/contextcommands skip scope resolution, so a danglingcurrent_contextor a badDEVLYFT_API_URLcan still be repaired;version/completiondon't read the config at all.internal/resolve): org by UUID, slug (unique, wins) or name; project/env by UUID or name (needs the parent); location by ID ignoring case. Exact name first, then case-insensitive. Ambiguity is a usage error (exit 2) listing the ID and name of every match, withdetails.matchesin JSON and a hint to use IDs in CI. No match isnot_found(exit 4). Nothing is cached. No command uses it yet; #247 is the first consumer.Factory.HTTPClient()is the single client for everything that dials out (the API facade now, the #254 log stream next). Proxy variables are read per invocation viax/net/http/httpproxy(nothttp.ProxyFromEnvironment, which caches them for the process lifetime).DEVLYFT_CA_BUNDLE/ca_bundlecertificates are added to the system roots, with a one-line stderr notice whenever a bundle is active, printed even with--quiet, since trusting extra CAs changes who can read the traffic.account, ordefaultwhen it has none, so credentials stored by #245 keep working with no migration.Decisions worth a look
--environment, not--env, for the global flag: spec §6.2 usesdeploy --env K=Vfor environment variables, and a persistent--envwould collide with it. The environment variable staysDEVLYFT_ENVand the context keyenv.DEVLYFT_ACCOUNTvariable: the spec puts the account on the context only.Tests
--context,DEVLYFT_CONTEXT,current_context, unknown, dangling); CA bundle source.Setvalidation.httptestserver fails without the bundle and works with it; a forward proxy receives the request;NO_PROXYbypasses it.context/configsession and of scope errors; the CA notice viaDEVLYFT_CA_BUNDLEandca_bundle.clitestnow gives each run a temporary config directory, so tests never read the developer's ownconfig.yaml.Coverage: 87.6% total (
internal/config87%,internal/resolve93.7%).make lint,make test,make vuln,make cover-check, Windows and macOS cross-builds and actionlint pass locally.🤖 Generated with Claude Code