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

Temp: PR #6214

Closed
wants to merge 5 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
12 changes: 7 additions & 5 deletions api/restHandler/CoreAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider/read"
pipelineBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
"github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
read3 "github.com/devtron-labs/devtron/pkg/team/read"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -98,10 +99,10 @@ type CoreAppRestHandlerImpl struct {
environmentRepository repository.EnvironmentRepository
configMapRepository chartConfig.ConfigMapRepository
chartRepo chartRepoRepository.ChartRepository
teamService team.TeamService
argoUserService argo.ArgoUserService
pipelineStageService pipeline.PipelineStageService
ciPipelineRepository pipelineConfig.CiPipelineRepository
teamReadService read3.TeamReadService
}

func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil,
Expand All @@ -112,7 +113,8 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
chartRepo chartRepoRepository.ChartRepository, teamService team.TeamService,
argoUserService argo.ArgoUserService, pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository,
gitProviderReadService read.GitProviderReadService,
gitMaterialReadService read2.GitMaterialReadService) *CoreAppRestHandlerImpl {
gitMaterialReadService read2.GitMaterialReadService,
teamReadService read3.TeamReadService) *CoreAppRestHandlerImpl {
handler := &CoreAppRestHandlerImpl{
logger: logger,
userAuthService: userAuthService,
Expand All @@ -133,10 +135,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 @@ -284,7 +286,7 @@ 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)
Expand Down Expand Up @@ -1148,7 +1150,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
17 changes: 9 additions & 8 deletions api/restHandler/NotificationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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 @@ -80,10 +80,10 @@ type NotificationRestHandlerImpl struct {
sesService notifier.SESNotificationService
smtpService notifier.SMTPNotificationService
enforcer casbin.Enforcer
teamService team.TeamService
environmentService environment.EnvironmentService
pipelineBuilder pipeline.PipelineBuilder
enforcerUtil rbac.EnforcerUtil
teamReadService read.TeamReadService
}

type ChannelDto struct {
Expand All @@ -95,8 +95,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 environment.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder,
enforcerUtil rbac.EnforcerUtil) *NotificationRestHandlerImpl {
enforcer casbin.Enforcer, environmentService environment.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder,
enforcerUtil rbac.EnforcerUtil,
teamReadService read.TeamReadService) *NotificationRestHandlerImpl {
return &NotificationRestHandlerImpl{
dockerRegistryConfig: dockerRegistryConfig,
logger: logger,
Expand All @@ -109,10 +110,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 @@ -299,7 +300,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 @@ -454,7 +455,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 @@ -692,7 +693,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
9 changes: 7 additions & 2 deletions api/restHandler/app/appList/AppFilteringRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/devtron-labs/devtron/pkg/cluster/environment"
bean2 "github.com/devtron-labs/devtron/pkg/cluster/environment/bean"
"github.com/devtron-labs/devtron/pkg/team"
bean4 "github.com/devtron-labs/devtron/pkg/team/bean"
"github.com/devtron-labs/devtron/pkg/team/read"
"go.uber.org/zap"
"net/http"
"strconv"
Expand All @@ -46,6 +48,7 @@ type AppFilteringRestHandlerImpl struct {
clusterService cluster.ClusterService
environmentClusterMappingsService environment.EnvironmentService
cfg *bean.Config
teamReadService read.TeamReadService
}

func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger,
Expand All @@ -54,6 +57,7 @@ func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger,
userService user.UserService,
clusterService cluster.ClusterService,
environmentClusterMappingsService environment.EnvironmentService,
teamReadService read.TeamReadService,
) *AppFilteringRestHandlerImpl {
cfg := &bean.Config{}
err := env.Parse(cfg)
Expand All @@ -70,6 +74,7 @@ func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger,
clusterService: clusterService,
environmentClusterMappingsService: environmentClusterMappingsService,
cfg: cfg,
teamReadService: teamReadService,
}
return appFilteringRestHandler
}
Expand Down Expand Up @@ -170,7 +175,7 @@ func (handler AppFilteringRestHandlerImpl) GetClusterTeamAndEnvListForAutocomple

//getting teams for autocomplete
start = time.Now()
teams, err := handler.teamService.FetchForAutocomplete()
teams, err := handler.teamReadService.FindAllActive()
if err != nil {
handler.logger.Errorw("service err, FetchForAutocomplete at teamService layer", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand All @@ -180,7 +185,7 @@ func (handler AppFilteringRestHandlerImpl) GetClusterTeamAndEnvListForAutocomple
var grantedTeams = teams
start = time.Now()
if !handler.cfg.IgnoreAuthCheck {
grantedTeams = make([]team.TeamRequest, 0)
grantedTeams = make([]bean4.TeamRequest, 0)
// RBAC enforcer applying
var teamNameList []string
for _, item := range teams {
Expand Down
4 changes: 2 additions & 2 deletions api/restHandler/app/appList/AppListingRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import (
"github.com/devtron-labs/devtron/pkg/k8s"
application3 "github.com/devtron-labs/devtron/pkg/k8s/application"
"github.com/devtron-labs/devtron/pkg/pipeline"
"github.com/devtron-labs/devtron/pkg/team"
bean6 "github.com/devtron-labs/devtron/pkg/team/bean"
util2 "github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
Expand Down Expand Up @@ -125,7 +125,7 @@ type AppStatus struct {
}

type AppAutocomplete struct {
Teams []team.TeamRequest
Teams []bean6.TeamRequest
Environments []bean2.EnvironmentBean
Clusters []bean5.ClusterBean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef"
security2 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning"
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/read"
read3 "github.com/devtron-labs/devtron/pkg/team/read"
"io"
"net/http"
"strconv"
Expand Down Expand Up @@ -134,6 +135,7 @@ type PipelineConfigRestHandlerImpl struct {
deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService
chartRefService chartRef.ChartRefService
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator
teamReadService read3.TeamReadService
}

func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger,
Expand Down Expand Up @@ -164,7 +166,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService,
chartRefService chartRef.ChartRefService,
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator,
gitProviderReadService gitProviderRead.GitProviderReadService) *PipelineConfigRestHandlerImpl {
gitProviderReadService gitProviderRead.GitProviderReadService,
teamReadService read3.TeamReadService) *PipelineConfigRestHandlerImpl {
envConfig := &PipelineRestHandlerEnvConfig{}
err := env.Parse(envConfig)
if err != nil {
Expand Down Expand Up @@ -204,6 +207,7 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
chartRefService: chartRefService,
ciCdPipelineOrchestrator: ciCdPipelineOrchestrator,
gitProviderReadService: gitProviderReadService,
teamReadService: teamReadService,
}
}

Expand Down Expand Up @@ -360,7 +364,7 @@ func (handler *PipelineConfigRestHandlerImpl) CreateApp(w http.ResponseWriter, r
return
}

project, err := handler.teamService.FetchOne(createRequest.TeamId)
project, err := handler.teamReadService.FindOne(createRequest.TeamId)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (handler PipelineTriggerRestHandlerImpl) OverrideConfig(w http.ResponseWrit
triggerContext := bean3.TriggerContext{
Context: ctx,
}
mergeResp, helmPackageName, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest)
mergeResp, helmPackageName, _, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest)
span.End()
if err != nil {
handler.logger.Errorw("request err, OverrideConfig", "err", err, "payload", overrideRequest)
Expand Down
11 changes: 6 additions & 5 deletions api/team/TeamRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package team
import (
"encoding/json"
"fmt"
bean2 "github.com/devtron-labs/devtron/pkg/team/bean"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -93,7 +94,7 @@ func (impl TeamRestHandlerImpl) SaveTeam(w http.ResponseWriter, r *http.Request)
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var bean team.TeamRequest
var bean bean2.TeamRequest
err = decoder.Decode(&bean)
if err != nil {
impl.logger.Errorw("request err, SaveTeam", "err", err, "payload", bean)
Expand Down Expand Up @@ -132,7 +133,7 @@ func (impl TeamRestHandlerImpl) FetchAll(w http.ResponseWriter, r *http.Request)
return
}
// RBAC enforcer applying
var result []team.TeamRequest
var result []bean2.TeamRequest
for _, item := range res {
if ok := impl.enforcer.Enforce(token, casbin.ResourceTeam, casbin.ActionGet, item.Name); ok {
result = append(result, item)
Expand Down Expand Up @@ -176,7 +177,7 @@ func (impl TeamRestHandlerImpl) UpdateTeam(w http.ResponseWriter, r *http.Reques
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var bean team.TeamRequest
var bean bean2.TeamRequest
err = decoder.Decode(&bean)
if err != nil {
impl.logger.Errorw("request err, UpdateTeam", "err", err, "bean", bean)
Expand Down Expand Up @@ -212,7 +213,7 @@ func (impl TeamRestHandlerImpl) DeleteTeam(w http.ResponseWriter, r *http.Reques
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
var deleteRequest team.TeamRequest
var deleteRequest bean2.TeamRequest
err = decoder.Decode(&deleteRequest)
if err != nil {
impl.logger.Errorw("request err, DeleteTeam", "err", err, "deleteRequest", deleteRequest)
Expand Down Expand Up @@ -261,7 +262,7 @@ func (impl TeamRestHandlerImpl) FetchForAutocomplete(w http.ResponseWriter, r *h
var grantedTeams = teams
start = time.Now()
if !impl.cfg.IgnoreAuthCheck {
grantedTeams = make([]team.TeamRequest, 0)
grantedTeams = make([]bean2.TeamRequest, 0)
// RBAC enforcer applying
var teamNameList []string
for _, item := range teams {
Expand Down
8 changes: 6 additions & 2 deletions api/team/wire_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ package team

import (
"github.com/devtron-labs/devtron/pkg/team"
"github.com/devtron-labs/devtron/pkg/team/read"
"github.com/devtron-labs/devtron/pkg/team/repository"
"github.com/google/wire"
)

//depends on sql,
//TODO integrate user auth module

var TeamsWireSet = wire.NewSet(
team.NewTeamRepositoryImpl,
wire.Bind(new(team.TeamRepository), new(*team.TeamRepositoryImpl)),
repository.NewTeamRepositoryImpl,
wire.Bind(new(repository.TeamRepository), new(*repository.TeamRepositoryImpl)),
team.NewTeamServiceImpl,
wire.Bind(new(team.TeamService), new(*team.TeamServiceImpl)),
NewTeamRestHandlerImpl,
wire.Bind(new(TeamRestHandler), new(*TeamRestHandlerImpl)),
NewTeamRouterImpl,
wire.Bind(new(TeamRouter), new(*TeamRouterImpl)),
read.NewTeamReadService,
wire.Bind(new(read.TeamReadService), new(*read.TeamReadServiceImpl)),
)
Loading
Loading