feat(config): honor DISPATCH_CONFIG to override config file path#300
Merged
Conversation
Set DISPATCH_CONFIG to an absolute file path to point dispatch at a different config file, which makes it easy to keep separate profiles without editing JSON by hand. The override flows through configPath(), so config path/get/set/edit and doctor all follow it. A relative or UNC value is ignored and the default OS config location is used, matching the guard already applied to the log file path. Closes #295 Co-authored-by: Copilot App <[email protected]>
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 #295
Summary
Adds a
DISPATCH_CONFIGenvironment variable that overrides the config file path. Point it at an absolute file path to keep separate profiles (for example work and personal) without editing JSON by hand.The override is resolved in one place,
configPath(), so every consumer follows it:dispatch config path/get/set/editdispatch doctorA relative or UNC value is ignored and the default OS config location is used instead. This mirrors the guard already applied to the log file path, so the override cannot point at a network share or a path relative to the current directory.
Verification
go build ./...go test ./...(added 4 tests in internal/config for override, save/load round-trip, relative + UNC rejection, and unset falls back to default)go vet ./...golangci-lint run --timeout 10m(0 issues)mage deadcode(OK)DISPATCH_CONFIGrow in the Environment Variables table