Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
367006be
Commit
367006be
authored
Feb 16, 2017
by
xilabao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove validNonResourceVerbs in create role
parent
148155f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
create_role.go
pkg/kubectl/cmd/create_role.go
+1
-4
create_role_test.go
pkg/kubectl/cmd/create_role_test.go
+12
-0
No files found.
pkg/kubectl/cmd/create_role.go
View file @
367006be
...
@@ -43,9 +43,6 @@ var (
...
@@ -43,9 +43,6 @@ var (
// Valid resource verb list for validation.
// Valid resource verb list for validation.
validResourceVerbs
=
[]
string
{
"*"
,
"get"
,
"delete"
,
"list"
,
"create"
,
"update"
,
"patch"
,
"watch"
,
"proxy"
,
"redirect"
,
"deletecollection"
}
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
{
type
CreateRoleOptions
struct
{
...
@@ -137,7 +134,7 @@ func (c *CreateRoleOptions) Validate(f cmdutil.Factory) error {
...
@@ -137,7 +134,7 @@ func (c *CreateRoleOptions) Validate(f cmdutil.Factory) error {
}
}
for
_
,
v
:=
range
c
.
Verbs
{
for
_
,
v
:=
range
c
.
Verbs
{
if
!
arrayContains
(
validResourceVerbs
,
v
)
&&
!
arrayContains
(
validNonResourceVerbs
,
v
)
{
if
!
arrayContains
(
validResourceVerbs
,
v
)
{
return
fmt
.
Errorf
(
"invalid verb: '%s'"
,
v
)
return
fmt
.
Errorf
(
"invalid verb: '%s'"
,
v
)
}
}
}
}
...
...
pkg/kubectl/cmd/create_role_test.go
View file @
367006be
...
@@ -157,6 +157,18 @@ func TestValidate(t *testing.T) {
...
@@ -157,6 +157,18 @@ func TestValidate(t *testing.T) {
},
},
expectErr
:
true
,
expectErr
:
true
,
},
},
"test-nonresource-verb"
:
{
roleOptions
:
&
CreateRoleOptions
{
Name
:
"my-role"
,
Verbs
:
[]
string
{
"post"
},
Resources
:
[]
schema
.
GroupVersionResource
{
{
Resource
:
"pods"
,
},
},
},
expectErr
:
true
,
},
"test-invalid-resource"
:
{
"test-invalid-resource"
:
{
roleOptions
:
&
CreateRoleOptions
{
roleOptions
:
&
CreateRoleOptions
{
Name
:
"my-role"
,
Name
:
"my-role"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment