Merge pull request #87687 from markusthoemmes/action-match-subresource

Allow Action's Matches function to specify a subresource.
This commit is contained in:
Kubernetes Prow Robot
2020-01-30 18:46:45 -08:00
committed by GitHub

View File

@@ -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