mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Add ControllerRoles Test
Added a test to check that if a controller role includes `List`, it also includes `Watch`. Signed-off-by: Mitsuru Kariya <mitsuru.kariya@nttdata.com>
This commit is contained in:
parent
019c9b4d2d
commit
7826934ada
@ -18,6 +18,7 @@ package bootstrappolicy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
@ -91,3 +92,15 @@ func TestControllerRoleLabel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestControllerRoleVerbsConsistensy(t *testing.T) {
|
||||||
|
roles := ControllerRoles()
|
||||||
|
for _, role := range roles {
|
||||||
|
for _, rule := range role.Rules {
|
||||||
|
verbs := rule.Verbs
|
||||||
|
if slices.Contains(verbs, "list") && !slices.Contains(verbs, "watch") {
|
||||||
|
t.Errorf("The ClusterRole %s has Verb `List` but does not have Verb `Watch`.", role.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user