Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pointers in Redefine funcs #668

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/globalhelper/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func deleteServiceAccount(client corev1Typed.CoreV1Interface, serviceAccountName
return nil
}

func DefineRole(roleName, namespace string) rbacv1.Role {
return rbacv1.Role{
func DefineRole(roleName, namespace string) *rbacv1.Role {
return &rbacv1.Role{
TypeMeta: metav1.TypeMeta{
Kind: "Role",
APIVersion: "v1",
Expand All @@ -84,22 +84,22 @@ func DefineRole(roleName, namespace string) rbacv1.Role {
}
}

func RedefineRoleWithAPIGroups(role rbacv1.Role, newAPIGroups []string) {
func RedefineRoleWithAPIGroups(role *rbacv1.Role, newAPIGroups []string) {
role.Rules[0].APIGroups = newAPIGroups
}

func RedefineRoleWithResources(role rbacv1.Role, newResources []string) {
func RedefineRoleWithResources(role *rbacv1.Role, newResources []string) {
role.Rules[0].Resources = newResources
}

// CreateRole creates a role.
func CreateRole(aRole rbacv1.Role) error {
func CreateRole(aRole *rbacv1.Role) error {
return createRole(GetAPIClient().K8sClient.RbacV1(), aRole)
}

func createRole(client rbacv1Typed.RbacV1Interface, aRole rbacv1.Role) error {
func createRole(client rbacv1Typed.RbacV1Interface, aRole *rbacv1.Role) error {
_, err :=
client.Roles(aRole.Namespace).Create(context.TODO(), &aRole, metav1.CreateOptions{})
client.Roles(aRole.Namespace).Create(context.TODO(), aRole, metav1.CreateOptions{})

if k8serrors.IsAlreadyExists(err) {
glog.V(5).Info(fmt.Sprintf("role %s already installed", aRole.Name))
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/crd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func DefineCustomResource(name, namespace, operatorLabels string, operatorLabels
}
}

func RedefineCustomResourceWithReplica(aCustomResource crscaleoperator.Memcached, replicas int) {
func RedefineCustomResourceWithReplica(aCustomResource *crscaleoperator.Memcached, replicas int) {
aCustomResource.Spec.Size = int32(replicas)
}

Expand Down
Loading