Skip to content

Commit f4b7fb3

Browse files
CLOUDP-177525: Migrate operator to new sdk at store/atlas (#2337)
Signed-off-by: Jose Vazquez <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 149df3f commit f4b7fb3

File tree

85 files changed

+5306
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5306
-481
lines changed

internal/cli/atlas/datafederation/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (opts *ListOpts) initStore(ctx context.Context) func() error {
5050
}
5151

5252
func (opts *ListOpts) Run() error {
53-
r, err := opts.store.DataFederationList(opts.ConfigProjectID(), opts.typeFlag)
53+
r, err := opts.store.DataFederationList(opts.ConfigProjectID())
5454
if err != nil {
5555
return err
5656
}

internal/cli/atlas/datafederation/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestListOpts_Run(t *testing.T) {
5353

5454
mockStore.
5555
EXPECT().
56-
DataFederationList(listOpts.ProjectID, listOpts.typeFlag).
56+
DataFederationList(listOpts.ProjectID).
5757
Return(expected, nil).
5858
Times(1)
5959

internal/cli/atlas/kubernetes/config/generate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/crds"
2727
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/features"
2828
"github.com/mongodb/mongodb-atlas-cli/internal/store"
29+
"github.com/mongodb/mongodb-atlas-cli/internal/store/atlas"
2930
"github.com/mongodb/mongodb-atlas-cli/internal/usage"
3031
"github.com/spf13/cobra"
3132
"k8s.io/apimachinery/pkg/util/validation"
@@ -41,7 +42,7 @@ type GenerateOpts struct {
4142
includeSecrets bool
4243
targetNamespace string
4344
operatorVersion string
44-
store store.AtlasOperatorGenericStore
45+
store atlas.OperatorGenericStore
4546
credsStore store.CredentialsGetter
4647
crdsProvider crds.AtlasOperatorCRDProvider
4748
}
@@ -65,7 +66,7 @@ func (opts *GenerateOpts) initStores(ctx context.Context) func() error {
6566
var err error
6667

6768
profile := config.Default()
68-
opts.store, err = store.New(store.AuthenticatedPreset(profile), store.WithContext(ctx))
69+
opts.store, err = atlas.New(atlas.AuthenticatedPreset(profile), atlas.WithContext(ctx))
6970
if err != nil {
7071
return err
7172
}

internal/cli/atlas/kubernetes/operator/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/crds"
2929
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/features"
3030
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/version"
31-
"github.com/mongodb/mongodb-atlas-cli/internal/store"
31+
"github.com/mongodb/mongodb-atlas-cli/internal/store/atlas"
3232
"github.com/mongodb/mongodb-atlas-cli/internal/usage"
3333
"github.com/spf13/cobra"
3434
"k8s.io/apimachinery/pkg/util/validation"
@@ -109,7 +109,7 @@ func (opts *InstallOpts) Run(ctx context.Context) error {
109109
installer := operator.NewInstaller(opts.versionProvider, kubeCtl)
110110

111111
profile := config.Default()
112-
atlasStore, err := store.New(store.AuthenticatedPreset(profile), store.WithContext(ctx))
112+
atlasStore, err := atlas.New(atlas.AuthenticatedPreset(profile), atlas.WithContext(ctx))
113113
if err != nil {
114114
return err
115115
}

internal/cli/atlas/projects/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (opts *ListOpts) initStore(ctx context.Context) func() error {
4747
}
4848

4949
func (opts *ListOpts) Run() error {
50-
listOptions := opts.NewListOptions()
50+
listOptions := opts.NewAtlasListOptions()
5151
var r interface{}
5252
var err error
5353
if opts.OrgID != "" {

internal/cli/atlas/projects/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestList_Run(t *testing.T) {
3737
}
3838
mockStore.
3939
EXPECT().
40-
Projects(listOpts.NewListOptions()).
40+
Projects(listOpts.NewAtlasListOptions()).
4141
Return(expected, nil).
4242
Times(1)
4343

@@ -54,7 +54,7 @@ func TestList_Run(t *testing.T) {
5454

5555
mockStore.
5656
EXPECT().
57-
GetOrgProjects(listOpts.OrgID, listOpts.NewListOptions()).
57+
GetOrgProjects(listOpts.OrgID, listOpts.NewAtlasListOptions()).
5858
Return(expected, nil).
5959
Times(1)
6060

internal/cli/atlas/projects/users/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (opts *ListOpts) initStore(ctx context.Context) func() error {
4848
}
4949

5050
func (opts *ListOpts) Run() error {
51-
listOptions := opts.NewListOptions()
51+
listOptions := opts.NewAtlasListOptions()
5252

5353
r, err := opts.store.ProjectUsers(opts.ConfigProjectID(), listOptions)
5454
if err != nil {

internal/cli/atlas/projects/users/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestList_Run(t *testing.T) {
4343

4444
mockStore.
4545
EXPECT().
46-
ProjectUsers(listOpts.ProjectID, listOpts.NewListOptions()).
46+
ProjectUsers(listOpts.ProjectID, listOpts.NewAtlasListOptions()).
4747
Return(&expected, nil).
4848
Times(1)
4949

internal/cli/list_opts.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414

1515
package cli
1616

17-
import "go.mongodb.org/atlas/mongodbatlas"
17+
import (
18+
"github.com/mongodb/mongodb-atlas-cli/internal/store/atlas"
19+
"go.mongodb.org/atlas/mongodbatlas"
20+
)
1821

1922
const (
2023
DefaultPage = 1
@@ -32,3 +35,10 @@ func (opts *ListOpts) NewListOptions() *mongodbatlas.ListOptions {
3235
ItemsPerPage: opts.ItemsPerPage,
3336
}
3437
}
38+
39+
func (opts *ListOpts) NewAtlasListOptions() *atlas.ListOptions {
40+
return &atlas.ListOptions{
41+
PageNum: opts.PageNum,
42+
ItemsPerPage: opts.ItemsPerPage,
43+
}
44+
}

internal/kubernetes/operator/config_exporter.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/project"
2828
"github.com/mongodb/mongodb-atlas-cli/internal/kubernetes/operator/resources"
2929
"github.com/mongodb/mongodb-atlas-cli/internal/store"
30+
"github.com/mongodb/mongodb-atlas-cli/internal/store/atlas"
3031
atlasv2 "go.mongodb.org/atlas-sdk/v20230201008/admin"
31-
"go.mongodb.org/atlas/mongodbatlas"
3232
"k8s.io/apimachinery/pkg/runtime"
3333
"k8s.io/apimachinery/pkg/runtime/serializer/json"
3434
"k8s.io/client-go/kubernetes/scheme"
@@ -42,7 +42,7 @@ const (
4242

4343
type ConfigExporter struct {
4444
featureValidator features.FeatureValidator
45-
dataProvider store.AtlasOperatorGenericStore
45+
dataProvider atlas.OperatorGenericStore
4646
credsProvider store.CredentialsGetter
4747
projectID string
4848
clusterNames []string
@@ -59,7 +59,7 @@ var (
5959
ErrNoCloudManagerClusters = errors.New("can not get 'advanced clusters' object")
6060
)
6161

62-
func NewConfigExporter(dataProvider store.AtlasOperatorGenericStore, credsProvider store.CredentialsGetter, projectID, orgID string) *ConfigExporter {
62+
func NewConfigExporter(dataProvider atlas.OperatorGenericStore, credsProvider store.CredentialsGetter, projectID, orgID string) *ConfigExporter {
6363
return &ConfigExporter{
6464
dataProvider: dataProvider,
6565
credsProvider: credsProvider,
@@ -226,9 +226,9 @@ func (e *ConfigExporter) exportDeployments(projectName string) ([]runtime.Object
226226
return result, nil
227227
}
228228

229-
func fetchClusterNames(clustersProvider store.AtlasAllClustersLister, projectID string) ([]string, error) {
229+
func fetchClusterNames(clustersProvider atlas.AllClustersLister, projectID string) ([]string, error) {
230230
result := make([]string, 0, DefaultClustersCount)
231-
response, err := clustersProvider.ProjectClusters(projectID, &mongodbatlas.ListOptions{ItemsPerPage: maxClusters})
231+
response, err := clustersProvider.ProjectClusters(projectID, &atlas.ListOptions{ItemsPerPage: maxClusters})
232232
if err != nil {
233233
return nil, err
234234
}
@@ -247,7 +247,7 @@ func fetchClusterNames(clustersProvider store.AtlasAllClustersLister, projectID
247247
}
248248
}
249249

250-
serverlessInstances, err := clustersProvider.ServerlessInstances(projectID, &mongodbatlas.ListOptions{ItemsPerPage: maxClusters})
250+
serverlessInstances, err := clustersProvider.ServerlessInstances(projectID, &atlas.ListOptions{ItemsPerPage: maxClusters})
251251
if err != nil {
252252
return nil, err
253253
}

0 commit comments

Comments
 (0)