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
142c2dd6
Commit
142c2dd6
authored
Sep 20, 2017
by
yuexiao-wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust the validating messages
Signed-off-by:
yuexiao-wang
<
wang.yuexiao@zte.com.cn
>
parent
5d995e3f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
9 deletions
+6
-9
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+1
-1
cani.go
pkg/kubectl/cmd/auth/cani.go
+2
-2
cani_test.go
pkg/kubectl/cmd/auth/cani_test.go
+3
-2
reconcile.go
pkg/kubectl/cmd/auth/reconcile.go
+0
-4
No files found.
hack/make-rules/test-cmd-util.sh
View file @
142c2dd6
...
@@ -4685,7 +4685,7 @@ runTests() {
...
@@ -4685,7 +4685,7 @@ runTests() {
kube::test::if_has_string
"
${
output_message
}
"
"yes"
kube::test::if_has_string
"
${
output_message
}
"
"yes"
output_message
=
$(
!
kubectl auth can-i get /logs/
--subresource
=
log 2>&1
"
${
kube_flags
[@]
}
"
)
output_message
=
$(
!
kubectl auth can-i get /logs/
--subresource
=
log 2>&1
"
${
kube_flags
[@]
}
"
)
kube::test::if_has_string
"
${
output_message
}
"
"subresource can not be used with
n
onResourceURL"
kube::test::if_has_string
"
${
output_message
}
"
"subresource can not be used with
N
onResourceURL"
output_message
=
$(
kubectl auth can-i list jobs.batch/bar
-n
foo
--quiet
2>&1
"
${
kube_flags
[@]
}
"
)
output_message
=
$(
kubectl auth can-i list jobs.batch/bar
-n
foo
--quiet
2>&1
"
${
kube_flags
[@]
}
"
)
kube::test::if_empty_string
"
${
output_message
}
"
kube::test::if_empty_string
"
${
output_message
}
"
...
...
pkg/kubectl/cmd/auth/cani.go
View file @
142c2dd6
...
@@ -156,10 +156,10 @@ func (o *CanIOptions) Complete(f cmdutil.Factory, args []string) error {
...
@@ -156,10 +156,10 @@ func (o *CanIOptions) Complete(f cmdutil.Factory, args []string) error {
func
(
o
*
CanIOptions
)
Validate
()
error
{
func
(
o
*
CanIOptions
)
Validate
()
error
{
if
o
.
NonResourceURL
!=
""
{
if
o
.
NonResourceURL
!=
""
{
if
o
.
Subresource
!=
""
{
if
o
.
Subresource
!=
""
{
return
fmt
.
Errorf
(
"--subresource can not be used with
n
onResourceURL"
)
return
fmt
.
Errorf
(
"--subresource can not be used with
N
onResourceURL"
)
}
}
if
o
.
Resource
!=
(
schema
.
GroupVersionResource
{})
||
o
.
ResourceName
!=
""
{
if
o
.
Resource
!=
(
schema
.
GroupVersionResource
{})
||
o
.
ResourceName
!=
""
{
return
fmt
.
Errorf
(
"
nonResourceURL and Resourc
e can not specified together"
)
return
fmt
.
Errorf
(
"
NonResourceURL and ResourceNam
e can not specified together"
)
}
}
}
}
return
nil
return
nil
...
...
pkg/kubectl/cmd/auth/cani_test.go
View file @
142c2dd6
...
@@ -124,8 +124,9 @@ func TestRunAccessCheck(t *testing.T) {
...
@@ -124,8 +124,9 @@ func TestRunAccessCheck(t *testing.T) {
APIRegistry
:
api
.
Registry
,
APIRegistry
:
api
.
Registry
,
NegotiatedSerializer
:
ns
,
NegotiatedSerializer
:
ns
,
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
if
req
.
URL
.
Path
!=
"/apis/authorization.k8s.io/v1/selfsubjectaccessreviews"
{
expectPath
:=
"/apis/authorization.k8s.io/v1/selfsubjectaccessreviews"
t
.
Errorf
(
"%s: %v"
,
test
.
name
,
req
.
URL
.
Path
)
if
req
.
URL
.
Path
!=
expectPath
{
t
.
Errorf
(
"%s: expected %v, got %v"
,
test
.
name
,
expectPath
,
req
.
URL
.
Path
)
return
nil
,
nil
return
nil
,
nil
}
}
bodyBits
,
err
:=
ioutil
.
ReadAll
(
req
.
Body
)
bodyBits
,
err
:=
ioutil
.
ReadAll
(
req
.
Body
)
...
...
pkg/kubectl/cmd/auth/reconcile.go
View file @
142c2dd6
...
@@ -157,7 +157,6 @@ func (o *ReconcileOptions) RunReconcile() error {
...
@@ -157,7 +157,6 @@ func (o *ReconcileOptions) RunReconcile() error {
}
}
shallowInfoCopy
.
Object
=
result
.
Role
.
GetObject
()
shallowInfoCopy
.
Object
=
result
.
Role
.
GetObject
()
o
.
Print
(
&
shallowInfoCopy
)
o
.
Print
(
&
shallowInfoCopy
)
return
nil
case
*
rbac
.
ClusterRole
:
case
*
rbac
.
ClusterRole
:
reconcileOptions
:=
reconciliation
.
ReconcileRoleOptions
{
reconcileOptions
:=
reconciliation
.
ReconcileRoleOptions
{
...
@@ -174,7 +173,6 @@ func (o *ReconcileOptions) RunReconcile() error {
...
@@ -174,7 +173,6 @@ func (o *ReconcileOptions) RunReconcile() error {
}
}
shallowInfoCopy
.
Object
=
result
.
Role
.
GetObject
()
shallowInfoCopy
.
Object
=
result
.
Role
.
GetObject
()
o
.
Print
(
&
shallowInfoCopy
)
o
.
Print
(
&
shallowInfoCopy
)
return
nil
case
*
rbac
.
RoleBinding
:
case
*
rbac
.
RoleBinding
:
reconcileOptions
:=
reconciliation
.
ReconcileRoleBindingOptions
{
reconcileOptions
:=
reconciliation
.
ReconcileRoleBindingOptions
{
...
@@ -192,7 +190,6 @@ func (o *ReconcileOptions) RunReconcile() error {
...
@@ -192,7 +190,6 @@ func (o *ReconcileOptions) RunReconcile() error {
}
}
shallowInfoCopy
.
Object
=
result
.
RoleBinding
.
GetObject
()
shallowInfoCopy
.
Object
=
result
.
RoleBinding
.
GetObject
()
o
.
Print
(
&
shallowInfoCopy
)
o
.
Print
(
&
shallowInfoCopy
)
return
nil
case
*
rbac
.
ClusterRoleBinding
:
case
*
rbac
.
ClusterRoleBinding
:
reconcileOptions
:=
reconciliation
.
ReconcileRoleBindingOptions
{
reconcileOptions
:=
reconciliation
.
ReconcileRoleBindingOptions
{
...
@@ -209,7 +206,6 @@ func (o *ReconcileOptions) RunReconcile() error {
...
@@ -209,7 +206,6 @@ func (o *ReconcileOptions) RunReconcile() error {
}
}
shallowInfoCopy
.
Object
=
result
.
RoleBinding
.
GetObject
()
shallowInfoCopy
.
Object
=
result
.
RoleBinding
.
GetObject
()
o
.
Print
(
&
shallowInfoCopy
)
o
.
Print
(
&
shallowInfoCopy
)
return
nil
default
:
default
:
glog
.
V
(
1
)
.
Infof
(
"skipping %#v"
,
info
.
Object
.
GetObjectKind
())
glog
.
V
(
1
)
.
Infof
(
"skipping %#v"
,
info
.
Object
.
GetObjectKind
())
...
...
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