-
Notifications
You must be signed in to change notification settings - Fork 118
CVL Enhancement and Fixes #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ __pycache__ | |
| *.yin | ||
| *.tree | ||
| translib/ocbinds/ocbinds.go | ||
| models/yang/*.md | ||
| .idea | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package common | ||
|
|
||
| // KeyMatch checks if the value matches a key pattern. | ||
| // vIndex and pIndex are start positions of value and pattern strings to match. | ||
| // Mimics redis pattern matcher - i.e, glob like pattern matcher which | ||
| // matches '/' against wildcard. | ||
| // Supports '*' and '?' wildcards with '\' as the escape character. | ||
| // '*' matches any char sequence or none; '?' matches exactly one char. | ||
| // Character classes are not supported (redis supports it). | ||
| func KeyMatch(value, pattern string) bool { | ||
| return keyMatch(value, 0, pattern, 0) | ||
| } | ||
|
|
||
| func keyMatch(value string, vIndex int, pattern string, pIndex int) bool { | ||
| for pIndex < len(pattern) { | ||
| switch pattern[pIndex] { | ||
| case '*': | ||
| // Skip successive *'s in the pattern | ||
| pIndex++ | ||
| for pIndex < len(pattern) && pattern[pIndex] == '*' { | ||
| pIndex++ | ||
| } | ||
| // Pattern ends with *. Its a match always | ||
| if pIndex == len(pattern) { | ||
| return true | ||
| } | ||
| // Try to match remaining pattern with every value substring | ||
| for ; vIndex < len(value); vIndex++ { | ||
| if keyMatch(value, vIndex, pattern, pIndex) { | ||
| return true | ||
| } | ||
| } | ||
| // No match for remaining pattern | ||
| return false | ||
|
|
||
| case '?': | ||
| // Accept any char.. there should be at least one | ||
| if vIndex >= len(value) { | ||
| return false | ||
| } | ||
| vIndex++ | ||
| pIndex++ | ||
|
|
||
| case '\\': | ||
| // Do not treat \ as escape char if it is the last pattern char. | ||
| // Redis commands behave this way. | ||
| if pIndex+1 < len(pattern) { | ||
| pIndex++ | ||
| } | ||
| fallthrough | ||
|
|
||
| default: | ||
| if vIndex >= len(value) || pattern[pIndex] != value[vIndex] { | ||
| return false | ||
| } | ||
| vIndex++ | ||
| pIndex++ | ||
| } | ||
| } | ||
|
|
||
| // All pattern chars have been compared. | ||
| // It is a match if all value chars have been exhausted too. | ||
| return (vIndex == len(value)) | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| //////////////////////////////////////////////////////////////////////////////// | ||
| // // | ||
| // Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or // | ||
| // its subsidiaries. // | ||
| // // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); // | ||
| // you may not use this file except in compliance with the License. // | ||
| // You may obtain a copy of the License at // | ||
| // // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 // | ||
| // // | ||
| // Unless required by applicable law or agreed to in writing, software // | ||
| // distributed under the License is distributed on an "AS IS" BASIS, // | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // | ||
| // See the License for the specific language governing permissions and // | ||
| // limitations under the License. // | ||
| // // | ||
| //////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| //go:build test | ||
| // +build test | ||
|
|
||
| package custom_validation | ||
|
|
||
| func (t *CustomValidation) ValidateIfExtraFieldValidationCalled( | ||
| vc *CustValidationCtxt) CVLErrorInfo { | ||
| vc.SessCache.Hint["ExtraFieldValidationCalled"] = true | ||
| return CVLErrorInfo{ErrCode: CVL_SUCCESS} | ||
|
|
||
| } | ||
|
|
||
| func (t *CustomValidation) ValidateIfListLevelValidationCalled( | ||
| vc *CustValidationCtxt) CVLErrorInfo { | ||
| vc.SessCache.Hint["ListLevelValidationCalled"] = true | ||
| return CVLErrorInfo{ErrCode: CVL_SUCCESS} | ||
|
|
||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.