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
commit bca516f179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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