feat: add defaults envs for auto compose#10
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
=======================================
Coverage 99.93% 99.94%
=======================================
Files 179 179
Lines 6664 6668 +4
Branches 1451 1458 +7
=======================================
+ Hits 6660 6664 +4
Misses 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for watcher-level compose defaults that apply when container-level compose labels are not present. It allows setting default values for compose trigger options (backup, prune, dryrun, auto, threshold) via environment variables at the watcher level.
Changes:
- Added
composeconfiguration object to Docker watcher with optional boolean/string fields for default trigger options - Modified compose trigger configuration extraction to fall back to watcher-level defaults when labels are absent
- Added comprehensive test coverage for the new default behavior and label override scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/watchers/providers/docker/Docker.ts | Added compose defaults interface, schema validation, helper function for value normalization, and updated getDockercomposeTriggerConfigurationFromLabels to use defaults as fallback |
| app/watchers/providers/docker/Docker.test.ts | Added tests for watcher compose defaults during init and container detail processing, including label override scenarios |
| README.md | Documented the new watcher-level environment variables for compose defaults |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const backup = | ||
| getLabel(labels, ddComposeBackup, wudComposeBackup) ?? | ||
| normalizeComposeDefaultValue(composeDefaults.backup); | ||
| if (backup !== undefined) { | ||
| dockercomposeConfig.backup = backup; | ||
| } | ||
|
|
||
| const prune = getLabel(labels, ddComposePrune, wudComposePrune); | ||
| const prune = | ||
| getLabel(labels, ddComposePrune, wudComposePrune) ?? | ||
| normalizeComposeDefaultValue(composeDefaults.prune); | ||
| if (prune !== undefined) { | ||
| dockercomposeConfig.prune = prune; | ||
| } | ||
|
|
||
| const dryrun = getLabel(labels, ddComposeDryrun, wudComposeDryrun); | ||
| const dryrun = | ||
| getLabel(labels, ddComposeDryrun, wudComposeDryrun) ?? | ||
| normalizeComposeDefaultValue(composeDefaults.dryrun); | ||
| if (dryrun !== undefined) { | ||
| dockercomposeConfig.dryrun = dryrun; | ||
| } | ||
|
|
||
| const auto = getLabel(labels, ddComposeAuto, wudComposeAuto); | ||
| const auto = | ||
| getLabel(labels, ddComposeAuto, wudComposeAuto) ?? | ||
| normalizeComposeDefaultValue(composeDefaults.auto); | ||
| if (auto !== undefined) { | ||
| dockercomposeConfig.auto = auto; | ||
| } | ||
|
|
||
| const threshold = getLabel(labels, ddComposeThreshold, wudComposeThreshold); | ||
| const threshold = | ||
| getLabel(labels, ddComposeThreshold, wudComposeThreshold) || | ||
| normalizeConfigStringValue(composeDefaults.threshold); |
There was a problem hiding this comment.
Inconsistent handling of empty string labels: threshold uses || with normalizeConfigStringValue (treats empty strings as unset), while backup/prune/dryrun/auto use ?? with normalizeComposeDefaultValue (preserves empty strings as ""). This creates different behaviors - an empty threshold label falls back to the default, but an empty backup label would result in backup: "". For consistency, either use || for all fields to treat empty strings as unset, or modify normalizeComposeDefaultValue to return undefined for empty strings like normalizeConfigStringValue does.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@Crow-Control I've opened a new pull request, #11, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * fix: use consistent empty string handling for compose labels Co-authored-by: Crow-Control <7613738+Crow-Control@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Crow-Control <7613738+Crow-Control@users.noreply.github.com>
5779329 to
d665764
Compare
Description
⚒️ Fixes #
⚙️ Type of change
🧪 How Has This Been Tested?
📃 Notes:
✔️ Checklist:
feat(chart-name):,fix(chart-name):,chore(chart-name):,docs(chart-name):orfix(docs):➕ App addition
If this PR is an app addition please make sure you have done the following.
icon.pngPlease don't blindly check all the boxes. Read them and only check those that apply.
Those checkboxes are there for the reviewer to see what is this all about and
the status of this PR with a quick glance.