feat: use Viper for controller configuration loading#292
Conversation
49ac78c to
4d75327
Compare
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the controller's configuration flexibility by integrating the Viper library. This allows the application to load configuration parameters not only from command-line flags but also from environment variables, providing a more robust and adaptable setup for deployment in various environments. The change ensures that CLI flags maintain precedence over environment variables, offering predictable behavior. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #292 +/- ##
===========================================
- Coverage 46.85% 25.15% -21.70%
===========================================
Files 11 10 -1
Lines 683 652 -31
===========================================
- Hits 320 164 -156
- Misses 340 487 +147
+ Partials 23 1 -22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@codex PTAL |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d7532713b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| github.com/onsi/gomega v1.39.1 | ||
| github.com/pkg/errors v0.9.1 | ||
| github.com/spf13/cobra v1.10.2 | ||
| github.com/spf13/viper v1.20.1 |
There was a problem hiding this comment.
Add go.sum checksums for the new Viper module
This adds github.com/spf13/viper to go.mod but does not include matching go.sum entries, which causes reproducible/read-only module builds to fail with missing go.sum entry for module providing package github.com/spf13/viper (for example when running with -mod=readonly). Please commit the generated go.sum updates alongside this dependency change.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks for the catch!
The go.sum updates have been included in 2b5a592.
Integrates github.com/spf13/viper to support environment variable-based configuration alongside existing Cobra CLI flags. - Add viper dependency to go.mod - Bind all Cobra PersistentFlags to viper with BindPFlags - Enable AutomaticEnv with hyphen-to-underscore key replacement - Read config values from viper inside RunE for consistent precedence: CLI flags > environment variables This allows local debugging with .env files without manually wiring os.Getenv() for each flag. Examples: --cloudflare-api-token=xxx or CLOUDFLARE_API_TOKEN=xxx --cloudflare-account-id=xxx or CLOUDFLARE_ACCOUNT_ID=xxx Fixes STRRL#291
4d75327 to
2b5a592
Compare
|
Hi @STRRL, Please let me know if there is anything further I should take care of. |
NP! I will take a look later today |
Summary
Integrates
github.com/spf13/viperto support environment variable-based configuration alongside existing Cobra CLI flags.Changes
viperdependency togo.mod/go.sumPersistentFlagsto viper withBindPFlagsAutomaticEnvwith hyphen-to-underscore key replacementRunEfor consistent precedenceos.Getenv()calls incontrolled-cloudflared-connector.gowith viper (2b5a592)Config precedence
Examples
# These are now equivalent: --cloudflare-api-token=xxx CLOUDFLARE_API_TOKEN=xxx --cloudflare-account-id=xxx CLOUDFLARE_ACCOUNT_ID=xxxCloses #291