Skip to content

Commit 811c672

Browse files
author
Gustavo Bazan
authored
task: clean some references to the old atlas client (#2377)
1 parent d674614 commit 811c672

13 files changed

+28
-268
lines changed

internal/cli/iam/organizations/create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323
"github.com/mongodb/mongodb-atlas-cli/internal/flag"
2424
"github.com/mongodb/mongodb-atlas-cli/internal/mocks"
2525
"github.com/mongodb/mongodb-atlas-cli/internal/test"
26-
"go.mongodb.org/atlas/mongodbatlas"
26+
"go.mongodb.org/ops-manager/opsmngr"
2727
)
2828

2929
func TestCreate_Run(t *testing.T) {
3030
ctrl := gomock.NewController(t)
3131
mockStore := mocks.NewMockOrganizationCreator(ctrl)
3232

33-
expected := &mongodbatlas.Organization{}
33+
expected := &opsmngr.Organization{}
3434

3535
mockStore.
3636
EXPECT().

internal/cli/iam/organizations/describe_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ import (
2525
"github.com/mongodb/mongodb-atlas-cli/internal/mocks"
2626
"github.com/mongodb/mongodb-atlas-cli/internal/test"
2727
"github.com/stretchr/testify/assert"
28-
atlas "go.mongodb.org/atlas/mongodbatlas"
28+
"go.mongodb.org/ops-manager/opsmngr"
2929
)
3030

3131
func TestDescribe_Run(t *testing.T) {
3232
ctrl := gomock.NewController(t)
3333
mockStore := mocks.NewMockOrganizationDescriber(ctrl)
3434
stringVal := "test"
35-
expected := &atlas.Organization{
35+
expected := &opsmngr.Organization{
3636
Links: nil,
3737
ID: stringVal,
3838
Name: stringVal,

internal/cli/iam/organizations/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/mongodb/mongodb-atlas-cli/internal/usage"
2727
"github.com/spf13/cobra"
2828
atlas "go.mongodb.org/atlas/mongodbatlas"
29+
"go.mongodb.org/ops-manager/opsmngr"
2930
)
3031

3132
const listTemplate = `ID NAME{{range .Results}}
@@ -57,7 +58,7 @@ func (opts *ListOpts) Run() error {
5758
return opts.Print(r)
5859
}
5960

60-
func (opts *ListOpts) newOrganizationListOptions() *atlas.OrganizationsListOptions {
61+
func (opts *ListOpts) newOrganizationListOptions() *opsmngr.OrganizationsListOptions {
6162
return &atlas.OrganizationsListOptions{
6263
Name: opts.name,
6364
IncludeDeletedOrgs: &opts.includeDeletedOrgs,

internal/cli/parse_service_version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818
"strings"
1919

2020
"github.com/Masterminds/semver/v3"
21-
atlas "go.mongodb.org/atlas/mongodbatlas"
21+
"go.mongodb.org/ops-manager/opsmngr"
2222
)
2323

2424
// ParseServiceVersion parses service version into semver.Version.
25-
func ParseServiceVersion(v *atlas.ServiceVersion) (*semver.Version, error) {
25+
func ParseServiceVersion(v *opsmngr.ServiceVersion) (*semver.Version, error) {
2626
versionParts := strings.Split(v.Version, ".")
2727

2828
const maxVersionParts = 2

internal/cli/parse_service_version_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,43 @@ package cli
1919
import (
2020
"testing"
2121

22-
"go.mongodb.org/atlas/mongodbatlas"
22+
"go.mongodb.org/ops-manager/opsmngr"
2323
)
2424

2525
func TestParseServiceVersion(t *testing.T) {
2626
tests := []struct {
2727
name string
28-
serviceVersion *mongodbatlas.ServiceVersion
28+
serviceVersion *opsmngr.ServiceVersion
2929
expected string
3030
wantErr bool
3131
}{
3232
{
3333
name: "OM 5.0",
34-
serviceVersion: &mongodbatlas.ServiceVersion{Version: "5.0.0.100.20210101T0000Z"},
34+
serviceVersion: &opsmngr.ServiceVersion{Version: "5.0.0.100.20210101T0000Z"},
3535
expected: "5.0.0",
3636
wantErr: false,
3737
},
3838
{
3939
name: "OM 5.0-rc1",
40-
serviceVersion: &mongodbatlas.ServiceVersion{Version: "5.0.0-rc1.100.20210101T0000Z"},
40+
serviceVersion: &opsmngr.ServiceVersion{Version: "5.0.0-rc1.100.20210101T0000Z"},
4141
expected: "5.0.0",
4242
wantErr: false,
4343
},
4444
{
4545
name: "OM 5.0.1",
46-
serviceVersion: &mongodbatlas.ServiceVersion{Version: "5.0.1.100.20210101T0000Z"},
46+
serviceVersion: &opsmngr.ServiceVersion{Version: "5.0.1.100.20210101T0000Z"},
4747
expected: "5.0.0",
4848
wantErr: false,
4949
},
5050
{
5151
name: "master",
52-
serviceVersion: &mongodbatlas.ServiceVersion{Version: "master"},
52+
serviceVersion: &opsmngr.ServiceVersion{Version: "master"},
5353
expected: "",
5454
wantErr: true,
5555
},
5656
{
5757
name: "v20210101",
58-
serviceVersion: &mongodbatlas.ServiceVersion{Version: "v20210101"},
58+
serviceVersion: &opsmngr.ServiceVersion{Version: "v20210101"},
5959
expected: "20210101.0.0",
6060
wantErr: false,
6161
},

internal/store/agents.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ import (
1818
"fmt"
1919

2020
"github.com/mongodb/mongodb-atlas-cli/internal/config"
21-
atlas "go.mongodb.org/atlas/mongodbatlas"
2221
"go.mongodb.org/ops-manager/opsmngr"
2322
)
2423

2524
//go:generate mockgen -destination=../mocks/mock_agents.go -package=mocks github.com/mongodb/mongodb-atlas-cli/internal/store AgentLister,AgentUpgrader,AgentAPIKeyLister,AgentAPIKeyCreator,AgentAPIKeyDeleter,AgentGlobalVersionsLister,AgentProjectVersionsLister
2625

2726
type AgentLister interface {
28-
Agents(string, string, *atlas.ListOptions) (*opsmngr.Agents, error)
27+
Agents(string, string, *opsmngr.ListOptions) (*opsmngr.Agents, error)
2928
}
3029

3130
type AgentGlobalVersionsLister interface {
@@ -53,7 +52,7 @@ type AgentAPIKeyDeleter interface {
5352
}
5453

5554
// Agents encapsulates the logic to manage different cloud providers.
56-
func (s *Store) Agents(projectID, agentType string, opts *atlas.ListOptions) (*opsmngr.Agents, error) {
55+
func (s *Store) Agents(projectID, agentType string, opts *opsmngr.ListOptions) (*opsmngr.Agents, error) {
5756
switch s.service {
5857
case config.OpsManagerService, config.CloudManagerService:
5958
result, _, err := s.client.(*opsmngr.Client).Agents.ListAgentsByType(s.ctx, projectID, agentType, opts)
@@ -107,7 +106,7 @@ func (s *Store) DeleteAgentAPIKey(projectID, keyID string) error {
107106
}
108107
}
109108

110-
// Agents encapsulates the logic to manage different cloud providers.
109+
// AgentGlobalVersions encapsulates the logic to manage different cloud providers.
111110
func (s *Store) AgentGlobalVersions() (*opsmngr.SoftwareVersions, error) {
112111
switch s.service {
113112
case config.OpsManagerService:
@@ -118,7 +117,7 @@ func (s *Store) AgentGlobalVersions() (*opsmngr.SoftwareVersions, error) {
118117
}
119118
}
120119

121-
// Agents encapsulates the logic to manage different cloud providers.
120+
// AgentProjectVersions encapsulates the logic to manage different cloud providers.
122121
func (s *Store) AgentProjectVersions(projectID string) (*opsmngr.AgentVersions, error) {
123122
switch s.service {
124123
case config.OpsManagerService, config.CloudManagerService:

internal/store/alert_configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
//go:generate mockgen -destination=../mocks/mock_alert_configuration.go -package=mocks github.com/mongodb/mongodb-atlas-cli/internal/store AlertConfigurationLister,AlertConfigurationCreator,AlertConfigurationDeleter,AlertConfigurationUpdater,MatcherFieldsLister,AlertConfigurationEnabler,AlertConfigurationDisabler
2727

2828
type AlertConfigurationLister interface {
29-
AlertConfigurations(string, *atlas.ListOptions) ([]atlas.AlertConfiguration, error)
29+
AlertConfigurations(string, *opsmngr.ListOptions) ([]atlas.AlertConfiguration, error)
3030
}
3131

3232
type AlertConfigurationCreator interface {

internal/store/alerts.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,20 @@ import (
2525
//go:generate mockgen -destination=../mocks/mock_alerts.go -package=mocks github.com/mongodb/mongodb-atlas-cli/internal/store AlertDescriber,AlertLister,AlertAcknowledger
2626

2727
type AlertDescriber interface {
28-
Alert(string, string) (*atlas.Alert, error)
28+
Alert(string, string) (*opsmngr.Alert, error)
2929
}
3030

3131
type AlertLister interface {
32-
Alerts(string, *atlas.AlertsListOptions) (*atlas.AlertsResponse, error)
32+
Alerts(string, *opsmngr.AlertsListOptions) (*atlas.AlertsResponse, error)
3333
}
3434

3535
type AlertAcknowledger interface {
36-
AcknowledgeAlert(string, string, *atlas.AcknowledgeRequest) (*atlas.Alert, error)
36+
AcknowledgeAlert(string, string, *opsmngr.AcknowledgeRequest) (*atlas.Alert, error)
3737
}
3838

3939
// Alert encapsulate the logic to manage different cloud providers.
4040
func (s *Store) Alert(projectID, alertID string) (*atlas.Alert, error) {
4141
switch s.service {
42-
case config.CloudService, config.CloudGovService:
43-
result, _, err := s.client.(*atlas.Client).Alerts.Get(s.ctx, projectID, alertID)
44-
return result, err
4542
case config.OpsManagerService, config.CloudManagerService:
4643
result, _, err := s.client.(*opsmngr.Client).Alerts.Get(s.ctx, projectID, alertID)
4744
return result, err
@@ -51,11 +48,8 @@ func (s *Store) Alert(projectID, alertID string) (*atlas.Alert, error) {
5148
}
5249

5350
// Alerts encapsulate the logic to manage different cloud providers.
54-
func (s *Store) Alerts(projectID string, opts *atlas.AlertsListOptions) (*atlas.AlertsResponse, error) {
51+
func (s *Store) Alerts(projectID string, opts *opsmngr.AlertsListOptions) (*opsmngr.AlertsResponse, error) {
5552
switch s.service {
56-
case config.CloudService, config.CloudGovService:
57-
result, _, err := s.client.(*atlas.Client).Alerts.List(s.ctx, projectID, opts)
58-
return result, err
5953
case config.OpsManagerService, config.CloudManagerService:
6054
result, _, err := s.client.(*opsmngr.Client).Alerts.List(s.ctx, projectID, opts)
6155
return result, err
@@ -65,11 +59,8 @@ func (s *Store) Alerts(projectID string, opts *atlas.AlertsListOptions) (*atlas.
6559
}
6660

6761
// Acknowledge encapsulate the logic to manage different cloud providers.
68-
func (s *Store) AcknowledgeAlert(projectID, alertID string, body *atlas.AcknowledgeRequest) (*atlas.Alert, error) {
62+
func (s *Store) AcknowledgeAlert(projectID, alertID string, body *opsmngr.AcknowledgeRequest) (*atlas.Alert, error) {
6963
switch s.service {
70-
case config.CloudService, config.CloudGovService:
71-
result, _, err := s.client.(*atlas.Client).Alerts.Acknowledge(s.ctx, projectID, alertID, body)
72-
return result, err
7364
case config.OpsManagerService, config.CloudManagerService:
7465
result, _, err := s.client.(*opsmngr.Client).Alerts.Acknowledge(s.ctx, projectID, alertID, body)
7566
return result, err

internal/store/api_keys_access_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
//go:generate mockgen -destination=../mocks/mock_api_keys_access_list.go -package=mocks github.com/mongodb/mongodb-atlas-cli/internal/store OrganizationAPIKeyAccessListCreator,OrganizationAPIKeyAccessListDeleter,OrganizationAPIKeyAccessListLister
2626

2727
type OrganizationAPIKeyAccessListLister interface {
28-
OrganizationAPIKeyAccessLists(string, string, *atlas.ListOptions) (*atlas.AccessListAPIKeys, error)
28+
OrganizationAPIKeyAccessLists(string, string, *opsmngr.ListOptions) (*atlas.AccessListAPIKeys, error)
2929
}
3030

3131
type OrganizationAPIKeyAccessListDeleter interface {

internal/store/backup_configs.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"fmt"
1919

2020
"github.com/mongodb/mongodb-atlas-cli/internal/config"
21-
atlas "go.mongodb.org/atlas/mongodbatlas"
2221
"go.mongodb.org/ops-manager/opsmngr"
2322
)
2423

@@ -29,7 +28,7 @@ type BackupConfigGetter interface {
2928
}
3029

3130
type BackupConfigLister interface {
32-
ListBackupConfigs(string, *atlas.ListOptions) (*opsmngr.BackupConfigs, error)
31+
ListBackupConfigs(string, *opsmngr.ListOptions) (*opsmngr.BackupConfigs, error)
3332
}
3433

3534
type BackupConfigUpdater interface {
@@ -48,7 +47,7 @@ func (s *Store) GetBackupConfig(projectID, clusterID string) (*opsmngr.BackupCon
4847
}
4948

5049
// ListBackupConfigs encapsulates the logic to manage different cloud providers.
51-
func (s *Store) ListBackupConfigs(projectID string, options *atlas.ListOptions) (*opsmngr.BackupConfigs, error) {
50+
func (s *Store) ListBackupConfigs(projectID string, options *opsmngr.ListOptions) (*opsmngr.BackupConfigs, error) {
5251
switch s.service {
5352
case config.CloudManagerService, config.OpsManagerService:
5453
result, _, err := s.client.(*opsmngr.Client).BackupConfigs.List(s.ctx, projectID, options)

0 commit comments

Comments
 (0)