diff --git a/go.mod b/go.mod index 6a3da1088d..28381652a9 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/tangzero/inflector v1.0.0 go.mongodb.org/atlas v0.36.0 go.mongodb.org/mongo-driver v1.14.0 - go.mongodb.org/ops-manager v0.55.3 + go.mongodb.org/ops-manager v0.55.5 golang.org/x/crypto v0.21.0 golang.org/x/mod v0.16.0 golang.org/x/tools v0.19.0 diff --git a/go.sum b/go.sum index ad417e6498..7b692633ea 100644 --- a/go.sum +++ b/go.sum @@ -212,8 +212,8 @@ go.mongodb.org/atlas v0.36.0 h1:m05S3AO7zkl+bcG1qaNsEKBnAqnKx2FDwLooHpIG3j4= go.mongodb.org/atlas v0.36.0/go.mod h1:nfPldE9dSama6G2IbIzmEza02Ly7yFZjMMVscaM0uEc= go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= -go.mongodb.org/ops-manager v0.55.3 h1:ZckNLra9XfvUxWgRfdCVOr7QkeCPi7S4VNbcK5di/2A= -go.mongodb.org/ops-manager v0.55.3/go.mod h1:3KAtjSrHt4KB0mWLDRDlQpiyZypB+4EX9XXjx3gN5PA= +go.mongodb.org/ops-manager v0.55.5 h1:MA6ATGRPg6SYzX7IzmiBcTEVISxmEvrIFTlKMy1y4SQ= +go.mongodb.org/ops-manager v0.55.5/go.mod h1:cckwuzkMX8+bKLnXOb5IO1uhDZzC0B3vPQURXLjoc18= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= diff --git a/internal/cli/iam/organizations/invitations/describe_test.go b/internal/cli/iam/organizations/invitations/describe_test.go index 25b4c8d9e2..fd2719b531 100644 --- a/internal/cli/iam/organizations/invitations/describe_test.go +++ b/internal/cli/iam/organizations/invitations/describe_test.go @@ -23,7 +23,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestDescribe_Run(t *testing.T) { @@ -38,7 +38,7 @@ func TestDescribe_Run(t *testing.T) { mockStore. EXPECT(). OrganizationInvitation(opts.ConfigOrgID(), opts.id). - Return(&mongodbatlas.Invitation{}, nil). + Return(&opsmngr.Invitation{}, nil). Times(1) if err := opts.Run(); err != nil { diff --git a/internal/cli/iam/organizations/invitations/invite.go b/internal/cli/iam/organizations/invitations/invite.go index 5b993bed56..b47ea19e05 100644 --- a/internal/cli/iam/organizations/invitations/invite.go +++ b/internal/cli/iam/organizations/invitations/invite.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const createTemplate = "User '{{.Username}}' invited.\n" @@ -57,8 +57,8 @@ func (opts *InviteOpts) Run() error { return opts.Print(r) } -func (opts *InviteOpts) newInvitation() *atlas.Invitation { - return &atlas.Invitation{ +func (opts *InviteOpts) newInvitation() *opsmngr.Invitation { + return &opsmngr.Invitation{ Username: opts.username, Roles: opts.roles, TeamIDs: opts.teamIDs, diff --git a/internal/cli/iam/organizations/invitations/invite_test.go b/internal/cli/iam/organizations/invitations/invite_test.go index 68a7cb9411..32e3e68a01 100644 --- a/internal/cli/iam/organizations/invitations/invite_test.go +++ b/internal/cli/iam/organizations/invitations/invite_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestCreate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockOrganizationInviter(ctrl) - expected := &mongodbatlas.Invitation{} + expected := &opsmngr.Invitation{} opts := &InviteOpts{ store: mockStore, username: "test", diff --git a/internal/cli/iam/organizations/invitations/list.go b/internal/cli/iam/organizations/invitations/list.go index 192cb802f1..ff1953f462 100644 --- a/internal/cli/iam/organizations/invitations/list.go +++ b/internal/cli/iam/organizations/invitations/list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const listTemplate = `ID USERNAME CREATED AT EXPIRES AT{{range valueOrEmptySlice .}} @@ -55,8 +55,8 @@ func (opts *ListOpts) Run() error { return opts.Print(r) } -func (opts *ListOpts) newInvitationOptions() *atlas.InvitationOptions { - return &atlas.InvitationOptions{ +func (opts *ListOpts) newInvitationOptions() *opsmngr.InvitationOptions { + return &opsmngr.InvitationOptions{ Username: opts.username, } } diff --git a/internal/cli/iam/organizations/invitations/list_test.go b/internal/cli/iam/organizations/invitations/list_test.go index 0589bf9f9f..e4d8cf832d 100644 --- a/internal/cli/iam/organizations/invitations/list_test.go +++ b/internal/cli/iam/organizations/invitations/list_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockOrganizationInvitationLister(ctrl) - var expected []*mongodbatlas.Invitation + var expected []*opsmngr.Invitation listOpts := &ListOpts{store: mockStore} diff --git a/internal/cli/iam/organizations/invitations/update.go b/internal/cli/iam/organizations/invitations/update.go index ddb198fcb7..4def5f782b 100644 --- a/internal/cli/iam/organizations/invitations/update.go +++ b/internal/cli/iam/organizations/invitations/update.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const updateTemplate = "Invitation {{.ID}} updated.\n" @@ -56,8 +56,8 @@ func (opts *UpdateOpts) Run() error { return opts.Print(r) } -func (opts *UpdateOpts) newInvitation() *atlas.Invitation { - return &atlas.Invitation{ +func (opts *UpdateOpts) newInvitation() *opsmngr.Invitation { + return &opsmngr.Invitation{ Username: opts.username, Roles: opts.roles, } diff --git a/internal/cli/iam/organizations/invitations/update_test.go b/internal/cli/iam/organizations/invitations/update_test.go index 426c2ee159..8dabf6ded7 100644 --- a/internal/cli/iam/organizations/invitations/update_test.go +++ b/internal/cli/iam/organizations/invitations/update_test.go @@ -24,14 +24,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestUpdate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockOrganizationInvitationUpdater(ctrl) - expected := &atlas.Invitation{} + expected := &opsmngr.Invitation{} updateOpts := &UpdateOpts{ roles: []string{"test"}, diff --git a/internal/cli/iam/projects/apikeys/assign.go b/internal/cli/iam/projects/apikeys/assign.go index 11146d2857..9f446d2d6a 100644 --- a/internal/cli/iam/projects/apikeys/assign.go +++ b/internal/cli/iam/projects/apikeys/assign.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) type AssignOpts struct { @@ -44,8 +44,8 @@ func (opts *AssignOpts) initStore(ctx context.Context) func() error { } } -func (opts *AssignOpts) newAssignAPIKey() *atlas.AssignAPIKey { - return &atlas.AssignAPIKey{ +func (opts *AssignOpts) newAssignAPIKey() *opsmngr.AssignAPIKey { + return &opsmngr.AssignAPIKey{ Roles: opts.roles, } } diff --git a/internal/cli/iam/projects/create.go b/internal/cli/iam/projects/create.go index 2bdf0013a6..be98ac42cb 100644 --- a/internal/cli/iam/projects/create.go +++ b/internal/cli/iam/projects/create.go @@ -18,7 +18,6 @@ import ( "context" "fmt" - "github.com/Masterminds/semver/v3" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/cli" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/cli/require" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" @@ -26,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const ( @@ -39,7 +38,6 @@ type CreateOpts struct { name string projectOwnerID string withoutDefaultAlertSettings bool - serviceVersion *semver.Version store store.ProjectCreator } @@ -71,60 +69,8 @@ func (opts *CreateOpts) Run() error { return opts.Print(r) } -func (opts *CreateOpts) newCreateProjectOptions() *atlas.CreateProjectOptions { - return &atlas.CreateProjectOptions{ProjectOwnerID: opts.projectOwnerID} -} - -func (opts *CreateOpts) validateOwnerID() error { - if opts.projectOwnerID == "" || opts.serviceVersion == nil { - return nil - } - - constrain, err := semver.NewConstraint(">= 6.0") - if err != nil { - return err - } - - if !constrain.Check(opts.serviceVersion) { - return fmt.Errorf("%s is available only for Atlas, Cloud Manager and Ops Manager >= 6.0", flag.OwnerID) - } - - return nil -} - -func (opts *CreateOpts) validateWithoutDefaultAlertSettings() error { - if !opts.withoutDefaultAlertSettings || opts.serviceVersion == nil { - return nil - } - - constrain, err := semver.NewConstraint(">= 6.0") - if err != nil { - return err - } - - if !constrain.Check(opts.serviceVersion) { - return fmt.Errorf("%s is available only for Atlas, Cloud Manager and Ops Manager >= 6.0", flag.WithoutDefaultAlertSettings) - } - - return nil -} - -func (opts *CreateOpts) initServiceVersion() error { - if config.Service() != config.OpsManagerService { - return nil - } - v, err := opts.store.ServiceVersion() - if err != nil { - return err - } - - sv, err := cli.ParseServiceVersion(v) - if err != nil { - return err - } - - opts.serviceVersion = sv - return nil +func (opts *CreateOpts) newCreateProjectOptions() *opsmngr.CreateProjectOptions { + return &opsmngr.CreateProjectOptions{ProjectOwnerID: opts.projectOwnerID} } // mongocli iam project(s) create [--orgId orgId] [--ownerID ownerID] [--withoutDefaultAlertSettings]. @@ -149,7 +95,7 @@ func CreateBuilder() *cobra.Command { if !config.IsCloud() { opts.Template += "Agent API Key: '{{.AgentAPIKey}}'\n" } - return opts.PreRunE(opts.initStore(cmd.Context()), opts.initServiceVersion, opts.validateOwnerID, opts.validateWithoutDefaultAlertSettings) + return opts.PreRunE(opts.initStore(cmd.Context())) }, RunE: func(_ *cobra.Command, args []string) error { opts.name = args[0] diff --git a/internal/cli/iam/projects/invitations/describe_test.go b/internal/cli/iam/projects/invitations/describe_test.go index bcdda15d30..1610725b36 100644 --- a/internal/cli/iam/projects/invitations/describe_test.go +++ b/internal/cli/iam/projects/invitations/describe_test.go @@ -23,7 +23,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestDescribe_Run(t *testing.T) { @@ -38,7 +38,7 @@ func TestDescribe_Run(t *testing.T) { mockStore. EXPECT(). ProjectInvitation(opts.ConfigProjectID(), opts.id). - Return(&mongodbatlas.Invitation{}, nil). + Return(&opsmngr.Invitation{}, nil). Times(1) if err := opts.Run(); err != nil { diff --git a/internal/cli/iam/projects/invitations/invite.go b/internal/cli/iam/projects/invitations/invite.go index 6402a3a2cd..b8a7cf4783 100644 --- a/internal/cli/iam/projects/invitations/invite.go +++ b/internal/cli/iam/projects/invitations/invite.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const createTemplate = "User '{{.Username}}' invited.\n" @@ -57,8 +57,8 @@ func (opts *InviteOpts) Run() error { return opts.Print(r) } -func (opts *InviteOpts) newInvitation() *atlas.Invitation { - return &atlas.Invitation{ +func (opts *InviteOpts) newInvitation() *opsmngr.Invitation { + return &opsmngr.Invitation{ Username: opts.username, Roles: opts.roles, TeamIDs: opts.teamIDs, diff --git a/internal/cli/iam/projects/invitations/invite_test.go b/internal/cli/iam/projects/invitations/invite_test.go index 81d7bfecc8..73aad458a3 100644 --- a/internal/cli/iam/projects/invitations/invite_test.go +++ b/internal/cli/iam/projects/invitations/invite_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestCreate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockProjectInviter(ctrl) - expected := &mongodbatlas.Invitation{} + expected := &opsmngr.Invitation{} opts := &InviteOpts{ store: mockStore, username: "test", diff --git a/internal/cli/iam/projects/invitations/list.go b/internal/cli/iam/projects/invitations/list.go index 51179ffdce..3f7c743d57 100644 --- a/internal/cli/iam/projects/invitations/list.go +++ b/internal/cli/iam/projects/invitations/list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const listTemplate = `ID USERNAME CREATED AT EXPIRES AT{{range valueOrEmptySlice .}} @@ -55,8 +55,8 @@ func (opts *ListOpts) Run() error { return opts.Print(r) } -func (opts *ListOpts) newInvitationOptions() *atlas.InvitationOptions { - return &atlas.InvitationOptions{ +func (opts *ListOpts) newInvitationOptions() *opsmngr.InvitationOptions { + return &opsmngr.InvitationOptions{ Username: opts.username, } } diff --git a/internal/cli/iam/projects/invitations/list_test.go b/internal/cli/iam/projects/invitations/list_test.go index 5ec6d4c3fd..9b13f09134 100644 --- a/internal/cli/iam/projects/invitations/list_test.go +++ b/internal/cli/iam/projects/invitations/list_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockProjectInvitationLister(ctrl) - var expected []*mongodbatlas.Invitation + var expected []*opsmngr.Invitation listOpts := &ListOpts{store: mockStore} diff --git a/internal/cli/iam/projects/invitations/update.go b/internal/cli/iam/projects/invitations/update.go index 15361c1d47..9b9ed6db00 100644 --- a/internal/cli/iam/projects/invitations/update.go +++ b/internal/cli/iam/projects/invitations/update.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const updateTemplate = "Invitation {{.ID}} updated.\n" @@ -56,8 +56,8 @@ func (opts *UpdateOpts) Run() error { return opts.Print(r) } -func (opts *UpdateOpts) newInvitation() *atlas.Invitation { - return &atlas.Invitation{ +func (opts *UpdateOpts) newInvitation() *opsmngr.Invitation { + return &opsmngr.Invitation{ Username: opts.username, Roles: opts.roles, } diff --git a/internal/cli/iam/projects/invitations/update_test.go b/internal/cli/iam/projects/invitations/update_test.go index f1b4662c8a..deeac74028 100644 --- a/internal/cli/iam/projects/invitations/update_test.go +++ b/internal/cli/iam/projects/invitations/update_test.go @@ -24,14 +24,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestUpdate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockProjectInvitationUpdater(ctrl) - expected := &atlas.Invitation{} + expected := &opsmngr.Invitation{} updateOpts := &UpdateOpts{ roles: []string{"test"}, diff --git a/internal/cli/iam/projects/list_test.go b/internal/cli/iam/projects/list_test.go index 7cf2d46842..1530821059 100644 --- a/internal/cli/iam/projects/list_test.go +++ b/internal/cli/iam/projects/list_test.go @@ -22,7 +22,6 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" "go.mongodb.org/ops-manager/opsmngr" ) @@ -52,7 +51,7 @@ func TestList_Run(t *testing.T) { store: mockStore, } listOpts.OrgID = "1" - filter := &mongodbatlas.ProjectsListOptions{ListOptions: *listOpts.NewListOptions()} + filter := &opsmngr.ProjectsListOptions{ListOptions: *listOpts.NewListOptions()} mockStore. EXPECT(). GetOrgProjects("1", filter). diff --git a/internal/cli/iam/projects/teams/add.go b/internal/cli/iam/projects/teams/add.go index 5b2ea2c64a..bfb4bc9f1b 100644 --- a/internal/cli/iam/projects/teams/add.go +++ b/internal/cli/iam/projects/teams/add.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const addTemplate = "Team added to the project.\n" @@ -55,8 +55,8 @@ func (opts *AddOpts) Run() error { return opts.Print(r) } -func (opts *AddOpts) newProjectTeam() []*atlas.ProjectTeam { - return []*atlas.ProjectTeam{ +func (opts *AddOpts) newProjectTeam() []*opsmngr.ProjectTeam { + return []*opsmngr.ProjectTeam{ { TeamID: opts.teamID, RoleNames: opts.roles, diff --git a/internal/cli/iam/projects/teams/add_test.go b/internal/cli/iam/projects/teams/add_test.go index 19b1249373..d8e13e51be 100644 --- a/internal/cli/iam/projects/teams/add_test.go +++ b/internal/cli/iam/projects/teams/add_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestAdd_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockProjectTeamAdder(ctrl) - var expected *mongodbatlas.TeamsAssigned + var expected *opsmngr.TeamsAssigned opts := &AddOpts{ store: mockStore, diff --git a/internal/cli/iam/projects/teams/list_test.go b/internal/cli/iam/projects/teams/list_test.go index d2cb532c5a..0709e96771 100644 --- a/internal/cli/iam/projects/teams/list_test.go +++ b/internal/cli/iam/projects/teams/list_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockProjectTeamLister(ctrl) - var expected *mongodbatlas.TeamsAssigned + var expected *opsmngr.TeamsAssigned listOpts := &ListOpts{ store: mockStore, diff --git a/internal/cli/iam/projects/teams/update.go b/internal/cli/iam/projects/teams/update.go index 0b544602f9..b015b2c5e4 100644 --- a/internal/cli/iam/projects/teams/update.go +++ b/internal/cli/iam/projects/teams/update.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const updateTemplate = "Team's roles updated.\n" @@ -55,8 +55,8 @@ func (opts *UpdateOpts) Run() error { return opts.Print(r) } -func (opts *UpdateOpts) newTeamUpdateRoles() *atlas.TeamUpdateRoles { - return &atlas.TeamUpdateRoles{ +func (opts *UpdateOpts) newTeamUpdateRoles() *opsmngr.TeamUpdateRoles { + return &opsmngr.TeamUpdateRoles{ RoleNames: opts.roles, } } diff --git a/internal/cli/iam/projects/teams/update_test.go b/internal/cli/iam/projects/teams/update_test.go index 96b17d797c..290c503176 100644 --- a/internal/cli/iam/projects/teams/update_test.go +++ b/internal/cli/iam/projects/teams/update_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestUpdate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockTeamRolesUpdater(ctrl) - expected := []atlas.TeamRoles{} + var expected []opsmngr.TeamRoles updateOpts := &UpdateOpts{ roles: []string{"test"}, diff --git a/internal/cli/iam/teams/create.go b/internal/cli/iam/teams/create.go index a4372a29af..5d65aae491 100644 --- a/internal/cli/iam/teams/create.go +++ b/internal/cli/iam/teams/create.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) var createTemplate = "Team '{{.Name}}' created.\n" @@ -54,8 +54,8 @@ func (opts *CreateOpts) Run() error { return opts.Print(r) } -func (opts *CreateOpts) newTeam() *atlas.Team { - return &atlas.Team{ +func (opts *CreateOpts) newTeam() *opsmngr.Team { + return &opsmngr.Team{ Name: opts.name, Usernames: opts.userNames, } diff --git a/internal/cli/iam/teams/create_test.go b/internal/cli/iam/teams/create_test.go index 3335a9b41c..e17baa362c 100644 --- a/internal/cli/iam/teams/create_test.go +++ b/internal/cli/iam/teams/create_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestCreate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockTeamCreator(ctrl) - expected := &mongodbatlas.Team{} + expected := &opsmngr.Team{} createOpts := &CreateOpts{ store: mockStore, diff --git a/internal/cli/iam/teams/describe_test.go b/internal/cli/iam/teams/describe_test.go index 0cfecfdcb7..1c58af7f50 100644 --- a/internal/cli/iam/teams/describe_test.go +++ b/internal/cli/iam/teams/describe_test.go @@ -20,14 +20,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestDescribeOpts_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockTeamDescriber(ctrl) - var expected *mongodbatlas.Team + var expected *opsmngr.Team t.Run("by ID", func(t *testing.T) { descOpts := &DescribeOpts{ diff --git a/internal/cli/iam/teams/list_test.go b/internal/cli/iam/teams/list_test.go index e5de7f719a..9ec3be4b14 100644 --- a/internal/cli/iam/teams/list_test.go +++ b/internal/cli/iam/teams/list_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockTeamLister(ctrl) - var expected []mongodbatlas.Team + var expected []opsmngr.Team listOpts := &ListOpts{ store: mockStore, diff --git a/internal/cli/iam/teams/users/list_test.go b/internal/cli/iam/teams/users/list_test.go index d2850a8f10..ee7bea5688 100644 --- a/internal/cli/iam/teams/users/list_test.go +++ b/internal/cli/iam/teams/users/list_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockTeamUserLister(ctrl) - var expected []mongodbatlas.Team + var expected []*opsmngr.User listOpts := &ListOpts{ store: mockStore, diff --git a/internal/cli/mongocli/alerts/settings/create_test.go b/internal/cli/mongocli/alerts/settings/create_test.go index 4d0260a2ba..679ccbad11 100644 --- a/internal/cli/mongocli/alerts/settings/create_test.go +++ b/internal/cli/mongocli/alerts/settings/create_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestCreate_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockAlertConfigurationCreator(ctrl) - expected := &mongodbatlas.AlertConfiguration{} + expected := &opsmngr.AlertConfiguration{} createOpts := &CreateOpts{ ConfigOpts: ConfigOpts{ diff --git a/internal/cli/mongocli/alerts/settings/disable_test.go b/internal/cli/mongocli/alerts/settings/disable_test.go index eaa433bcb6..3f1da9ca7e 100644 --- a/internal/cli/mongocli/alerts/settings/disable_test.go +++ b/internal/cli/mongocli/alerts/settings/disable_test.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestDisableBuilder(t *testing.T) { @@ -51,7 +51,7 @@ func TestDisableOpts_Run(t *testing.T) { }, store: mockStore, } - expected := &mongodbatlas.AlertConfiguration{} + expected := &opsmngr.AlertConfiguration{} mockStore. EXPECT(). DisableAlertConfiguration(opts.ProjectID, opts.alertID). diff --git a/internal/cli/mongocli/alerts/settings/enable_test.go b/internal/cli/mongocli/alerts/settings/enable_test.go index d70e98c3b3..50aa9e9d73 100644 --- a/internal/cli/mongocli/alerts/settings/enable_test.go +++ b/internal/cli/mongocli/alerts/settings/enable_test.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestEnableBuilder(t *testing.T) { @@ -51,7 +51,7 @@ func TestEnableOpts_Run(t *testing.T) { }, store: mockStore, } - expected := &mongodbatlas.AlertConfiguration{} + expected := &opsmngr.AlertConfiguration{} mockStore. EXPECT(). EnableAlertConfiguration(opts.ProjectID, opts.alertID). diff --git a/internal/cli/mongocli/alerts/settings/list_test.go b/internal/cli/mongocli/alerts/settings/list_test.go index c5d19a9db5..dc4eee19e1 100644 --- a/internal/cli/mongocli/alerts/settings/list_test.go +++ b/internal/cli/mongocli/alerts/settings/list_test.go @@ -26,13 +26,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/pointer" "github.com/stretchr/testify/assert" "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestConfigList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockAlertConfigurationLister(ctrl) - expected := []mongodbatlas.AlertConfiguration{ + expected := []opsmngr.AlertConfiguration{ { ID: "test", GroupID: "test", diff --git a/internal/cli/mongocli/alerts/settings/settings.go b/internal/cli/mongocli/alerts/settings/settings.go index 747096beb6..58f1b51f0e 100644 --- a/internal/cli/mongocli/alerts/settings/settings.go +++ b/internal/cli/mongocli/alerts/settings/settings.go @@ -19,6 +19,7 @@ import ( "github.com/spf13/cobra" atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const ( @@ -63,8 +64,8 @@ type ConfigOpts struct { metricThresholdThreshold float64 } -func (opts *ConfigOpts) NewAlertConfiguration(projectID string) *atlas.AlertConfiguration { - out := new(atlas.AlertConfiguration) +func (opts *ConfigOpts) NewAlertConfiguration(projectID string) *opsmngr.AlertConfiguration { + out := new(opsmngr.AlertConfiguration) out.GroupID = projectID out.EventTypeName = strings.ToUpper(opts.event) diff --git a/internal/cli/mongocli/alerts/settings/update_test.go b/internal/cli/mongocli/alerts/settings/update_test.go index ebea56d5e5..cff144c48f 100644 --- a/internal/cli/mongocli/alerts/settings/update_test.go +++ b/internal/cli/mongocli/alerts/settings/update_test.go @@ -21,14 +21,14 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestUpdates_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockAlertConfigurationUpdater(ctrl) - expected := &mongodbatlas.AlertConfiguration{} + expected := &opsmngr.AlertConfiguration{} updateOpts := &UpdateOpts{ ConfigOpts: ConfigOpts{ diff --git a/internal/cli/mongocli/events/list.go b/internal/cli/mongocli/events/list.go index 7cb598169b..7a3cba3916 100644 --- a/internal/cli/mongocli/events/list.go +++ b/internal/cli/mongocli/events/list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) type EventListOpts struct { @@ -35,9 +35,9 @@ type EventListOpts struct { MaxDate string } -func (opts *EventListOpts) newEventListOptions() *atlas.EventListOptions { - return &atlas.EventListOptions{ - ListOptions: atlas.ListOptions{ +func (opts *EventListOpts) newEventListOptions() *opsmngr.EventListOptions { + return &opsmngr.EventListOptions{ + ListOptions: opsmngr.ListOptions{ PageNum: opts.PageNum, ItemsPerPage: opts.ItemsPerPage, }, @@ -70,7 +70,7 @@ var listTemplate = `ID TYPE CREATED{{range valueOrEmptySlice .Results}} func (opts *ListOpts) Run() error { listOpts := opts.newEventListOptions() - var r *atlas.EventResponse + var r *opsmngr.EventResponse var err error if opts.orgID != "" { diff --git a/internal/cli/mongocli/events/list_test.go b/internal/cli/mongocli/events/list_test.go index eb5249d37d..df3ac4be08 100644 --- a/internal/cli/mongocli/events/list_test.go +++ b/internal/cli/mongocli/events/list_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockEventLister(ctrl) - expected := &mongodbatlas.EventResponse{} + expected := &opsmngr.EventResponse{} t.Run("for a project", func(t *testing.T) { listOpts := &ListOpts{ diff --git a/internal/cli/mongocli/events/orgs_list.go b/internal/cli/mongocli/events/orgs_list.go index 9179e138f5..61504d92fc 100644 --- a/internal/cli/mongocli/events/orgs_list.go +++ b/internal/cli/mongocli/events/orgs_list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) type orgListOpts struct { @@ -46,7 +46,7 @@ func (opts *orgListOpts) initStore(ctx context.Context) func() error { func (opts *orgListOpts) Run() error { listOpts := opts.newEventListOptions() - var r *atlas.EventResponse + var r *opsmngr.EventResponse var err error r, err = opts.store.OrganizationEvents(opts.ConfigOrgID(), listOpts) if err != nil { diff --git a/internal/cli/mongocli/events/orgs_list_test.go b/internal/cli/mongocli/events/orgs_list_test.go index db0089e769..1c091da0eb 100644 --- a/internal/cli/mongocli/events/orgs_list_test.go +++ b/internal/cli/mongocli/events/orgs_list_test.go @@ -21,14 +21,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func Test_orgListOpts_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockOrganizationEventLister(ctrl) - expected := &mongodbatlas.EventResponse{} + expected := &opsmngr.EventResponse{} listOpts := &orgListOpts{ store: mockStore, } diff --git a/internal/cli/mongocli/events/projects_list.go b/internal/cli/mongocli/events/projects_list.go index 383cd98eea..febe64ed6c 100644 --- a/internal/cli/mongocli/events/projects_list.go +++ b/internal/cli/mongocli/events/projects_list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) type projectListOpts struct { @@ -46,7 +46,7 @@ func (opts *projectListOpts) initStore(ctx context.Context) func() error { func (opts *projectListOpts) Run() error { listOpts := opts.newEventListOptions() - var r *atlas.EventResponse + var r *opsmngr.EventResponse var err error r, err = opts.store.ProjectEvents(opts.ConfigProjectID(), listOpts) diff --git a/internal/cli/mongocli/performanceadvisor/namespaces/list.go b/internal/cli/mongocli/performanceadvisor/namespaces/list.go index 8e5b8ea826..6dba157f2b 100644 --- a/internal/cli/mongocli/performanceadvisor/namespaces/list.go +++ b/internal/cli/mongocli/performanceadvisor/namespaces/list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const listTemplate = `NAMESPACE TYPE{{range valueOrEmptySlice .Namespaces}} @@ -58,8 +58,8 @@ func (opts *ListOpts) Run() error { return opts.Print(r) } -func (opts *ListOpts) newNamespaceOptions() *atlas.NamespaceOptions { - return &atlas.NamespaceOptions{ +func (opts *ListOpts) newNamespaceOptions() *opsmngr.NamespaceOptions { + return &opsmngr.NamespaceOptions{ Since: opts.since, Duration: opts.duration, } diff --git a/internal/cli/mongocli/performanceadvisor/namespaces/list_test.go b/internal/cli/mongocli/performanceadvisor/namespaces/list_test.go index 70d6d751f8..73d7665b7c 100644 --- a/internal/cli/mongocli/performanceadvisor/namespaces/list_test.go +++ b/internal/cli/mongocli/performanceadvisor/namespaces/list_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestNamespacesList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockPerformanceAdvisorNamespacesLister(ctrl) - var expected *mongodbatlas.Namespaces + var expected *opsmngr.Namespaces listOpts := &ListOpts{ store: mockStore, diff --git a/internal/cli/mongocli/performanceadvisor/slowquerylogs/list.go b/internal/cli/mongocli/performanceadvisor/slowquerylogs/list.go index a04e3ac51c..fdc2a771e2 100644 --- a/internal/cli/mongocli/performanceadvisor/slowquerylogs/list.go +++ b/internal/cli/mongocli/performanceadvisor/slowquerylogs/list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const listTemplate = `NAMESPACE LINE{{range valueOrEmptySlice .SlowQuery}} @@ -60,11 +60,11 @@ func (opts *ListOpts) Run() error { return opts.Print(r) } -func (opts *ListOpts) newSlowQueryOptions() *atlas.SlowQueryOptions { - return &atlas.SlowQueryOptions{ +func (opts *ListOpts) newSlowQueryOptions() *opsmngr.SlowQueryOptions { + return &opsmngr.SlowQueryOptions{ Namespaces: opts.namespaces, NLogs: opts.nLog, - NamespaceOptions: atlas.NamespaceOptions{ + NamespaceOptions: opsmngr.NamespaceOptions{ Since: opts.since, Duration: opts.duration, }, diff --git a/internal/cli/mongocli/performanceadvisor/slowquerylogs/list_test.go b/internal/cli/mongocli/performanceadvisor/slowquerylogs/list_test.go index 197db3156a..cc42010699 100644 --- a/internal/cli/mongocli/performanceadvisor/slowquerylogs/list_test.go +++ b/internal/cli/mongocli/performanceadvisor/slowquerylogs/list_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestSlowQueryLogsList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockPerformanceAdvisorSlowQueriesLister(ctrl) - var expected *mongodbatlas.SlowQueries + var expected *opsmngr.SlowQueries listOpts := &ListOpts{ store: mockStore, diff --git a/internal/cli/mongocli/performanceadvisor/suggestedindexes/list.go b/internal/cli/mongocli/performanceadvisor/suggestedindexes/list.go index f560c791bb..c7c1fb8d43 100644 --- a/internal/cli/mongocli/performanceadvisor/suggestedindexes/list.go +++ b/internal/cli/mongocli/performanceadvisor/suggestedindexes/list.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/usage" "github.com/spf13/cobra" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) const listTemplate = `ID NAMESPACE SUGGESTED INDEX{{range valueOrEmptySlice .SuggestedIndexes}} @@ -61,12 +61,12 @@ func (opts *ListOpts) Run() error { return opts.Print(r) } -func (opts *ListOpts) newSuggestedIndexOptions() *atlas.SuggestedIndexOptions { - return &atlas.SuggestedIndexOptions{ +func (opts *ListOpts) newSuggestedIndexOptions() *opsmngr.SuggestedIndexOptions { + return &opsmngr.SuggestedIndexOptions{ Namespaces: opts.namespaces, NIndexes: opts.nIndexes, NExamples: opts.nExamples, - NamespaceOptions: atlas.NamespaceOptions{ + NamespaceOptions: opsmngr.NamespaceOptions{ Since: opts.since, Duration: opts.duration, }, diff --git a/internal/cli/mongocli/performanceadvisor/suggestedindexes/list_test.go b/internal/cli/mongocli/performanceadvisor/suggestedindexes/list_test.go index ab4dd9a0db..95796383d7 100644 --- a/internal/cli/mongocli/performanceadvisor/suggestedindexes/list_test.go +++ b/internal/cli/mongocli/performanceadvisor/suggestedindexes/list_test.go @@ -23,14 +23,14 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/flag" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/mocks" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestNamespacesList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockPerformanceAdvisorIndexesLister(ctrl) - var expected *mongodbatlas.SuggestedIndexes + var expected *opsmngr.SuggestedIndexes listOpts := &ListOpts{ store: mockStore, diff --git a/internal/homebrew/homebrew.go b/internal/homebrew/homebrew.go index 71fa88b9eb..9ae5eb154c 100644 --- a/internal/homebrew/homebrew.go +++ b/internal/homebrew/homebrew.go @@ -53,7 +53,7 @@ func FormulaName(tool string) string { } // IsHomebrew checks if the cli was installed with homebrew. -func (s Checker) IsHomebrew() bool { +func (s *Checker) IsHomebrew() bool { // Load from cache h, err := s.load() if h != nil && h.ExecutablePath != "" && h.FormulaPath != "" && err == nil { diff --git a/internal/log/log.go b/internal/log/log.go index 1be3962b09..9bae727647 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -64,42 +64,42 @@ func (l *Logger) IsWarningLevel() bool { return l.level >= WarningLevel } -func (l Logger) Debug(a ...any) (int, error) { +func (l *Logger) Debug(a ...any) (int, error) { if !l.IsDebugLevel() { return 0, nil } return fmt.Fprint(l.w, a...) } -func (l Logger) Debugln(a ...any) (int, error) { +func (l *Logger) Debugln(a ...any) (int, error) { if !l.IsDebugLevel() { return 0, nil } return fmt.Fprintln(l.w, a...) } -func (l Logger) Debugf(format string, a ...any) (int, error) { +func (l *Logger) Debugf(format string, a ...any) (int, error) { if !l.IsDebugLevel() { return 0, nil } return fmt.Fprintf(l.w, format, a...) } -func (l Logger) Warning(a ...any) (int, error) { +func (l *Logger) Warning(a ...any) (int, error) { if !l.IsWarningLevel() { return 0, nil } return fmt.Fprint(l.w, a...) } -func (l Logger) Warningln(a ...any) (int, error) { +func (l *Logger) Warningln(a ...any) (int, error) { if !l.IsWarningLevel() { return 0, nil } return fmt.Fprintln(l.w, a...) } -func (l Logger) Warningf(format string, a ...any) (int, error) { +func (l *Logger) Warningf(format string, a ...any) (int, error) { if !l.IsWarningLevel() { return 0, nil } diff --git a/internal/mocks/mock_organization_invitations.go b/internal/mocks/mock_organization_invitations.go index 9f6d471d33..2515a0912d 100644 --- a/internal/mocks/mock_organization_invitations.go +++ b/internal/mocks/mock_organization_invitations.go @@ -35,10 +35,10 @@ func (m *MockOrganizationInvitationLister) EXPECT() *MockOrganizationInvitationL } // OrganizationInvitations mocks base method. -func (m *MockOrganizationInvitationLister) OrganizationInvitations(arg0 string, arg1 *mongodbatlas.InvitationOptions) (interface{}, error) { +func (m *MockOrganizationInvitationLister) OrganizationInvitations(arg0 string, arg1 *mongodbatlas.InvitationOptions) ([]*mongodbatlas.Invitation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "OrganizationInvitations", arg0, arg1) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].([]*mongodbatlas.Invitation) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -110,10 +110,10 @@ func (m *MockOrganizationInvitationDescriber) EXPECT() *MockOrganizationInvitati } // OrganizationInvitation mocks base method. -func (m *MockOrganizationInvitationDescriber) OrganizationInvitation(arg0, arg1 string) (interface{}, error) { +func (m *MockOrganizationInvitationDescriber) OrganizationInvitation(arg0, arg1 string) (*mongodbatlas.Invitation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "OrganizationInvitation", arg0, arg1) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*mongodbatlas.Invitation) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -148,10 +148,10 @@ func (m *MockOrganizationInvitationUpdater) EXPECT() *MockOrganizationInvitation } // UpdateOrganizationInvitation mocks base method. -func (m *MockOrganizationInvitationUpdater) UpdateOrganizationInvitation(arg0, arg1 string, arg2 *mongodbatlas.Invitation) (interface{}, error) { +func (m *MockOrganizationInvitationUpdater) UpdateOrganizationInvitation(arg0, arg1 string, arg2 *mongodbatlas.Invitation) (*mongodbatlas.Invitation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateOrganizationInvitation", arg0, arg1, arg2) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*mongodbatlas.Invitation) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -186,10 +186,10 @@ func (m *MockOrganizationInviter) EXPECT() *MockOrganizationInviterMockRecorder } // InviteUser mocks base method. -func (m *MockOrganizationInviter) InviteUser(arg0 string, arg1 *mongodbatlas.Invitation) (interface{}, error) { +func (m *MockOrganizationInviter) InviteUser(arg0 string, arg1 *mongodbatlas.Invitation) (*mongodbatlas.Invitation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "InviteUser", arg0, arg1) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*mongodbatlas.Invitation) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/internal/mocks/mock_users.go b/internal/mocks/mock_users.go index e04897767e..35942ef678 100644 --- a/internal/mocks/mock_users.go +++ b/internal/mocks/mock_users.go @@ -202,10 +202,10 @@ func (m *MockTeamUserLister) EXPECT() *MockTeamUserListerMockRecorder { } // TeamUsers mocks base method. -func (m *MockTeamUserLister) TeamUsers(arg0, arg1 string) (interface{}, error) { +func (m *MockTeamUserLister) TeamUsers(arg0, arg1 string) ([]*opsmngr.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "TeamUsers", arg0, arg1) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].([]*opsmngr.User) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index e154b397ca..69cd1086fd 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -30,7 +30,6 @@ const ( maxIdleConnsPerHost = 4 idleConnTimeout = 30 * time.Second expectContinueTimeout = 1 * time.Second - cloudGovServiceURL = "https://cloud.mongodbgov.com/" ) var defaultTransport = &http.Transport{ @@ -52,8 +51,7 @@ type ServiceGetter interface { } const ( - ClientID = "0oabtxactgS3gHIR0297" // ClientID for production - GovClientID = "0oabtyfelbTBdoucy297" // GovClientID for production + ClientID = "0oabtxactgS3gHIR0297" // ClientID for production ) func FlowWithConfig(c ServiceGetter) (*auth.Config, error) { diff --git a/internal/store/api_keys.go b/internal/store/api_keys.go index adcf988d8d..a0bbb1c515 100644 --- a/internal/store/api_keys.go +++ b/internal/store/api_keys.go @@ -18,7 +18,6 @@ import ( "fmt" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - atlas "go.mongodb.org/atlas/mongodbatlas" "go.mongodb.org/ops-manager/opsmngr" ) @@ -37,7 +36,7 @@ type ProjectAPIKeyDeleter interface { } type ProjectAPIKeyAssigner interface { - AssignProjectAPIKey(string, string, *atlas.AssignAPIKey) error + AssignProjectAPIKey(string, string, *opsmngr.AssignAPIKey) error } type OrganizationAPIKeyLister interface { @@ -138,7 +137,7 @@ func (s *Store) CreateProjectAPIKey(projectID string, apiKeyInput *opsmngr.APIKe } // AssignProjectAPIKey encapsulates the logic to manage different cloud providers. -func (s *Store) AssignProjectAPIKey(projectID, apiKeyID string, input *atlas.AssignAPIKey) error { +func (s *Store) AssignProjectAPIKey(projectID, apiKeyID string, input *opsmngr.AssignAPIKey) error { switch s.service { case config.OpsManagerService, config.CloudManagerService: _, err := s.client.ProjectAPIKeys.Assign(s.ctx, projectID, apiKeyID, input) diff --git a/internal/store/organization_invitations.go b/internal/store/organization_invitations.go index d403cbc0ff..ae2834a36d 100644 --- a/internal/store/organization_invitations.go +++ b/internal/store/organization_invitations.go @@ -18,21 +18,21 @@ import ( "fmt" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) //go:generate mockgen -destination=../mocks/mock_organization_invitations.go -package=mocks github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store OrganizationInvitationLister,OrganizationInvitationDeleter,OrganizationInvitationDescriber,OrganizationInvitationUpdater,OrganizationInviter type OrganizationInvitationLister interface { - OrganizationInvitations(string, *atlas.InvitationOptions) (interface{}, error) + OrganizationInvitations(string, *opsmngr.InvitationOptions) ([]*opsmngr.Invitation, error) } type OrganizationInvitationDescriber interface { - OrganizationInvitation(string, string) (interface{}, error) + OrganizationInvitation(string, string) (*opsmngr.Invitation, error) } type OrganizationInviter interface { - InviteUser(string, *atlas.Invitation) (interface{}, error) + InviteUser(string, *opsmngr.Invitation) (*opsmngr.Invitation, error) } type OrganizationInvitationDeleter interface { @@ -40,11 +40,11 @@ type OrganizationInvitationDeleter interface { } type OrganizationInvitationUpdater interface { - UpdateOrganizationInvitation(string, string, *atlas.Invitation) (interface{}, error) + UpdateOrganizationInvitation(string, string, *opsmngr.Invitation) (*opsmngr.Invitation, error) } // OrganizationInvitations encapsulate the logic to manage different cloud providers. -func (s *Store) OrganizationInvitations(orgID string, opts *atlas.InvitationOptions) (interface{}, error) { +func (s *Store) OrganizationInvitations(orgID string, opts *opsmngr.InvitationOptions) ([]*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Organizations.Invitations(s.ctx, orgID, opts) @@ -55,7 +55,7 @@ func (s *Store) OrganizationInvitations(orgID string, opts *atlas.InvitationOpti } // OrganizationInvitation encapsulate the logic to manage different cloud providers. -func (s *Store) OrganizationInvitation(orgID, invitationID string) (interface{}, error) { +func (s *Store) OrganizationInvitation(orgID, invitationID string) (*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Organizations.Invitation(s.ctx, orgID, invitationID) @@ -77,7 +77,7 @@ func (s *Store) DeleteInvitation(orgID, invitationID string) error { } // UpdateOrganizationInvitation encapsulates the logic to manage different cloud providers. -func (s *Store) UpdateOrganizationInvitation(orgID, invitationID string, invitation *atlas.Invitation) (interface{}, error) { +func (s *Store) UpdateOrganizationInvitation(orgID, invitationID string, invitation *opsmngr.Invitation) (*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: if invitationID != "" { @@ -92,7 +92,7 @@ func (s *Store) UpdateOrganizationInvitation(orgID, invitationID string, invitat } // InviteUser encapsulates the logic to manage different cloud providers. -func (s *Store) InviteUser(orgID string, invitation *atlas.Invitation) (interface{}, error) { +func (s *Store) InviteUser(orgID string, invitation *opsmngr.Invitation) (*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Organizations.InviteUser(s.ctx, orgID, invitation) diff --git a/internal/store/performance_advisor.go b/internal/store/performance_advisor.go index b2b360c47c..af95a0c036 100644 --- a/internal/store/performance_advisor.go +++ b/internal/store/performance_advisor.go @@ -18,24 +18,24 @@ import ( "fmt" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) //go:generate mockgen -destination=../mocks/mock_performance_advisor.go -package=mocks github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store PerformanceAdvisorNamespacesLister,PerformanceAdvisorSlowQueriesLister,PerformanceAdvisorIndexesLister type PerformanceAdvisorNamespacesLister interface { - PerformanceAdvisorNamespaces(string, string, *atlas.NamespaceOptions) (*atlas.Namespaces, error) + PerformanceAdvisorNamespaces(string, string, *opsmngr.NamespaceOptions) (*opsmngr.Namespaces, error) } type PerformanceAdvisorSlowQueriesLister interface { - PerformanceAdvisorSlowQueries(string, string, *atlas.SlowQueryOptions) (*atlas.SlowQueries, error) + PerformanceAdvisorSlowQueries(string, string, *opsmngr.SlowQueryOptions) (*opsmngr.SlowQueries, error) } type PerformanceAdvisorIndexesLister interface { - PerformanceAdvisorIndexes(string, string, *atlas.SuggestedIndexOptions) (*atlas.SuggestedIndexes, error) + PerformanceAdvisorIndexes(string, string, *opsmngr.SuggestedIndexOptions) (*opsmngr.SuggestedIndexes, error) } // PerformanceAdvisorNamespaces encapsulates the logic to manage different cloud providers. -func (s *Store) PerformanceAdvisorNamespaces(projectID, processName string, opts *atlas.NamespaceOptions) (*atlas.Namespaces, error) { +func (s *Store) PerformanceAdvisorNamespaces(projectID, processName string, opts *opsmngr.NamespaceOptions) (*opsmngr.Namespaces, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.PerformanceAdvisor.GetNamespaces(s.ctx, projectID, processName, opts) @@ -46,7 +46,7 @@ func (s *Store) PerformanceAdvisorNamespaces(projectID, processName string, opts } // PerformanceAdvisorSlowQueries encapsulates the logic to manage different cloud providers. -func (s *Store) PerformanceAdvisorSlowQueries(projectID, processName string, opts *atlas.SlowQueryOptions) (*atlas.SlowQueries, error) { +func (s *Store) PerformanceAdvisorSlowQueries(projectID, processName string, opts *opsmngr.SlowQueryOptions) (*opsmngr.SlowQueries, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.PerformanceAdvisor.GetSlowQueries(s.ctx, projectID, processName, opts) @@ -57,7 +57,7 @@ func (s *Store) PerformanceAdvisorSlowQueries(projectID, processName string, opt } // PerformanceAdvisorIndexes encapsulates the logic to manage different cloud providers. -func (s *Store) PerformanceAdvisorIndexes(projectID, processName string, opts *atlas.SuggestedIndexOptions) (*atlas.SuggestedIndexes, error) { +func (s *Store) PerformanceAdvisorIndexes(projectID, processName string, opts *opsmngr.SuggestedIndexOptions) (*opsmngr.SuggestedIndexes, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.PerformanceAdvisor.GetSuggestedIndexes(s.ctx, projectID, processName, opts) diff --git a/internal/store/project_invitations.go b/internal/store/project_invitations.go index c2e3cfb17a..2db16ebf3d 100644 --- a/internal/store/project_invitations.go +++ b/internal/store/project_invitations.go @@ -18,21 +18,21 @@ import ( "fmt" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - atlas "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) //go:generate mockgen -destination=../mocks/mock_project_invitations.go -package=mocks github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store ProjectInvitationLister,ProjectInvitationDescriber,ProjectInvitationDeleter,ProjectInviter,ProjectInvitationUpdater type ProjectInvitationLister interface { - ProjectInvitations(string, *atlas.InvitationOptions) ([]*atlas.Invitation, error) + ProjectInvitations(string, *opsmngr.InvitationOptions) ([]*opsmngr.Invitation, error) } type ProjectInvitationDescriber interface { - ProjectInvitation(string, string) (*atlas.Invitation, error) + ProjectInvitation(string, string) (*opsmngr.Invitation, error) } type ProjectInviter interface { - InviteUserToProject(string, *atlas.Invitation) (*atlas.Invitation, error) + InviteUserToProject(string, *opsmngr.Invitation) (*opsmngr.Invitation, error) } type ProjectInvitationDeleter interface { @@ -40,11 +40,11 @@ type ProjectInvitationDeleter interface { } type ProjectInvitationUpdater interface { - UpdateProjectInvitation(string, string, *atlas.Invitation) (*atlas.Invitation, error) + UpdateProjectInvitation(string, string, *opsmngr.Invitation) (*opsmngr.Invitation, error) } // ProjectInvitations encapsulate the logic to manage different cloud providers. -func (s *Store) ProjectInvitations(groupID string, opts *atlas.InvitationOptions) ([]*atlas.Invitation, error) { +func (s *Store) ProjectInvitations(groupID string, opts *opsmngr.InvitationOptions) ([]*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Projects.Invitations(s.ctx, groupID, opts) @@ -55,7 +55,7 @@ func (s *Store) ProjectInvitations(groupID string, opts *atlas.InvitationOptions } // ProjectInvitation encapsulate the logic to manage different cloud providers. -func (s *Store) ProjectInvitation(groupID, invitationID string) (*atlas.Invitation, error) { +func (s *Store) ProjectInvitation(groupID, invitationID string) (*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Projects.Invitation(s.ctx, groupID, invitationID) @@ -77,7 +77,7 @@ func (s *Store) DeleteProjectInvitation(groupID, invitationID string) error { } // InviteUserToProject encapsulate the logic to manage different cloud providers. -func (s *Store) InviteUserToProject(groupID string, invitation *atlas.Invitation) (*atlas.Invitation, error) { +func (s *Store) InviteUserToProject(groupID string, invitation *opsmngr.Invitation) (*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Projects.InviteUser(s.ctx, groupID, invitation) @@ -88,7 +88,7 @@ func (s *Store) InviteUserToProject(groupID string, invitation *atlas.Invitation } // UpdateProjectInvitation encapsulate the logic to manage different cloud providers. -func (s *Store) UpdateProjectInvitation(groupID, invitationID string, invitation *atlas.Invitation) (*atlas.Invitation, error) { +func (s *Store) UpdateProjectInvitation(groupID, invitationID string, invitation *opsmngr.Invitation) (*opsmngr.Invitation, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: if invitationID != "" { diff --git a/internal/store/projects.go b/internal/store/projects.go index 580375d747..2b0bddb71e 100644 --- a/internal/store/projects.go +++ b/internal/store/projects.go @@ -18,7 +18,6 @@ import ( "fmt" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - atlas "go.mongodb.org/atlas/mongodbatlas" "go.mongodb.org/ops-manager/opsmngr" ) @@ -34,7 +33,7 @@ type OrgProjectLister interface { } type ProjectCreator interface { - CreateProject(string, string, *bool, *atlas.CreateProjectOptions) (*opsmngr.Project, error) + CreateProject(string, string, *bool, *opsmngr.CreateProjectOptions) (*opsmngr.Project, error) ServiceVersionDescriber } @@ -56,11 +55,11 @@ type ProjectUserDeleter interface { } type ProjectTeamLister interface { - ProjectTeams(string) (*atlas.TeamsAssigned, error) + ProjectTeams(string) (*opsmngr.TeamsAssigned, error) } type ProjectTeamAdder interface { - AddTeamsToProject(string, []*atlas.ProjectTeam) (*atlas.TeamsAssigned, error) + AddTeamsToProject(string, []*opsmngr.ProjectTeam) (*opsmngr.TeamsAssigned, error) } type ProjectTeamDeleter interface { @@ -68,7 +67,7 @@ type ProjectTeamDeleter interface { } // Projects encapsulates the logic to manage different cloud providers. -func (s *Store) Projects(opts *atlas.ListOptions) (*opsmngr.Projects, error) { +func (s *Store) Projects(opts *opsmngr.ListOptions) (*opsmngr.Projects, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Projects.List(s.ctx, opts) @@ -79,7 +78,7 @@ func (s *Store) Projects(opts *atlas.ListOptions) (*opsmngr.Projects, error) { } // GetOrgProjects encapsulates the logic to manage different cloud providers. -func (s *Store) GetOrgProjects(orgID string, opts *atlas.ProjectsListOptions) (*opsmngr.Projects, error) { +func (s *Store) GetOrgProjects(orgID string, opts *opsmngr.ProjectsListOptions) (*opsmngr.Projects, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Organizations.Projects(s.ctx, orgID, opts) @@ -111,7 +110,7 @@ func (s *Store) ProjectByName(name string) (*opsmngr.Project, error) { } // CreateProject encapsulates the logic to manage different cloud providers. -func (s *Store) CreateProject(name, orgID string, defaultAlertSettings *bool, opts *atlas.CreateProjectOptions) (*opsmngr.Project, error) { +func (s *Store) CreateProject(name, orgID string, defaultAlertSettings *bool, opts *opsmngr.CreateProjectOptions) (*opsmngr.Project, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: project := &opsmngr.Project{Name: name, OrgID: orgID, WithDefaultAlertsSettings: defaultAlertSettings} @@ -134,7 +133,7 @@ func (s *Store) DeleteProject(projectID string) error { } // ProjectUsers lists all IAM users in a project. -func (s *Store) ProjectUsers(projectID string, opts *atlas.ListOptions) ([]*opsmngr.User, error) { +func (s *Store) ProjectUsers(projectID string, opts *opsmngr.ListOptions) ([]*opsmngr.User, error) { switch s.service { case config.OpsManagerService, config.CloudManagerService: result, _, err := s.client.Projects.ListUsers(s.ctx, projectID, opts) @@ -156,7 +155,7 @@ func (s *Store) DeleteUserFromProject(projectID, userID string) error { } // ProjectTeams encapsulates the logic to manage different cloud providers. -func (s *Store) ProjectTeams(projectID string) (*atlas.TeamsAssigned, error) { +func (s *Store) ProjectTeams(projectID string) (*opsmngr.TeamsAssigned, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Projects.GetTeams(s.ctx, projectID, nil) @@ -167,7 +166,7 @@ func (s *Store) ProjectTeams(projectID string) (*atlas.TeamsAssigned, error) { } // AddTeamsToProject encapsulates the logic to manage different cloud providers. -func (s *Store) AddTeamsToProject(projectID string, teams []*atlas.ProjectTeam) (*atlas.TeamsAssigned, error) { +func (s *Store) AddTeamsToProject(projectID string, teams []*opsmngr.ProjectTeam) (*opsmngr.TeamsAssigned, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Projects.AddTeamsToProject(s.ctx, projectID, teams) diff --git a/internal/store/teams.go b/internal/store/teams.go index 4701a50744..8de495b1f8 100644 --- a/internal/store/teams.go +++ b/internal/store/teams.go @@ -18,23 +18,22 @@ import ( "fmt" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/config" - atlas "go.mongodb.org/atlas/mongodbatlas" "go.mongodb.org/ops-manager/opsmngr" ) //go:generate mockgen -destination=../mocks/mock_teams.go -package=mocks github.com/mongodb/mongodb-atlas-cli/mongocli/v2/internal/store TeamLister,TeamDescriber,TeamCreator,TeamDeleter,TeamAdder,TeamUserRemover,TeamRolesUpdater type TeamLister interface { - Teams(string, *opsmngr.ListOptions) ([]atlas.Team, error) + Teams(string, *opsmngr.ListOptions) ([]opsmngr.Team, error) } type TeamDescriber interface { - TeamByID(string, string) (*atlas.Team, error) - TeamByName(string, string) (*atlas.Team, error) + TeamByID(string, string) (*opsmngr.Team, error) + TeamByName(string, string) (*opsmngr.Team, error) } type TeamCreator interface { - CreateTeam(string, *atlas.Team) (*atlas.Team, error) + CreateTeam(string, *opsmngr.Team) (*opsmngr.Team, error) } type TeamDeleter interface { @@ -50,11 +49,11 @@ type TeamUserRemover interface { } type TeamRolesUpdater interface { - UpdateProjectTeamRoles(string, string, *atlas.TeamUpdateRoles) ([]atlas.TeamRoles, error) + UpdateProjectTeamRoles(string, string, *opsmngr.TeamUpdateRoles) ([]opsmngr.TeamRoles, error) } // TeamByID encapsulates the logic to manage different cloud providers. -func (s *Store) TeamByID(orgID, teamID string) (*atlas.Team, error) { +func (s *Store) TeamByID(orgID, teamID string) (*opsmngr.Team, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Teams.Get(s.ctx, orgID, teamID) @@ -65,7 +64,7 @@ func (s *Store) TeamByID(orgID, teamID string) (*atlas.Team, error) { } // TeamByName encapsulates the logic to manage different cloud providers. -func (s *Store) TeamByName(orgID, teamName string) (*atlas.Team, error) { +func (s *Store) TeamByName(orgID, teamName string) (*opsmngr.Team, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Teams.GetOneTeamByName(s.ctx, orgID, teamName) @@ -76,7 +75,7 @@ func (s *Store) TeamByName(orgID, teamName string) (*atlas.Team, error) { } // Teams encapsulates the logic to manage different cloud providers. -func (s *Store) Teams(orgID string, opts *atlas.ListOptions) ([]atlas.Team, error) { +func (s *Store) Teams(orgID string, opts *opsmngr.ListOptions) ([]opsmngr.Team, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Teams.List(s.ctx, orgID, opts) @@ -87,7 +86,7 @@ func (s *Store) Teams(orgID string, opts *atlas.ListOptions) ([]atlas.Team, erro } // CreateTeam encapsulates the logic to manage different cloud providers. -func (s *Store) CreateTeam(orgID string, team *atlas.Team) (*atlas.Team, error) { +func (s *Store) CreateTeam(orgID string, team *opsmngr.Team) (*opsmngr.Team, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Teams.Create(s.ctx, orgID, team) @@ -131,7 +130,7 @@ func (s *Store) RemoveUserFromTeam(orgID, teamID, userID string) error { } // UpdateProjectTeamRoles encapsulates the logic to manage different cloud providers. -func (s *Store) UpdateProjectTeamRoles(projectID, teamID string, team *atlas.TeamUpdateRoles) ([]atlas.TeamRoles, error) { +func (s *Store) UpdateProjectTeamRoles(projectID, teamID string, team *opsmngr.TeamUpdateRoles) ([]opsmngr.TeamRoles, error) { switch s.service { case config.CloudManagerService, config.OpsManagerService: result, _, err := s.client.Teams.UpdateTeamRoles(s.ctx, projectID, teamID, team) diff --git a/internal/store/users.go b/internal/store/users.go index ad4bdd9e8e..7c26686a72 100644 --- a/internal/store/users.go +++ b/internal/store/users.go @@ -36,7 +36,7 @@ type UserLister interface { } type TeamUserLister interface { - TeamUsers(string, string) (interface{}, error) + TeamUsers(string, string) ([]*opsmngr.User, error) } type UserDescriber interface { @@ -100,7 +100,7 @@ func (s *Store) OrganizationUsers(organizationID string, opts *opsmngr.ListOptio } // TeamUsers encapsulates the logic to manage different cloud providers. -func (s *Store) TeamUsers(orgID, teamID string) (interface{}, error) { +func (s *Store) TeamUsers(orgID, teamID string) ([]*opsmngr.User, error) { switch s.service { case config.OpsManagerService, config.CloudManagerService: result, _, err := s.client.Teams.GetTeamUsersAssigned(s.ctx, orgID, teamID) diff --git a/test/e2e/iam/helper_test.go b/test/e2e/iam/helper_test.go index ca8fa12483..ac41c9a3f6 100644 --- a/test/e2e/iam/helper_test.go +++ b/test/e2e/iam/helper_test.go @@ -24,7 +24,6 @@ import ( "strconv" "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/test/e2e" - "go.mongodb.org/atlas/mongodbatlas" "go.mongodb.org/ops-manager/opsmngr" ) @@ -119,7 +118,7 @@ func createTeam(teamName string) (string, error) { return "", fmt.Errorf("%w: %s", err, string(resp)) } - var team mongodbatlas.Team + var team opsmngr.Team if err := json.Unmarshal(resp, &team); err != nil { return "", err } @@ -166,7 +165,7 @@ func OrgNUser(n int) (username, userID string, err error) { return "", "", fmt.Errorf("error loading org users: %w (%s)", err, string(resp)) } - var users mongodbatlas.AtlasUsersResponse + var users opsmngr.UsersResponse if err := json.Unmarshal(resp, &users); err != nil { return "", "", err } diff --git a/test/e2e/iam/org_api_keys_test.go b/test/e2e/iam/org_api_keys_test.go index 41704f6f69..1010d939c2 100644 --- a/test/e2e/iam/org_api_keys_test.go +++ b/test/e2e/iam/org_api_keys_test.go @@ -25,7 +25,6 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/test/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" "go.mongodb.org/ops-manager/opsmngr" ) @@ -74,7 +73,7 @@ func TestOrgAPIKeys(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v, resp: %v", err, string(resp)) } - var keys []mongodbatlas.APIKey + var keys []opsmngr.APIKey if err := json.Unmarshal(resp, &keys); err != nil { t.Fatalf("unexpected error: %v", err) } @@ -96,7 +95,7 @@ func TestOrgAPIKeys(t *testing.T) { resp, err := cmd.CombinedOutput() a := assert.New(t) require.NoError(t, err, string(resp)) - var key mongodbatlas.APIKey + var key opsmngr.APIKey require.NoError(t, json.Unmarshal(resp, &key)) a.Equal(newDesc, key.Desc) }) @@ -114,7 +113,7 @@ func TestOrgAPIKeys(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var key mongodbatlas.APIKey + var key opsmngr.APIKey require.NoError(t, json.Unmarshal(resp, &key)) a.Equal(ID, key.ID) }) diff --git a/test/e2e/iam/org_invitations_test.go b/test/e2e/iam/org_invitations_test.go index 915a8a2d3e..e3ec2e6e13 100644 --- a/test/e2e/iam/org_invitations_test.go +++ b/test/e2e/iam/org_invitations_test.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/test/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestOrgInvitations(t *testing.T) { @@ -55,7 +55,7 @@ func TestOrgInvitations(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(emailOrg, invitation.Username) require.NotEmpty(t, invitation.ID) @@ -75,7 +75,7 @@ func TestOrgInvitations(t *testing.T) { a := assert.New(t) - var invitations []mongodbatlas.Invitation + var invitations []opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitations)) a.NotEmpty(invitations) }) @@ -94,7 +94,7 @@ func TestOrgInvitations(t *testing.T) { a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(orgInvitationID, invitation.ID) }) @@ -116,7 +116,7 @@ func TestOrgInvitations(t *testing.T) { a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(emailOrg, invitation.Username) a.ElementsMatch([]string{roleNameOrg}, invitation.Roles) @@ -137,7 +137,7 @@ func TestOrgInvitations(t *testing.T) { require.NoError(t, err, string(resp)) a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(emailOrg, invitation.Username) a.ElementsMatch([]string{roleNameOrg}, invitation.Roles) diff --git a/test/e2e/iam/project_invitations_test.go b/test/e2e/iam/project_invitations_test.go index e4f6946b0c..9c2e957333 100644 --- a/test/e2e/iam/project_invitations_test.go +++ b/test/e2e/iam/project_invitations_test.go @@ -25,7 +25,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/test/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestProjectInvitations(t *testing.T) { @@ -63,7 +63,7 @@ func TestProjectInvitations(t *testing.T) { require.NoError(t, err, string(resp)) a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(emailProject, invitation.Username) require.NotEmpty(t, invitation.ID) @@ -84,7 +84,7 @@ func TestProjectInvitations(t *testing.T) { require.NoError(t, err, string(resp)) a := assert.New(t) - var invitations []mongodbatlas.Invitation + var invitations []opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitations)) a.NotEmpty(invitations) }) @@ -104,7 +104,7 @@ func TestProjectInvitations(t *testing.T) { require.NoError(t, err, string(resp)) a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(invitationID, invitation.ID) }) @@ -129,7 +129,7 @@ func TestProjectInvitations(t *testing.T) { require.NoError(t, err, string(resp)) a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(emailProject, invitation.Username) a.ElementsMatch([]string{roleName1, roleName2}, invitation.Roles) @@ -154,7 +154,7 @@ func TestProjectInvitations(t *testing.T) { require.NoError(t, err, string(resp)) a := assert.New(t) - var invitation mongodbatlas.Invitation + var invitation opsmngr.Invitation require.NoError(t, json.Unmarshal(resp, &invitation)) a.Equal(emailProject, invitation.Username) a.ElementsMatch([]string{roleName1, roleName2}, invitation.Roles) diff --git a/test/e2e/iam/project_teams_test.go b/test/e2e/iam/project_teams_test.go index 18445a65a3..16ef555dcb 100644 --- a/test/e2e/iam/project_teams_test.go +++ b/test/e2e/iam/project_teams_test.go @@ -26,7 +26,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/test/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestProjectTeams(t *testing.T) { @@ -68,7 +68,7 @@ func TestProjectTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var teams mongodbatlas.TeamsAssigned + var teams opsmngr.TeamsAssigned require.NoError(t, json.Unmarshal(resp, &teams)) found := false for _, team := range teams.Results { @@ -101,7 +101,7 @@ func TestProjectTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var roles []mongodbatlas.TeamRoles + var roles []opsmngr.TeamRoles require.NoError(t, json.Unmarshal(resp, &roles)) a.Len(roles, 1) @@ -125,7 +125,7 @@ func TestProjectTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var teams mongodbatlas.TeamsAssigned + var teams opsmngr.TeamsAssigned require.NoError(t, json.Unmarshal(resp, &teams)) a.NotEmpty(teams.Results) }) diff --git a/test/e2e/iam/teams_test.go b/test/e2e/iam/teams_test.go index 2b331785ac..7c19d1559f 100644 --- a/test/e2e/iam/teams_test.go +++ b/test/e2e/iam/teams_test.go @@ -26,7 +26,7 @@ import ( "github.com/mongodb/mongodb-atlas-cli/mongocli/v2/test/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/ops-manager/opsmngr" ) func TestTeams(t *testing.T) { @@ -57,7 +57,7 @@ func TestTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var team mongodbatlas.Team + var team opsmngr.Team require.NoError(t, json.Unmarshal(resp, &team)) a.Equal(teamName, team.Name) teamID = team.ID @@ -78,7 +78,7 @@ func TestTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var team mongodbatlas.Team + var team opsmngr.Team require.NoError(t, json.Unmarshal(resp, &team)) a.Equal(teamID, team.ID) }) @@ -97,7 +97,7 @@ func TestTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var team mongodbatlas.Team + var team opsmngr.Team require.NoError(t, json.Unmarshal(resp, &team)) a.Equal(teamName, team.Name) }) @@ -114,7 +114,7 @@ func TestTeams(t *testing.T) { a := assert.New(t) require.NoError(t, err, string(resp)) - var teams []mongodbatlas.Team + var teams []opsmngr.Team require.NoError(t, json.Unmarshal(resp, &teams)) a.NotEmpty(t, teams) })