diff --git a/build/ci/library_owners.json b/build/ci/library_owners.json index d0d8ede89f..bd6d617de9 100644 --- a/build/ci/library_owners.json +++ b/build/ci/library_owners.json @@ -36,7 +36,6 @@ "go.mongodb.org/atlas": "mongocli", "go.mongodb.org/atlas-sdk/v20231115007": "mongocli", "go.mongodb.org/mongo-driver": "mongocli", - "go.mongodb.org/ops-manager": "mongocli", "golang.org/x/crypto": "mongocli", "golang.org/x/tools": "mongocli", "google.golang.org/api": "mongocli", diff --git a/go.mod b/go.mod index 481c1cf01a..48ff2901f3 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,6 @@ require ( go.mongodb.org/atlas v0.36.0 go.mongodb.org/atlas-sdk/v20231115007 v20231115007.1.0 go.mongodb.org/mongo-driver v1.14.0 - go.mongodb.org/ops-manager v0.55.3 golang.org/x/crypto v0.21.0 golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc golang.org/x/mod v0.16.0 diff --git a/go.sum b/go.sum index 8e68c69583..ddfedeeb13 100644 --- a/go.sum +++ b/go.sum @@ -391,8 +391,6 @@ go.mongodb.org/atlas-sdk/v20231115007 v20231115007.1.0 h1:RAnP53qeTT32iySa4sjfl1 go.mongodb.org/atlas-sdk/v20231115007 v20231115007.1.0/go.mod h1:JU7JOUGcv7pfDzbRTwIr8hGy2R1lehdrdfGj9fDjSVY= 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.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= diff --git a/internal/cli/atlas/projects/describe_test.go b/internal/cli/atlas/projects/describe_test.go index f692563362..821530c7b2 100644 --- a/internal/cli/atlas/projects/describe_test.go +++ b/internal/cli/atlas/projects/describe_test.go @@ -21,19 +21,20 @@ import ( "github.com/golang/mock/gomock" mocks "github.com/mongodb/mongodb-atlas-cli/internal/mocks/atlas" - "go.mongodb.org/ops-manager/opsmngr" + "github.com/mongodb/mongodb-atlas-cli/internal/pointer" + "go.mongodb.org/atlas-sdk/v20231115007/admin" ) func TestDescribe_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockProjectDescriber(ctrl) - expected := opsmngr.Project{ + expected := admin.Group{ Name: "test", - ID: "5a0a1e7e0f2912c554080adc", + Id: pointer.Get("5a0a1e7e0f2912c554080adc"), } mockStore. EXPECT(). - Project(gomock.Eq("5a0a1e7e0f2912c554080adc")). + Project("5a0a1e7e0f2912c554080adc"). Return(&expected, nil). Times(1) diff --git a/internal/kubernetes/operator/install.go b/internal/kubernetes/operator/install.go index f28e664916..5de81b91e3 100644 --- a/internal/kubernetes/operator/install.go +++ b/internal/kubernetes/operator/install.go @@ -33,10 +33,8 @@ import ( ) const ( - roleOrgGroupCreator = "ORG_GROUP_CREATOR" - roleProjectOwner = "GROUP_OWNER" - atlasErrorProjectNotFound = "GROUP_NAME_NOT_FOUND" - atlasErrorNotInGroup = "NOT_IN_GROUP" + roleOrgGroupCreator = "ORG_GROUP_CREATOR" + roleProjectOwner = "GROUP_OWNER" ) type Install struct { @@ -143,13 +141,8 @@ func (i *Install) Run(ctx context.Context, orgID string) error { } func (i *Install) ensureProject(orgID, projectName string) (*admin.Group, error) { - data, err := i.atlasStore.ProjectByName(projectName) + project, err := i.atlasStore.ProjectByName(projectName) if err == nil { - project, ok := data.(*admin.Group) - if !ok { - return nil, fmt.Errorf("failed to decode project: %w", err) - } - return project, nil } @@ -157,7 +150,7 @@ func (i *Install) ensureProject(orgID, projectName string) (*admin.Group, error) return nil, fmt.Errorf("failed to retrieve project: %w", err) } - data, err = i.atlasStore.CreateProject(&admin.CreateProjectApiParams{ + project, err = i.atlasStore.CreateProject(&admin.CreateProjectApiParams{ Group: &admin.Group{ Name: projectName, OrgId: orgID, @@ -169,11 +162,6 @@ func (i *Install) ensureProject(orgID, projectName string) (*admin.Group, error) return nil, fmt.Errorf("failed to create project: %w", err) } - project, ok := data.(*admin.Group) - if !ok { - return nil, fmt.Errorf("failed to decode created project: %w", err) - } - return project, nil } diff --git a/internal/kubernetes/operator/project/project.go b/internal/kubernetes/operator/project/project.go index b3b8430d90..bac41b5c33 100644 --- a/internal/kubernetes/operator/project/project.go +++ b/internal/kubernetes/operator/project/project.go @@ -15,7 +15,6 @@ package project import ( - "errors" "fmt" "strings" @@ -63,10 +62,6 @@ const ( prometheusIntegrationType = "PROMETHEUS" ) -var ( - ErrAtlasProject = errors.New("can not get 'atlas project' resource") -) - type AtlasProjectResult struct { Project *akov2.AtlasProject Secrets []*corev1.Secret @@ -74,16 +69,11 @@ type AtlasProjectResult struct { } func BuildAtlasProject(projectStore atlas.OperatorProjectStore, validator features.FeatureValidator, orgID, projectID, targetNamespace string, includeSecret bool, dictionary map[string]string, version string) (*AtlasProjectResult, error) { //nolint:gocyclo - data, err := projectStore.Project(projectID) + project, err := projectStore.Project(projectID) if err != nil { return nil, err } - project, ok := data.(*atlasv2.Group) - if !ok { - return nil, ErrAtlasProject - } - projectResult := newAtlasProject(project, dictionary, targetNamespace, version) result := &AtlasProjectResult{ diff --git a/internal/mocks/atlas/mock_atlas_generic_store.go b/internal/mocks/atlas/mock_atlas_generic_store.go index a04244bac1..07eddc2c85 100644 --- a/internal/mocks/atlas/mock_atlas_generic_store.go +++ b/internal/mocks/atlas/mock_atlas_generic_store.go @@ -365,10 +365,10 @@ func (mr *MockOperatorGenericStoreMockRecorder) PrivateEndpoints(arg0, arg1 inte } // Project mocks base method. -func (m *MockOperatorGenericStore) Project(arg0 string) (interface{}, error) { +func (m *MockOperatorGenericStore) Project(arg0 string) (*admin.Group, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Project", arg0) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*admin.Group) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -380,10 +380,10 @@ func (mr *MockOperatorGenericStoreMockRecorder) Project(arg0 interface{}) *gomoc } // ProjectByName mocks base method. -func (m *MockOperatorGenericStore) ProjectByName(arg0 string) (interface{}, error) { +func (m *MockOperatorGenericStore) ProjectByName(arg0 string) (*admin.Group, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ProjectByName", arg0) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*admin.Group) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/internal/mocks/atlas/mock_atlas_operator_project_store.go b/internal/mocks/atlas/mock_atlas_operator_project_store.go index 669a5574f3..c40948d294 100644 --- a/internal/mocks/atlas/mock_atlas_operator_project_store.go +++ b/internal/mocks/atlas/mock_atlas_operator_project_store.go @@ -216,10 +216,10 @@ func (mr *MockOperatorProjectStoreMockRecorder) PrivateEndpoints(arg0, arg1 inte } // Project mocks base method. -func (m *MockOperatorProjectStore) Project(arg0 string) (interface{}, error) { +func (m *MockOperatorProjectStore) Project(arg0 string) (*admin.Group, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Project", arg0) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*admin.Group) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -231,10 +231,10 @@ func (mr *MockOperatorProjectStoreMockRecorder) Project(arg0 interface{}) *gomoc } // ProjectByName mocks base method. -func (m *MockOperatorProjectStore) ProjectByName(arg0 string) (interface{}, error) { +func (m *MockOperatorProjectStore) ProjectByName(arg0 string) (*admin.Group, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ProjectByName", arg0) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*admin.Group) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/internal/mocks/atlas/mock_projects.go b/internal/mocks/atlas/mock_projects.go index dbcc2985b3..83c59a59bc 100644 --- a/internal/mocks/atlas/mock_projects.go +++ b/internal/mocks/atlas/mock_projects.go @@ -202,10 +202,10 @@ func (m *MockProjectDescriber) EXPECT() *MockProjectDescriberMockRecorder { } // Project mocks base method. -func (m *MockProjectDescriber) Project(arg0 string) (interface{}, error) { +func (m *MockProjectDescriber) Project(arg0 string) (*admin.Group, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Project", arg0) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*admin.Group) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -217,10 +217,10 @@ func (mr *MockProjectDescriberMockRecorder) Project(arg0 interface{}) *gomock.Ca } // ProjectByName mocks base method. -func (m *MockProjectDescriber) ProjectByName(arg0 string) (interface{}, error) { +func (m *MockProjectDescriber) ProjectByName(arg0 string) (*admin.Group, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ProjectByName", arg0) - ret0, _ := ret[0].(interface{}) + ret0, _ := ret[0].(*admin.Group) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/internal/store/atlas/projects.go b/internal/store/atlas/projects.go index 7824579713..02136f7ee3 100644 --- a/internal/store/atlas/projects.go +++ b/internal/store/atlas/projects.go @@ -38,8 +38,8 @@ type ProjectDeleter interface { } type ProjectDescriber interface { - Project(string) (interface{}, error) - ProjectByName(string) (interface{}, error) + Project(string) (*atlasv2.Group, error) + ProjectByName(string) (*atlasv2.Group, error) } type ProjectUsersLister interface { @@ -83,12 +83,12 @@ func (s *Store) GetOrgProjects(orgID string, opts *ListOptions) (*atlasv2.Pagina } // Project encapsulates the logic to manage different cloud providers. -func (s *Store) Project(id string) (interface{}, error) { +func (s *Store) Project(id string) (*atlasv2.Group, error) { result, _, err := s.clientv2.ProjectsApi.GetProject(s.ctx, id).Execute() return result, err } -func (s *Store) ProjectByName(name string) (interface{}, error) { +func (s *Store) ProjectByName(name string) (*atlasv2.Group, error) { result, _, err := s.clientv2.ProjectsApi.GetProjectByName(s.ctx, name).Execute() return result, err }