-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix leaf-list validation when it is a relative path leafref (#626)
* workaround leafref validation * as commented by @wenovus in #623 The fix is essentially correct: we handle the case of lists (a single level in YANG) being represented as two levels in Go (map -> element), but don't handle the case of leaf-lists also being represented as two levels in Go (slice -> element). The "two levels" is how ForEachField processes elements, which creates this corner case for DataNodeAtPath. It turns out we already had a test case for this but it had an extra "../" s o it was testing the wrong behaviour. * Do not trim compressed path elements for maps or slices. Currently, we trim the path for a `map[]{}` or slice type in Go for lists in order to prevent the list's name from appearing twice in the data tree while traversing a list element. This is because `forEachFieldInternal` currently creates new `NodeInfo` elements, copying the list name, when traversing list elements. Based on the tests that fail, this behaviour apparently tries to solve the problem of processing "../" when calling `ytypes.dataNodesAtPath`, but the logic in there incorrectly identifies compression to be the issue: compression is indeed not the issue, but rather how slices and maps are processed in two levels -- slices and maps exist equally in compressed and uncompressed generated code. This PR removes the dependency of existing logic on schema compression, but rather on whether the current element is a map or a slice, corresponding to a YANG list or leaf-list, and in such cases, it skips that extra level created by `forEachFieldInternal` instead. This results in slightly simpler, and much more understandable logic with the comment updates. * try using go install * misspelling * Add a sentence on why compression is not involved Co-authored-by: Hans Thienpondt <hans.thienpondt@nokia.com>
- Loading branch information
1 parent
444fa8c
commit c238422
Showing
4 changed files
with
169 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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