mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +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
|
return a.Subresource
|
||||||
}
|
}
|
||||||
func (a ActionImpl) Matches(verb, resource string) bool {
|
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) &&
|
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 {
|
func (a ActionImpl) DeepCopy() Action {
|
||||||
ret := a
|
ret := a
|
||||||
|
Loading…
Reference in New Issue
Block a user