// Create the driver registrar cluster role if it doesn't exist, no teardown so that tests
// are parallelizable. This role will be shared with many of the CSI tests.
Create the driver registrar cluster role if it doesn't exist, no teardown so that tests
are parallelizable. This role will be shared with many of the CSI tests.
// Create the driver registrar cluster role if it doesn ' t exist no teardown so that tests // are parallelizable . This role will be shared with many of the CSI tests .
func csiDriverRegistrarClusterRole(
	config framework.VolumeTestConfig,
) *rbacv1.ClusterRole {
	By("Creating an impersonating superuser kubernetes clientset to define cluster role")
	rc, err := framework.LoadConfig()
	framework.ExpectNoError(err)
	rc.Impersonate = restclient.ImpersonationConfig{
		UserName: "superuser",
		Groups:   []string{"system:masters"},
	}
	superuserClientset, err := clientset.NewForConfig(rc)
	framework.ExpectNoError(err, "Failed to create superuser clientset: %v", err)
	By("Creating the CSI driver registrar cluster role")
	clusterRoleClient := superuserClientset.RbacV1().ClusterRoles()
	role := &rbacv1.ClusterRole{
		ObjectMeta: metav1.ObjectMeta{
			Name: csiDriverRegistrarClusterRoleName,
		},
		Rules: []rbacv1.PolicyRule{
			{
				APIGroups: []string{""},
				Resources: []string{"events"},
				Verbs:     []string{"get", "list", "watch", "create", "update", "patch"},
			},
			{
				APIGroups: []string{""},
				Resources: []string{"nodes"},
				Verbs:     []string{"get", "update", "patch"},
			},
		},
	}
	ret, err := clusterRoleClient.Create(role)
	if err != nil {
		if apierrs.IsAlreadyExists(err) {
			return ret
		}
		framework.ExpectNoError(err, "Failed to create %s cluster role: %v", role.GetName(), err)
	}
	return ret
}
func csiDriverRegistrarClusterRole ( config framework . VolumeTestConfig , ) * rbacv1 . ClusterRole { By ( " " ) rc , err := framework . LoadConfig ( ) framework . ExpectNoError ( err ) rc . Impersonate = restclient . ImpersonationConfig { UserName : " " , Groups : [ ] string { " " } , } superuserClientset , err := clientset . NewForConfig ( rc ) framework . ExpectNoError ( err , " " , err ) By ( " " ) clusterRoleClient := superuserClientset . RbacV1 ( ) . ClusterRoles ( ) role := & rbacv1 . ClusterRole { ObjectMeta : metav1 . ObjectMeta { Name : csiDriverRegistrarClusterRoleName , } , Rules : [ ] rbacv1 . PolicyRule { { APIGroups : [ ] string { " " } , Resources : [ ] string { " " } , Verbs : [ ] string { " " , " " , " " , " " , " " , " " } , } , { APIGroups : [ ] string { " " } , Resources : [ ] string { " " } , Verbs : [ ] string { " " , " " , " " } , } , } , } ret , err := clusterRoleClient . Create ( role ) if err != nil { if apierrs . IsAlreadyExists ( err ) { return ret } framework . ExpectNoError ( err , " " , role . GetName ( ) , err ) } return ret }
Create the driver registrar cluster role if it doesn't exist, no teardown so that tests
are parallelizable.
Create the driver registrar cluster role if it doesn ' t exist no teardown so that tests are parallelizable .
// TODO(Issue: #62237) Remove impersonation workaround and cluster role when issue resolved