func newLauncherRole(mpiJob *kubeflow.MPIJob, workerReplicas int) *rbacv1.Role {
	var podNames []string
	for i := 0; i < workerReplicas; i++ {
		podNames = append(podNames, fmt.Sprintf("%s%s-%d", mpiJob.Name, workerSuffix, i))
	}
	return &rbacv1.Role{
		ObjectMeta: metav1.ObjectMeta{
			Name:      mpiJob.Name + launcherSuffix,
			Namespace: mpiJob.Namespace,
			Labels: map[string]string{
				"app": mpiJob.Name,
			},
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(mpiJob, kubeflow.SchemeGroupVersionKind),
			},
		},
		Rules: []rbacv1.PolicyRule{
			{
				Verbs:         []string{"get"},
				APIGroups:     []string{""},
				Resources:     []string{"pods"},
				ResourceNames: podNames,
			},
			{
				Verbs:         []string{"create"},
				APIGroups:     []string{""},
				Resources:     []string{"pods/exec"},
				ResourceNames: podNames,
			},
		},
	}
}
// newLauncherRole creates a new launcher Role for an MPIJob resource. It also
// sets the appropriate OwnerReferences on the resource so handleObject can
// discover the MPIJob resource that 'owns' it.
newLauncherRole creates a new launcher Role for an MPIJob resource. It also
sets the appropriate OwnerReferences on the resource so handleObject can
discover the MPIJob resource that 'owns' it.
// newLauncherRole creates a new launcher Role for an MPIJob resource . It also // sets the appropriate OwnerReferences on the resource so handleObject can // discover the MPIJob resource that ' owns ' it .
func newLauncherRole(mpiJob *kubeflow.MPIJob, workerReplicas int) *rbacv1.Role {
	var podNames []string
	for i := 0; i < workerReplicas; i++ {
		podNames = append(podNames, fmt.Sprintf("%s%s-%d", mpiJob.Name, workerSuffix, i))
	}
	return &rbacv1.Role{
		ObjectMeta: metav1.ObjectMeta{
			Name:      mpiJob.Name + launcherSuffix,
			Namespace: mpiJob.Namespace,
			Labels: map[string]string{
				"app": mpiJob.Name,
			},
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(mpiJob, kubeflow.SchemeGroupVersionKind),
			},
		},
		Rules: []rbacv1.PolicyRule{
			{
				Verbs:         []string{"get"},
				APIGroups:     []string{""},
				Resources:     []string{"pods"},
				ResourceNames: podNames,
			},
			{
				Verbs:         []string{"create"},
				APIGroups:     []string{""},
				Resources:     []string{"pods/exec"},
				ResourceNames: podNames,
			},
		},
	}
}
func newLauncherRole ( mpiJob * kubeflow . MPIJob , workerReplicas int ) * rbacv1 . Role { var podNames [ ] string for i := 0 ; i < workerReplicas ; i ++ { podNames = append ( podNames , fmt . Sprintf ( " " , mpiJob . Name , workerSuffix , i ) ) } return & rbacv1 . Role { ObjectMeta : metav1 . ObjectMeta { Name : mpiJob . Name + launcherSuffix , Namespace : mpiJob . Namespace , Labels : map [ string ] string { " " : mpiJob . Name , } , OwnerReferences : [ ] metav1 . OwnerReference { * metav1 . NewControllerRef ( mpiJob , kubeflow . SchemeGroupVersionKind ) , } , } , Rules : [ ] rbacv1 . PolicyRule { { Verbs : [ ] string { " " } , APIGroups : [ ] string { " " } , Resources : [ ] string { " " } , ResourceNames : podNames , } , { Verbs : [ ] string { " " } , APIGroups : [ ] string { " " } , Resources : [ ] string { " " } , ResourceNames : podNames , } , } , } }
newLauncherRole creates a new launcher Role for an MPIJob resource.
newLauncherRole creates a new launcher Role for an MPIJob resource .