Preserve explicit zero config values when applying defaults#177
Open
Vlasdislav wants to merge 2 commits into
Open
Preserve explicit zero config values when applying defaults#177Vlasdislav wants to merge 2 commits into
Vlasdislav wants to merge 2 commits into
Conversation
leborchuk
approved these changes
Jul 17, 2026
leborchuk
left a comment
Contributor
There was a problem hiding this comment.
LGTM, using opts and With methods is more go-way then checking default values
There was a problem hiding this comment.
Pull request overview
This PR changes config-loading to prefill defaults before YAML/TOML/JSON decoding so that explicitly configured zero/false values are preserved (instead of being overwritten by “zero means unset” defaulting).
Changes:
- Replaces
EmbedDefaultswith builder-style default constructors (BuildInstance,BuildStorage,BuildVacuum) and applies defaults by initializing the config struct prior to decoding. - Removes
EmbedDefaultscalls from copy flows and updates a garbage-collection test to construct vacuum defaults explicitly. - Adds
config/instance_test.goto verify defaults and preservation of explicit zero/false values across YAML/JSON/TOML.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/proc/interaction.go | Removes post-decode default embedding when reading the “old bucket” instance config. |
| pkg/proc/delete_handler_test.go | Updates test setup to use BuildVacuum defaults (with check_backup=false) instead of EmbedDefaults. |
| pkg/core/pg/pg.go | Removes post-decode default embedding when reading the “old bucket” instance config. |
| config/vacuum.go | Moves vacuum defaults into the vacuum config section and adds option/builder helpers. |
| config/storage.go | Moves storage defaults into the storage config section and adds option/builder helpers. |
| config/instance.go | Introduces instance builder/options and switches to “prefill then decode” initialization flow. |
| config/instance_test.go | Adds coverage ensuring defaults apply when unset and explicit zero/false values are preserved. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+127
to
132
| if strings.HasSuffix(file.Name(), ".yaml") { | ||
| return yaml.NewDecoder(file).Decode(&cfgInstance) | ||
| } | ||
| if cfgInstance.VacuumCnf.ProtectionWindow == 0 { | ||
| cfgInstance.VacuumCnf.ProtectionWindow = DefaultProtectionWindow | ||
| if strings.HasSuffix(file.Name(), ".json") { | ||
| return json.NewDecoder(file).Decode(&cfgInstance) | ||
| } |
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.
Prefill config defaults before YAML/TOML/JSON decoding so explicit zero and false values from user config are preserved. Move defaults to their config sections and cover the behavior with tests.