feat: add configuration file support (distill.yaml)#18
Merged
Conversation
Add distill.yaml config file support with:
- pkg/config: schema, loading, validation, env var interpolation
- distill config init: generate config template
- distill config validate: validate config files
- Viper bindings for api/serve commands to read from config
- Updated root.go config loading (distill.yaml, DISTILL_ env prefix)
- README documentation for config file usage
Config priority: CLI flags > env vars > config file > defaults.
Environment variables referenced via ${VAR} or ${VAR:-default}.
Closes #10
Co-authored-by: Ona <[email protected]>
Co-authored-by: Ona <[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.
Motivation
CLI flags are tedious for repeated use. A config file enables consistent settings across invocations and easier deployment configuration.
Closes #10
Changes
pkg/config/— Config schema, file loading, validation, and${VAR}/${VAR:-default}environment variable interpolationcmd/config.go—distill config init(generate template) anddistill config validate(check config file)cmd/api.go/cmd/serve.go— Viper bindings so config file values serve as fallbacks for CLI flagscmd/root.go— Updated config loading: searches fordistill.yaml(not.distill), usesDISTILL_env prefix with key replacerREADME.md— Config file documentation with example YAMLConfig priority
CLI flags > environment variables > config file > defaults
Example
Testing
go test ./...andgolangci-lint