-
Notifications
You must be signed in to change notification settings - Fork 46
Reorder config loading to load config and *then* fill in missing defaults #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughNewAtPath no longer applies default values when creating a config; FromFile now applies defaults after unmarshalling YAML. Comments were updated to indicate defaults are applied on file load rather than at construction time. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Config as config.NewAtPath
Note over Config: NewAtPath (after change)
Caller->>Config: NewAtPath(path)
activate Config
Config-->>Caller: Config{Path: path} (no defaults applied)
deactivate Config
sequenceDiagram
autonumber
participant Caller
participant Loader as config.FromFile
participant FS as Filesystem
Note over Loader: FromFile (after change)
Caller->>Loader: FromFile(path)
activate Loader
Loader->>FS: Read file
FS-->>Loader: YAML bytes
Loader->>Loader: Unmarshal YAML into Config
Loader->>Loader: Apply defaults.Set(c)
Loader-->>Caller: Config with defaults applied
deactivate Loader
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
config/config.go
(1 hunks)
🔇 Additional comments (1)
config/config.go (1)
368-373
: LGTM!The removal of
defaults.Set()
fromNewAtPath
is correct. The constructor now only sets the path, and defaults are applied later inFromFile
after YAML unmarshaling. This prevents unintended merging of arrays/maps from the config file with default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know they reverted it as it broke config generation: |
Sorry, haven't followed that thread. I am still having a problem with setting |
Quoting the original PR:
Summary by CodeRabbit
Bug Fixes
Documentation