-
Notifications
You must be signed in to change notification settings - Fork 784
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
Support GVK format is case sensitive #2261
Conversation
Did you happen to test plural vs singular as well? I know it's not the subject of this PR but asking. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we convert the GVK dynamically while processing the policy? Mutating the policy may not work if mutating webhook is missing or the policy creation request is somehow missed.
@vyankyGH - what do you think? |
Sorry, I missed comment. I will update to convert GVK while processing the policy. |
Added test cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if resource.GetKind() == strings.Title(kind) { | ||
return true | ||
} | ||
} else if len(SplitGVK) == 2 { | ||
if resource.GroupVersionKind().Kind == SplitGVK[1] && resource.GroupVersionKind().Version == SplitGVK[0] { | ||
if resource.GroupVersionKind().Kind == strings.Title(SplitGVK[1]) && resource.GroupVersionKind().Version == SplitGVK[0] { | ||
return true | ||
} | ||
} else { | ||
if resource.GroupVersionKind().Group == SplitGVK[0] && resource.GroupVersionKind().Kind == SplitGVK[2] && (resource.GroupVersionKind().Version == SplitGVK[1] || resource.GroupVersionKind().Version == "*") { | ||
if resource.GroupVersionKind().Group == SplitGVK[0] && resource.GroupVersionKind().Kind == strings.Title(SplitGVK[2]) && (resource.GroupVersionKind().Version == SplitGVK[1] || resource.GroupVersionKind().Version == "*") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vyankyGH - this solution won't work for resources like ConfigMap, ClusterRole, CronJob, etc. We need to leverage this util GetFormatedKind
to match the GVK.
Signed-off-by: Vyankatesh vyankateshkd@gmail.com
Related issue
closes #2253
Milestone of this PR
What type of PR is this
Proposed Changes
Proof Manifests
Resource.yaml
After install policy -o yaml
Resource.yaml
After install policy -o yaml
Resource.yaml
After install policy -o yaml
Checklist
Further Comments