mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #87687 from markusthoemmes/action-match-subresource
Allow Action's Matches function to specify a subresource.
This commit is contained in:
commit
bca516f179
@ -439,8 +439,18 @@ func (a ActionImpl) GetSubresource() string {
|
||||
return a.Subresource
|
||||
}
|
||||
func (a ActionImpl) Matches(verb, resource string) bool {
|
||||
// Stay backwards compatible.
|
||||
if !strings.Contains(resource, "/") {
|
||||
return strings.EqualFold(verb, a.Verb) &&
|
||||
strings.EqualFold(resource, a.Resource.Resource)
|
||||
}
|
||||
|
||||
parts := strings.SplitN(resource, "/", 2)
|
||||
topresource, subresource := parts[0], parts[1]
|
||||
|
||||
return strings.EqualFold(verb, a.Verb) &&
|
||||
strings.EqualFold(resource, a.Resource.Resource)
|
||||
strings.EqualFold(topresource, a.Resource.Resource) &&
|
||||
strings.EqualFold(subresource, a.Subresource)
|
||||
}
|
||||
func (a ActionImpl) DeepCopy() Action {
|
||||
ret := a
|
||||
|
Loading…
Reference in New Issue
Block a user