1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-01 07:27:46 +00:00

Add ability to disallow methods per a schema attribute

This commit is contained in:
Darren Shepherd
2021-08-13 11:02:38 -07:00
parent e9222c6ccf
commit d9512c366d
2 changed files with 32 additions and 6 deletions

View File

@@ -127,6 +127,25 @@ func Access(s *types.APISchema) interface{} {
return s.Attributes["access"]
}
func AddDisallowMethods(s *types.APISchema, methods ...string) {
data, ok := s.Attributes["disallowMethods"].(map[string]bool)
if !ok {
data = map[string]bool{}
s.Attributes["disallowMethods"] = data
}
for _, method := range methods {
data[method] = true
}
}
func DisallowMethods(s *types.APISchema) map[string]bool {
data, ok := s.Attributes["disallowMethods"].(map[string]bool)
if !ok {
return nil
}
return data
}
func SetAPIResource(s *types.APISchema, resource v1.APIResource) {
SetResource(s, resource.Name)
SetVerbs(s, resource.Verbs)