mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Adjust the validating messages
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
This commit is contained in:
parent
5d995e3f7b
commit
142c2dd67b
@ -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 nonResourceURL"
|
kube::test::if_has_string "${output_message}" "subresource can not be used with NonResourceURL"
|
||||||
|
|
||||||
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}"
|
||||||
|
@ -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 nonResourceURL")
|
return fmt.Errorf("--subresource can not be used with NonResourceURL")
|
||||||
}
|
}
|
||||||
if o.Resource != (schema.GroupVersionResource{}) || o.ResourceName != "" {
|
if o.Resource != (schema.GroupVersionResource{}) || o.ResourceName != "" {
|
||||||
return fmt.Errorf("nonResourceURL and Resource can not specified together")
|
return fmt.Errorf("NonResourceURL and ResourceName can not specified together")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -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)
|
||||||
|
@ -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 {
|
|||||||
}
|
}
|
||||||
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 {
|
|||||||
}
|
}
|
||||||
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 {
|
|||||||
}
|
}
|
||||||
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())
|
||||||
|
Loading…
Reference in New Issue
Block a user