remove validNonResourceVerbs in create role

pull/6/head
xilabao 2017-02-16 18:02:10 +08:00
parent 148155f8b8
commit 367006bea4
2 changed files with 13 additions and 4 deletions

View File

@ -43,9 +43,6 @@ var (
// Valid resource verb list for validation.
validResourceVerbs = []string{"*", "get", "delete", "list", "create", "update", "patch", "watch", "proxy", "redirect", "deletecollection"}
// Valid non-resource verb list for validation.
validNonResourceVerbs = []string{"get", "post", "put", "delete"}
)
type CreateRoleOptions struct {
@ -137,7 +134,7 @@ func (c *CreateRoleOptions) Validate(f cmdutil.Factory) error {
}
for _, v := range c.Verbs {
if !arrayContains(validResourceVerbs, v) && !arrayContains(validNonResourceVerbs, v) {
if !arrayContains(validResourceVerbs, v) {
return fmt.Errorf("invalid verb: '%s'", v)
}
}

View File

@ -157,6 +157,18 @@ func TestValidate(t *testing.T) {
},
expectErr: true,
},
"test-nonresource-verb": {
roleOptions: &CreateRoleOptions{
Name: "my-role",
Verbs: []string{"post"},
Resources: []schema.GroupVersionResource{
{
Resource: "pods",
},
},
},
expectErr: true,
},
"test-invalid-resource": {
roleOptions: &CreateRoleOptions{
Name: "my-role",