Closed rina23q closed 3 months ago
As reference, git
also returns a non-zero exit code (1) if a specific configuration item is not set. This makes it possible to use a simple one-liner to do an action if something isn't set:
git config user.name || echo "user.name is not set"
Resolved by #2995
PR: https://github.com/thin-edge/thin-edge.io/pull/2995
Summary
The purpose of this PR is to address and resolve the issues outlined in this ticket.
Testing Performed
Unit Tests:
crates/core/tedge/tests/main.rs
Integration Tests:
Conducted integration tests to verify end-to-end functionality. Tested various configuration update scenarios to confirm proper handling.
Manual Testing:
Manually updated configurations and observed system behavior. Verified log entries for accuracy and completeness.
Automated Testing
tests/RobotFramework/tests/tedge/tedge_config_get.robot
The changes introduced in PR https://github.com/thin-edge/thin-edge.io/pull/2995 successfully resolve the issues outlined in this Ticket.
The implementation is robust, thoroughly tested, and ready for deployment.
Is your feature improvement request related to a problem? Please describe. Currently,
tedge config get
returns0
when the provided key is not set.It is inconvenient for writing a third party plugin. See Additional Context.
Describe the solution you'd like Return
1
instead of0
if the key doesn't have value set. If the key has a default value, returns 0 since it's anyway set.Describe alternatives you've considered
Additional context While writing a configuration file for tedge-monit-setup, this check "if c8y.url is not set, unmonitor c8y" is required. However, since the exit code is anyway
0
regardless whether it's set or not, the rule needed a kind of workaround.This could have been re-written more simply if the status is non-zero like below.