A lot of fixes around setting / retrieving base64 encoded values#701
Merged
ianmcorvidae merged 7 commits intomeshtastic:masterfrom Oct 29, 2024
Merged
A lot of fixes around setting / retrieving base64 encoded values#701ianmcorvidae merged 7 commits intomeshtastic:masterfrom
ianmcorvidae merged 7 commits intomeshtastic:masterfrom
Conversation
We have a lot of code duplication by checkin over and over again if field should be named in camel or snake notation. We simplify this by writing the choosen variant into a variable and just use that name across the code. No functional change.
We add a local helper function to print a single setting. This is a preparation to correctly print non-trivial types. The existing code in getPref is ported over to use that function. By that, the output of "wholeField" is changed slightly to always print the full path for each setting (e.g. "security.serialEnabled" instead of "security:\nserialEnabled"). This improves support for grepping on the output.
When getting config values of type bytes or list (technically a protobuf repeated container type), these were directly printed on the output. However, the retrieved values could not be set by --set again, as the format was different (e.g. python string representation of bytes vs. base64 prefixed and encoded as expected by --set). We fix this by adding a toStr utility function (similar to the fromStr) function to convert byte types correctly to the base64 representation. Further, we check if the type is repeated and apply this operation to all values.
Same change as done in getPerf to have less branches (simplifies the code).
By passing a typed value we can conserve the type information to later use that to convert it back into the correct protobuf type. The type conversion is now done inside setPref.
When setting the whole configuration via --configure, list types like adminKey need special handling. Previously this failed as a list cannot be appended to a list. The new code adds dedicated logic to replace the repeated value when passing a list. Also, all items of that list are converted into the correct (typed) form before setting them.
When clearning or appending to a repeated value, both the "Clearing..." / "Adding..." line and the "Set..." line were shown. However, this is misleading as the only performed operation is the clearing / appending. We fix this by directly returning from the function in case of clearing / appending.
Contributor
|
Not sure why the codecov check is failing but I'm not worried about it. This all looks good to me; thanks again for the fixes/improvements! |
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.
For details, please check the individual commit messages.