Skip to content

feat: support repo-local config for context selection - #85

Open
Karnak19 wants to merge 1 commit into
coollabsio:mainfrom
Karnak19:Karnak19/feat-repo-local-context
Open

feat: support repo-local config for context selection#85
Karnak19 wants to merge 1 commit into
coollabsio:mainfrom
Karnak19:Karnak19/feat-repo-local-context

Conversation

@Karnak19

@Karnak19 Karnak19 commented Aug 17, 2026

Copy link
Copy Markdown

Closes #58Support repo-local config for context selection

Adds a repo-local config file so a repository can pin which context every coolify command inside it targets, without anyone having to remember --context or flip the global default back and forth.

Usage

.coolify.json (or .coolifyrc) at the repo root:

{
  "context": "production"
}

The CLI walks up from the working directory and uses the nearest one.

Resolution order

  1. --context flag
  2. repo-local .coolify.json / .coolifyrc
  3. global default context

Notes

  • No credentials in the repo. The file only names a context that already exists in ~/.config/coolify/config.json; tokens stay global.
  • Both file names are plain JSON, so no new dependency (.coolify.toml would need a TOML parser for a single key — happy to add it if you'd prefer that shape).
  • A repo-local file naming a context that doesn't exist is a hard error that prints both paths, rather than a silent fallback to the default instance — silently deploying to the wrong place is the thing the issue is about.
  • Malformed JSON in the local file errors too, for the same reason.
  • --debug prints which file the context came from.
  • Wired into cli.GetAPIClient, the single point where every command resolves its context, so all commands pick it up.

Testing

internal/config/local_test.go covers discovery from a nested directory, nearest-file-wins, absence, and parse failure. go test ./internal/... and go vet ./... are green; also verified against a built binary for the override, hit, and miss paths.

🤖 Generated with Claude Code

- Add .coolify.json / .coolifyrc discovery, walking up from the working
  directory; nearest file wins, malformed JSON errors instead of silently
  falling back to the global default
- Resolve contexts as: --context flag > repo-local file > global default
- Point a missing repo-local context at both the file and the global config
  in the error, and log the source file under --debug
- Keep credentials global: the repo file only names an existing context
- Add tests for discovery, precedence and parse failures; document in README

Closes coollabsio#58

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

Support repo-local config for context selection

1 participant