Skip to content

Commit

Permalink
move GetDomains function, return GetDomainsResponse
Browse files Browse the repository at this point in the history
Signed-off-by: zychen5186 <[email protected]>
  • Loading branch information
zychen5186 committed Jun 12, 2024
1 parent 93979fa commit d022eb4
Show file tree
Hide file tree
Showing 24 changed files with 939 additions and 10,519 deletions.
28 changes: 14 additions & 14 deletions flyteadmin/pkg/manager/impl/project_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ func (m *ProjectManager) CreateProject(ctx context.Context, request admin.Projec
return &admin.ProjectRegisterResponse{}, nil
}

func (m *ProjectManager) GetDomains(ctx context.Context, request admin.GetDomainRequest) *admin.Domains {
configDomains := m.config.ApplicationConfiguration().GetDomainsConfig()
var domains = make([]*admin.Domain, len(*configDomains))
for index, configDomain := range *configDomains {
domains[index] = &admin.Domain{
Id: configDomain.ID,
Name: configDomain.Name,
}
}
return &admin.Domains{
Domains: domains,
}
}

func (m *ProjectManager) ListProjects(ctx context.Context, request admin.ProjectListRequest) (*admin.Projects, error) {
spec := util.FilterSpec{
RequestFilters: request.Filters,
Expand Down Expand Up @@ -141,6 +127,20 @@ func (m *ProjectManager) GetProject(ctx context.Context, request admin.ProjectGe
return &projectResponse, nil
}

func (m *ProjectManager) GetDomains(ctx context.Context, request admin.GetDomainRequest) *admin.GetDomainsResponse {
configDomains := m.config.ApplicationConfiguration().GetDomainsConfig()
var domains = make([]*admin.Domain, len(*configDomains))
for index, configDomain := range *configDomains {
domains[index] = &admin.Domain{
Id: configDomain.ID,
Name: configDomain.Name,
}
}
return &admin.GetDomainsResponse{
Domains: domains,
}
}

func NewProjectManager(db repoInterfaces.Repository, config runtimeInterfaces.Configuration) interfaces.ProjectInterface {
return &ProjectManager{
db: db,
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/pkg/manager/interfaces/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

// Interface for managing projects (and domains).
type ProjectInterface interface {
GetDomains(ctx context.Context, request admin.GetDomainRequest) *admin.Domains
CreateProject(ctx context.Context, request admin.ProjectRegisterRequest) (*admin.ProjectRegisterResponse, error)
ListProjects(ctx context.Context, request admin.ProjectListRequest) (*admin.Projects, error)
UpdateProject(ctx context.Context, request admin.Project) (*admin.ProjectUpdateResponse, error)
GetProject(ctx context.Context, request admin.ProjectGetRequest) (*admin.Project, error)
GetDomains(ctx context.Context, request admin.GetDomainRequest) *admin.GetDomainsResponse
}
4 changes: 2 additions & 2 deletions flyteadmin/pkg/manager/mocks/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin"
)

type GetDomainsFunc func(ctx context.Context, request admin.GetDomainRequest) *admin.Domains
type GetDomainsFunc func(ctx context.Context, request admin.GetDomainRequest) *admin.GetDomainsResponse
type CreateProjectFunc func(ctx context.Context, request admin.ProjectRegisterRequest) (*admin.ProjectRegisterResponse, error)
type ListProjectFunc func(ctx context.Context, request admin.ProjectListRequest) (*admin.Projects, error)
type UpdateProjectFunc func(ctx context.Context, request admin.Project) (*admin.ProjectUpdateResponse, error)
Expand All @@ -24,7 +24,7 @@ func (m *MockProjectManager) SetCreateProject(createProjectFunc CreateProjectFun
m.createProjectFunc = createProjectFunc
}

func (m *MockProjectManager) GetDomains(ctx context.Context, request admin.GetDomainRequest) *admin.Domains {
func (m *MockProjectManager) GetDomains(ctx context.Context, request admin.GetDomainRequest) *admin.GetDomainsResponse {
if m.getDomainsFunc != nil {
return m.getDomainsFunc(ctx, request)
}
Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/pkg/rpc/adminservice/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func (m *AdminService) RegisterProject(ctx context.Context, request *admin.Proje
return response, nil
}

func (m *AdminService) GetDomains(ctx context.Context, request *admin.GetDomainRequest) (*admin.Domains, error) {
func (m *AdminService) GetDomains(ctx context.Context, request *admin.GetDomainRequest) (*admin.GetDomainsResponse, error) {
defer m.interceptPanic(ctx, request)
if request == nil {
return nil, status.Errorf(codes.InvalidArgument, "Incorrect request, nil requests not allowed")

Check warning on line 34 in flyteadmin/pkg/rpc/adminservice/project.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/rpc/adminservice/project.go#L31-L34

Added lines #L31 - L34 were not covered by tests
}
var response *admin.Domains
var response *admin.GetDomainsResponse
m.Metrics.domainEndpointMetrics.get.Time(func() {
response = m.ProjectManager.GetDomains(ctx, *request)
})

Check warning on line 39 in flyteadmin/pkg/rpc/adminservice/project.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/rpc/adminservice/project.go#L36-L39

Added lines #L36 - L39 were not covered by tests
Expand Down
10 changes: 5 additions & 5 deletions flyteidl/clients/go/admin/mocks/AdminServiceClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions flyteidl/clients/go/admin/mocks/AdminServiceServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions flyteidl/clients/go/assets/admin.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions flyteidl/gen/pb-es/flyteidl/admin/project_pb.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions flyteidl/gen/pb-es/flyteidl/service/admin_connect.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d022eb4

Please sign in to comment.