-
Notifications
You must be signed in to change notification settings - Fork 818
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
Adding Tests and Refactoring for ruleWithKSOpaDependency Function in cautils #1487
Adding Tests and Refactoring for ruleWithKSOpaDependency Function in cautils #1487
Conversation
Signed-off-by: cbrom <kb.cbrom@gmail.com>
Signed-off-by: cbrom <kb.cbrom@gmail.com>
/describe |
@vladklokun @Daniel-GrunbergerCA Looking up at the repo history I see you might have a clue if the |
Doing a search into the |
@amirmalka should I get rid of the function and its usage at https://github.com/kubescape/kubescape/blob/master/core/cautils/datastructuresmethods.go#L36 |
/describe |
@cbrom yes, it looks like it's not used in any of our controls |
Signed-off-by: cbrom <kb.cbrom@gmail.com>
…ionCompatible function Signed-off-by: cbrom <kb.cbrom@gmail.com>
…FromKubescapeVersion Signed-off-by: cbrom <kb.cbrom@gmail.com>
cb45bcf
to
4ae45cd
Compare
@amirmalka I've removed the function along with its usage and added type safe checks and tests to other function. |
@amirmalka are you reviewing that? |
/review |
PR Analysis
PR Feedback
How to useInstructions
|
@cbrom please check the code feedback on |
The type assertion works fine for string and does not lead to panic.
|
@matthyx I was doing a code improvement on this :( to use switch case for type assertion and remove unnecessary if else conditionals. Should I create a new PR? |
ooops sorry, next time put it back to draft to indicate you don't want to merge it |
PR Type:
Tests
PR Description:
This PR introduces the following changes:
ruleWithKSOpaDependency
function incore/cautils/datastructuresmethods_test.go
.ruleWithKSOpaDependency
function incore/cautils/datastructuresmethods.go
to handle type assertion of the "armoOpa" attribute.PR Main Files Walkthrough:
files:
core/cautils/datastructuresmethods.go
: Refactored theruleWithKSOpaDependency
function to handle type assertion of the 'armoOpa' attribute.core/cautils/datastructuresmethods_test.go
: Added unit tests for theruleWithKSOpaDependency
function, covering cases when attributes are nil, do not contain 'armoOpa' key, contain 'armoOpa' key with non-boolean value, and contain 'armoOpa' key with value 'true'.