Skip to content

Commit

Permalink
CLOUDP-286489: Atlas Search now works with the new API (#1956)
Browse files Browse the repository at this point in the history
Atlas Search now works with the new API

Co-authored-by: jose.vazquez <jose.vazquez@mongodb.com>
  • Loading branch information
igor-karpukhin and josvazg authored Dec 4, 2024
1 parent ac59f95 commit 9f40e55
Show file tree
Hide file tree
Showing 18 changed files with 651 additions and 488 deletions.
2 changes: 1 addition & 1 deletion .licenses-gomod.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100644 44fd0d244f4208cddd503d82323872f245a6730e go.mod
100644 518dae515a8b5e7a840a7382feabb289d1aafb9a go.mod
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
go.mongodb.org/atlas v0.37.0
go.mongodb.org/atlas-sdk/v20231115004 v20231115004.1.0
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0
go.mongodb.org/atlas-sdk/v20241113001 v20241113001.0.0
go.mongodb.org/mongo-driver v1.17.1
go.uber.org/zap v1.27.0
golang.org/x/sync v0.9.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ go.mongodb.org/atlas-sdk/v20231115004 v20231115004.1.0 h1:vOvfk8bPedcphaTHIm6p8U
go.mongodb.org/atlas-sdk/v20231115004 v20231115004.1.0/go.mod h1:FzD5DLz+WPB+z3OGgNBjXMPQJjJ7Y+hKn4iupXZuoOc=
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0 h1:OuV1HfIpZUZa4+BKvtrvDlNqnilkCkdHspuZok6KAbM=
go.mongodb.org/atlas-sdk/v20231115008 v20231115008.5.0/go.mod h1:0707RpWIrNFZ6Msy/dwRDCzC5JVDon61JoOqcbfCujg=
go.mongodb.org/atlas-sdk/v20241113001 v20241113001.0.0 h1:G3UZcWwWziGUuaILWp/Gc+jLm1tfu7OUhUOpMWVZSWc=
go.mongodb.org/atlas-sdk/v20241113001 v20241113001.0.0/go.mod h1:fMiUyCacIAm+XwFkJ4j+rJtYLRsGU7hButtgGv+SBU4=
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
Expand Down
15 changes: 11 additions & 4 deletions internal/mocks/atlas/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package atlas
import (
"context"

"github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/controller/atlas"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas/mongodbatlas"
"go.uber.org/zap"
Expand All @@ -12,10 +14,11 @@ import (
)

type TestProvider struct {
ClientFunc func(secretRef *client.ObjectKey, log *zap.SugaredLogger) (*mongodbatlas.Client, string, error)
SdkClientFunc func(secretRef *client.ObjectKey, log *zap.SugaredLogger) (*admin.APIClient, string, error)
IsCloudGovFunc func() bool
IsSupportedFunc func() bool
ClientFunc func(secretRef *client.ObjectKey, log *zap.SugaredLogger) (*mongodbatlas.Client, string, error)
SdkClientFunc func(secretRef *client.ObjectKey, log *zap.SugaredLogger) (*admin.APIClient, string, error)
SdkSetClientFunc func(secretRef *client.ObjectKey, log *zap.SugaredLogger) (*atlas.ClientSet, string, error)
IsCloudGovFunc func() bool
IsSupportedFunc func() bool
}

func (f *TestProvider) Client(_ context.Context, secretRef *client.ObjectKey, log *zap.SugaredLogger) (*mongodbatlas.Client, string, error) {
Expand All @@ -30,6 +33,10 @@ func (f *TestProvider) IsCloudGov() bool {
return f.IsCloudGovFunc()
}

func (f *TestProvider) SdkClientSet(ctx context.Context, secretRef *client.ObjectKey, log *zap.SugaredLogger) (*atlas.ClientSet, string, error) {
return f.SdkSetClientFunc(secretRef, log)
}

func (f *TestProvider) IsResourceSupported(_ api.AtlasCustomResource) bool {
return f.IsSupportedFunc()
}
6 changes: 3 additions & 3 deletions internal/translation/searchindex/searchIndexsvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"net/http"

"go.mongodb.org/atlas-sdk/v20231115008/admin"
"go.mongodb.org/atlas-sdk/v20241113001/admin"
)

var (
Expand Down Expand Up @@ -50,7 +50,7 @@ func (si *SearchIndexes) GetIndex(ctx context.Context, projectID, clusterName, i
}

func (si *SearchIndexes) CreateIndex(ctx context.Context, projectID, clusterName string, index *SearchIndex) (*SearchIndex, error) {
atlasIndex, err := index.toAtlas()
atlasIndex, err := index.toAtlasCreateView()
if err != nil {
return nil, err
}
Expand All @@ -77,7 +77,7 @@ func (si *SearchIndexes) DeleteIndex(ctx context.Context, projectID, clusterName
}

func (si *SearchIndexes) UpdateIndex(ctx context.Context, projectID, clusterName string, index *SearchIndex) (*SearchIndex, error) {
atlasIndex, err := index.toAtlas()
atlasIndex, err := index.toAtlasUpdateView()
if err != nil {
return nil, fmt.Errorf("error converting index: %w", err)
}
Expand Down
Loading

0 comments on commit 9f40e55

Please sign in to comment.