Skip to content
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
6 changes: 2 additions & 4 deletions pkg/api/v1/custom_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package v1

import (
"go.mongodb.org/atlas/mongodbatlas"

"github.com/mongodb/mongodb-atlas-kubernetes/pkg/util/toptr"
)

type CustomRole struct {
Expand Down Expand Up @@ -47,8 +45,8 @@ func (in *CustomRole) ToAtlas() *mongodbatlas.CustomDBRole {
resources := make([]mongodbatlas.Resource, 0, len(action.Resources))

for _, resource := range action.Resources {
if resource.Cluster == nil {
resource.Cluster = toptr.MakePtr(false)
if resource.Cluster != nil && !*resource.Cluster {
resource.Cluster = nil
}
resources = append(resources, mongodbatlas.Resource{
Collection: resource.Collection,
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/v1/custom_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ func TestAtlasCustomRoles_ToAtlas(t *testing.T) {
Action: "testName",
Resources: []mongodbatlas.Resource{
{
Cluster: toptr.MakePtr(false),
Cluster: nil,
DB: toptr.MakePtr("testDB"),
Collection: toptr.MakePtr("testCollection"),
},
{
Cluster: toptr.MakePtr(false),
Cluster: nil,
DB: toptr.MakePtr("testDB2"),
Collection: toptr.MakePtr("testCollection2"),
},
Expand All @@ -99,7 +99,7 @@ func TestAtlasCustomRoles_ToAtlas(t *testing.T) {
Action: "testName3",
Resources: []mongodbatlas.Resource{
{
Cluster: toptr.MakePtr(false),
Cluster: nil,
DB: toptr.MakePtr(""),
Collection: toptr.MakePtr(""),
},
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/atlasproject/custom_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"

"github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/v1/status"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/util/toptr"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand Down Expand Up @@ -74,8 +73,8 @@ func fetchCustomRoles(ctx *workflow.Context, projectID string) ([]v1.CustomRole,
resources := make([]v1.Resource, 0, len(atlasAction.Resources))

for _, atlasResource := range atlasAction.Resources {
if atlasResource.Cluster == nil {
atlasResource.Cluster = toptr.MakePtr(false)
if atlasResource.Cluster != nil && !*atlasResource.Cluster {
atlasResource.Cluster = nil
}
resources = append(resources, v1.Resource{
Cluster: atlasResource.Cluster,
Expand Down
1 change: 1 addition & 0 deletions test/int/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var _ = Describe("AtlasProject", Label("int", "AtlasProject"), func() {
AfterEach(func() {
if createdProject != nil && createdProject.Status.ID != "" {
By("Removing Atlas Project " + createdProject.Status.ID)
Expect(k8sClient.Get(context.Background(), kube.ObjectKeyFromObject(createdProject), createdProject)).To(Succeed())
Expect(k8sClient.Delete(context.Background(), createdProject)).To(Succeed())
Eventually(checkAtlasProjectRemoved(createdProject.Status.ID), 20, interval).Should(BeTrue())
}
Expand Down