Warn when creating roles with custom verbs kubectl
Remove errors when using custom verbs Signed-off-by: Eddie Zaneski <eddiezane@gmail.com> Kubernetes-commit: c9420cd703b9431528e91a78428bb982d3b20b67
This commit is contained in:
parent
129c63b3d6
commit
1ac77cf17d
|
@ -143,7 +143,7 @@ func (c *CreateClusterRoleOptions) Validate() error {
|
|||
if len(c.Resources) > 0 {
|
||||
for _, v := range c.Verbs {
|
||||
if !arrayContains(validResourceVerbs, v) {
|
||||
return fmt.Errorf("invalid verb: '%s'", v)
|
||||
fmt.Fprintf(c.ErrOut, "Warning: '%s' is not a standard resource verb\n", v)
|
||||
}
|
||||
}
|
||||
if err := c.validateResource(); err != nil {
|
||||
|
|
|
@ -243,7 +243,7 @@ func TestClusterRoleValidate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expectErr: false,
|
||||
},
|
||||
"test-nonresource-verb": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
|
@ -257,7 +257,7 @@ func TestClusterRoleValidate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expectErr: false,
|
||||
},
|
||||
"test-special-verb": {
|
||||
clusterRoleOptions: &CreateClusterRoleOptions{
|
||||
|
@ -496,6 +496,7 @@ func TestClusterRoleValidate(t *testing.T) {
|
|||
|
||||
for name, test := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
test.clusterRoleOptions.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
|
||||
var err error
|
||||
test.clusterRoleOptions.Mapper, err = tf.ToRESTMapper()
|
||||
if err != nil {
|
||||
|
|
|
@ -294,7 +294,7 @@ func (o *CreateRoleOptions) Validate() error {
|
|||
|
||||
for _, v := range o.Verbs {
|
||||
if !arrayContains(validResourceVerbs, v) {
|
||||
return fmt.Errorf("invalid verb: '%s'", v)
|
||||
fmt.Fprintf(o.ErrOut, "Warning: '%s' is not a standard resource verb\n", v)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ func TestValidate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expectErr: false,
|
||||
},
|
||||
"test-nonresource-verb": {
|
||||
roleOptions: &CreateRoleOptions{
|
||||
|
@ -225,7 +225,7 @@ func TestValidate(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expectErr: true,
|
||||
expectErr: false,
|
||||
},
|
||||
"test-special-verb": {
|
||||
roleOptions: &CreateRoleOptions{
|
||||
|
@ -340,6 +340,8 @@ func TestValidate(t *testing.T) {
|
|||
}
|
||||
|
||||
for name, test := range tests {
|
||||
test.roleOptions.IOStreams = genericclioptions.NewTestIOStreamsDiscard()
|
||||
|
||||
var err error
|
||||
test.roleOptions.Mapper, err = tf.ToRESTMapper()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue