fix(config): prevent silent success on empty configs and fix context switch error propagation#930
Open
gcharpe1604 wants to merge 1 commit into
Open
Conversation
- Added validation in \harbor config apply\ to prevent silently accepting empty or invalid configuration files. - Updated \harbor context switch\ to return a non-zero exit code and standard error format when a context is not found, improving scriptability and automation UX. Signed-off-by: Govind Charpe <govind.charpe16@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #930 +/- ##
=========================================
- Coverage 10.99% 8.51% -2.48%
=========================================
Files 173 288 +115
Lines 8671 14445 +5774
=========================================
+ Hits 953 1230 +277
- Misses 7612 13098 +5486
- Partials 106 117 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Description
This PR addresses ungraceful handling of empty configuration files and context switching errors. Previously, applying an empty configuration resulted in a silent success (
exit 0), and failing to switch contexts printed an error but still exited gracefully, which breaks automation scripts.Type of Change
Please select the relevant type.
Changes
cmd/harbor/root/configurations/apply.goto error out on empty configuration files instead of silently succeeding.cmd/harbor/root/context/switch.goto return an explicit error, allowing Cobra to emit a proper non-zero exit code (exit 1) on failure.