Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: team read service #6071

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions api/restHandler/BatchOperationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/devtron-labs/devtron/pkg/appClone/batch"
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
"go.uber.org/zap"
Expand All @@ -42,20 +41,18 @@ type BatchOperationRestHandlerImpl struct {
userAuthService user.UserService
enforcer casbin.Enforcer
workflowAction batch.WorkflowAction
teamService team.TeamService
logger *zap.SugaredLogger
enforcerUtil rbac.EnforcerUtil
argoUserService argo.ArgoUserService
}

func NewBatchOperationRestHandlerImpl(userAuthService user.UserService, enforcer casbin.Enforcer, workflowAction batch.WorkflowAction,
teamService team.TeamService, logger *zap.SugaredLogger, enforcerUtil rbac.EnforcerUtil,
logger *zap.SugaredLogger, enforcerUtil rbac.EnforcerUtil,
argoUserService argo.ArgoUserService) *BatchOperationRestHandlerImpl {
return &BatchOperationRestHandlerImpl{
userAuthService: userAuthService,
enforcer: enforcer,
workflowAction: workflowAction,
teamService: teamService,
logger: logger,
enforcerUtil: enforcerUtil,
argoUserService: argoUserService,
Expand Down
4 changes: 0 additions & 4 deletions api/restHandler/BulkUpdateRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
request "github.com/devtron-labs/devtron/pkg/cluster"
"github.com/devtron-labs/devtron/pkg/pipeline"
security2 "github.com/devtron-labs/devtron/pkg/security"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -70,7 +69,6 @@ type BulkUpdateRestHandlerImpl struct {
application application.ServiceClient
userAuthService user.UserService
validator *validator.Validate
teamService team.TeamService
enforcer casbin.Enforcer
gitSensorClient gitSensor.Client
pipelineRepository pipelineConfig.PipelineRepository
Expand All @@ -93,7 +91,6 @@ func NewBulkUpdateRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, logg
propertiesConfigService pipeline.PropertiesConfigService,
application application.ServiceClient,
userAuthService user.UserService,
teamService team.TeamService,
enforcer casbin.Enforcer,
ciHandler pipeline.CiHandler,
validator *validator.Validate,
Expand All @@ -116,7 +113,6 @@ func NewBulkUpdateRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, logg
application: application,
userAuthService: userAuthService,
validator: validator,
teamService: teamService,
enforcer: enforcer,
ciHandler: ciHandler,
gitSensorClient: gitSensorClient,
Expand Down
5 changes: 1 addition & 4 deletions api/restHandler/ConfigMapRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/devtron-labs/devtron/pkg/chart"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/gorilla/mux"
"go.uber.org/zap"
Expand Down Expand Up @@ -67,23 +66,21 @@ type ConfigMapRestHandlerImpl struct {
Logger *zap.SugaredLogger
chartService chart.ChartService
userAuthService user.UserService
teamService team.TeamService
enforcer casbin.Enforcer
pipelineRepository pipelineConfig.PipelineRepository
enforcerUtil rbac.EnforcerUtil
configMapService pipeline.ConfigMapService
}

func NewConfigMapRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger,
chartService chart.ChartService, userAuthService user.UserService, teamService team.TeamService,
chartService chart.ChartService, userAuthService user.UserService,
enforcer casbin.Enforcer, pipelineRepository pipelineConfig.PipelineRepository,
enforcerUtil rbac.EnforcerUtil, configMapService pipeline.ConfigMapService) *ConfigMapRestHandlerImpl {
return &ConfigMapRestHandlerImpl{
pipelineBuilder: pipelineBuilder,
Logger: Logger,
chartService: chartService,
userAuthService: userAuthService,
teamService: teamService,
enforcer: enforcer,
pipelineRepository: pipelineRepository,
enforcerUtil: enforcerUtil,
Expand Down
17 changes: 9 additions & 8 deletions api/restHandler/CoreAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
app2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure"
"github.com/devtron-labs/devtron/pkg/pipeline/bean/CiPipeline"
"github.com/devtron-labs/devtron/pkg/team/read"
"net/http"
"strconv"
"strings"
Expand All @@ -47,7 +48,6 @@ import (
"github.com/devtron-labs/devtron/pkg/pipeline"
bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/sql"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
Expand Down Expand Up @@ -93,10 +93,10 @@ type CoreAppRestHandlerImpl struct {
environmentRepository repository2.EnvironmentRepository
configMapRepository chartConfig.ConfigMapRepository
chartRepo chartRepoRepository.ChartRepository
teamService team.TeamService
argoUserService argo.ArgoUserService
pipelineStageService pipeline.PipelineStageService
ciPipelineRepository pipelineConfig.CiPipelineRepository
teamReadService read.TeamReadService
}

func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil,
Expand All @@ -105,8 +105,9 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
propertiesConfigService pipeline.PropertiesConfigService, appWorkflowService appWorkflow.AppWorkflowService,
materialRepository pipelineConfig.MaterialRepository, gitProviderRepo repository.GitProviderRepository,
appWorkflowRepository appWorkflow2.AppWorkflowRepository, environmentRepository repository2.EnvironmentRepository, configMapRepository chartConfig.ConfigMapRepository,
chartRepo chartRepoRepository.ChartRepository, teamService team.TeamService,
argoUserService argo.ArgoUserService, pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository) *CoreAppRestHandlerImpl {
chartRepo chartRepoRepository.ChartRepository,
argoUserService argo.ArgoUserService, pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository,
teamReadService read.TeamReadService) *CoreAppRestHandlerImpl {
handler := &CoreAppRestHandlerImpl{
logger: logger,
userAuthService: userAuthService,
Expand All @@ -127,10 +128,10 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
environmentRepository: environmentRepository,
configMapRepository: configMapRepository,
chartRepo: chartRepo,
teamService: teamService,
argoUserService: argoUserService,
pipelineStageService: pipelineStageService,
ciPipelineRepository: ciPipelineRepository,
teamReadService: teamReadService,
}
return handler
}
Expand Down Expand Up @@ -278,13 +279,13 @@ func (handler CoreAppRestHandlerImpl) CreateApp(w http.ResponseWriter, r *http.R
}

//rbac starts
team, err := handler.teamService.FindByTeamName(createAppRequest.Metadata.ProjectName)
team, err := handler.teamReadService.FindByTeamName(createAppRequest.Metadata.ProjectName)
if err != nil {
handler.logger.Errorw("Error in getting team", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
if team == nil {
if team == nil || (team != nil && team.Id == 0) {
handler.logger.Errorw("no project found by name in CreateApp request by API")
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand Down Expand Up @@ -1142,7 +1143,7 @@ func (handler CoreAppRestHandlerImpl) createBlankApp(appMetadata *appBean.AppMet
return nil, err, http.StatusBadRequest
}

team, err := handler.teamService.FindByTeamName(appMetadata.ProjectName)
team, err := handler.teamReadService.FindByTeamName(appMetadata.ProjectName)
if err != nil {
handler.logger.Infow("no project found by name in CreateApp request by API")
return nil, err, http.StatusBadRequest
Expand Down
6 changes: 2 additions & 4 deletions api/restHandler/DeploymentGroupRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
"github.com/devtron-labs/devtron/pkg/deploymentGroup"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/gorilla/mux"
"go.uber.org/zap"
Expand All @@ -50,15 +49,14 @@ type DeploymentGroupRestHandlerImpl struct {
logger *zap.SugaredLogger
validator *validator.Validate
enforcer casbin.Enforcer
teamService team.TeamService
userAuthService user.UserService
enforcerUtil rbac.EnforcerUtil
}

func NewDeploymentGroupRestHandlerImpl(deploymentGroupService deploymentGroup.DeploymentGroupService, logger *zap.SugaredLogger,
validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService, userAuthService user.UserService, enforcerUtil rbac.EnforcerUtil) *DeploymentGroupRestHandlerImpl {
validator *validator.Validate, enforcer casbin.Enforcer, userAuthService user.UserService, enforcerUtil rbac.EnforcerUtil) *DeploymentGroupRestHandlerImpl {
return &DeploymentGroupRestHandlerImpl{deploymentGroupService: deploymentGroupService, logger: logger, validator: validator,
enforcer: enforcer, teamService: teamService, userAuthService: userAuthService, enforcerUtil: enforcerUtil}
enforcer: enforcer, userAuthService: userAuthService, enforcerUtil: enforcerUtil}
}

func (impl *DeploymentGroupRestHandlerImpl) CreateDeploymentGroup(w http.ResponseWriter, r *http.Request) {
Expand Down
8 changes: 2 additions & 6 deletions api/restHandler/DockerRegRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"k8s.io/utils/strings/slices"

"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/go-pg/pg"
"github.com/gorilla/mux"
"go.uber.org/zap"
Expand Down Expand Up @@ -70,7 +69,6 @@ type DockerRegRestHandlerImpl struct {
userAuthService user.UserService
validator *validator.Validate
enforcer casbin.Enforcer
teamService team.TeamService
deleteService deleteService.DeleteService
}

Expand All @@ -79,7 +77,7 @@ func NewDockerRegRestHandlerExtendedImpl(
logger *zap.SugaredLogger,
chartProviderService chartProviderService.ChartProviderService,
userAuthService user.UserService,
validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService,
validator *validator.Validate, enforcer casbin.Enforcer,
deleteService deleteService.DeleteService,
deleteServiceFullMode deleteService.DeleteServiceFullMode) *DockerRegRestHandlerExtendedImpl {
return &DockerRegRestHandlerExtendedImpl{
Expand All @@ -91,7 +89,6 @@ func NewDockerRegRestHandlerExtendedImpl(
userAuthService: userAuthService,
validator: validator,
enforcer: enforcer,
teamService: teamService,
deleteService: deleteService,
},
}
Expand All @@ -102,7 +99,7 @@ func NewDockerRegRestHandlerImpl(
logger *zap.SugaredLogger,
chartProviderService chartProviderService.ChartProviderService,
userAuthService user.UserService,
validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService,
validator *validator.Validate, enforcer casbin.Enforcer,
deleteService deleteService.DeleteService) *DockerRegRestHandlerImpl {
return &DockerRegRestHandlerImpl{
dockerRegistryConfig: dockerRegistryConfig,
Expand All @@ -111,7 +108,6 @@ func NewDockerRegRestHandlerImpl(
userAuthService: userAuthService,
validator: validator,
enforcer: enforcer,
teamService: teamService,
deleteService: deleteService,
}
}
Expand Down
5 changes: 1 addition & 4 deletions api/restHandler/GitOpsConfigRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
"github.com/devtron-labs/devtron/pkg/gitops"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/gorilla/mux"
"go.uber.org/zap"
"gopkg.in/go-playground/validator.v9"
Expand All @@ -50,20 +49,18 @@ type GitOpsConfigRestHandlerImpl struct {
userAuthService user.UserService
validator *validator.Validate
enforcer casbin.Enforcer
teamService team.TeamService
}

func NewGitOpsConfigRestHandlerImpl(
logger *zap.SugaredLogger,
gitOpsConfigService gitops.GitOpsConfigService, userAuthService user.UserService,
validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService) *GitOpsConfigRestHandlerImpl {
validator *validator.Validate, enforcer casbin.Enforcer) *GitOpsConfigRestHandlerImpl {
return &GitOpsConfigRestHandlerImpl{
logger: logger,
gitOpsConfigService: gitOpsConfigService,
userAuthService: userAuthService,
validator: validator,
enforcer: enforcer,
teamService: teamService,
}
}

Expand Down
5 changes: 1 addition & 4 deletions api/restHandler/GitProviderRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
delete2 "github.com/devtron-labs/devtron/pkg/delete"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/pipeline/types"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/gorilla/mux"
"go.uber.org/zap"
"gopkg.in/go-playground/validator.v9"
Expand All @@ -50,15 +49,14 @@ type GitProviderRestHandlerImpl struct {
userAuthService user.UserService
validator *validator.Validate
enforcer casbin.Enforcer
teamService team.TeamService
deleteServiceFullMode delete2.DeleteServiceFullMode
}

func NewGitProviderRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistryConfig,
logger *zap.SugaredLogger,
gitRegistryConfig pipeline.GitRegistryConfig,
userAuthService user.UserService,
validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService,
validator *validator.Validate, enforcer casbin.Enforcer,
deleteServiceFullMode delete2.DeleteServiceFullMode) *GitProviderRestHandlerImpl {
return &GitProviderRestHandlerImpl{
dockerRegistryConfig: dockerRegistryConfig,
Expand All @@ -67,7 +65,6 @@ func NewGitProviderRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistryC
userAuthService: userAuthService,
validator: validator,
enforcer: enforcer,
teamService: teamService,
deleteServiceFullMode: deleteServiceFullMode,
}
}
Expand Down
17 changes: 9 additions & 8 deletions api/restHandler/NotificationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/devtron-labs/devtron/pkg/notifier"
"github.com/devtron-labs/devtron/pkg/notifier/beans"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/pkg/team/read"
util "github.com/devtron-labs/devtron/util/event"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/devtron-labs/devtron/util/response"
Expand Down Expand Up @@ -79,10 +79,10 @@ type NotificationRestHandlerImpl struct {
sesService notifier.SESNotificationService
smtpService notifier.SMTPNotificationService
enforcer casbin.Enforcer
teamService team.TeamService
environmentService cluster.EnvironmentService
pipelineBuilder pipeline.PipelineBuilder
enforcerUtil rbac.EnforcerUtil
teamReadService read.TeamReadService
}

type ChannelDto struct {
Expand All @@ -94,8 +94,9 @@ func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistry
userAuthService user.UserService,
validator *validator.Validate, notificationService notifier.NotificationConfigService,
slackService notifier.SlackNotificationService, webhookService notifier.WebhookNotificationService, sesService notifier.SESNotificationService, smtpService notifier.SMTPNotificationService,
enforcer casbin.Enforcer, teamService team.TeamService, environmentService cluster.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder,
enforcerUtil rbac.EnforcerUtil) *NotificationRestHandlerImpl {
enforcer casbin.Enforcer, environmentService cluster.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder,
enforcerUtil rbac.EnforcerUtil,
teamReadService read.TeamReadService) *NotificationRestHandlerImpl {
return &NotificationRestHandlerImpl{
dockerRegistryConfig: dockerRegistryConfig,
logger: logger,
Expand All @@ -108,10 +109,10 @@ func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistry
sesService: sesService,
smtpService: smtpService,
enforcer: enforcer,
teamService: teamService,
environmentService: environmentService,
pipelineBuilder: pipelineBuilder,
enforcerUtil: enforcerUtil,
teamReadService: teamReadService,
}
}

Expand Down Expand Up @@ -298,7 +299,7 @@ func (impl NotificationRestHandlerImpl) SaveNotificationChannelConfig(w http.Res
for _, item := range slackReq.SlackConfigDtos {
teamIds = append(teamIds, &item.TeamId)
}
teams, err := impl.teamService.FindByIds(teamIds)
teams, err := impl.teamReadService.FindByIds(teamIds)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand Down Expand Up @@ -453,7 +454,7 @@ func (impl NotificationRestHandlerImpl) FindAllNotificationConfig(w http.Respons
for _, item := range slackConfigs {
teamIds = append(teamIds, &item.TeamId)
}
teams, err := impl.teamService.FindByIds(teamIds)
teams, err := impl.teamReadService.FindByIds(teamIds)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand Down Expand Up @@ -691,7 +692,7 @@ func (impl NotificationRestHandlerImpl) FindAllNotificationConfigAutocomplete(w
return
}
for _, item := range channelsResponseAll {
team, err := impl.teamService.FetchOne(item.TeamId)
team, err := impl.teamReadService.FindOne(item.TeamId)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand Down
Loading
Loading