Skip to content

Commit 48e814e

Browse files
Merge pull request #6210 from devtron-labs/main-sync-develop-20dec
misc: Main sync develop 20dec
2 parents 1c7a4f6 + 7789ec9 commit 48e814e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1045
-644
lines changed

api/restHandler/CoreAppRestHandler.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider/read"
3131
pipelineBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
3232
"github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
33+
read3 "github.com/devtron-labs/devtron/pkg/team/read"
3334
"net/http"
3435
"strconv"
3536
"strings"
@@ -98,10 +99,10 @@ type CoreAppRestHandlerImpl struct {
9899
environmentRepository repository.EnvironmentRepository
99100
configMapRepository chartConfig.ConfigMapRepository
100101
chartRepo chartRepoRepository.ChartRepository
101-
teamService team.TeamService
102102
argoUserService argo.ArgoUserService
103103
pipelineStageService pipeline.PipelineStageService
104104
ciPipelineRepository pipelineConfig.CiPipelineRepository
105+
teamReadService read3.TeamReadService
105106
}
106107

107108
func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil,
@@ -112,7 +113,8 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
112113
chartRepo chartRepoRepository.ChartRepository, teamService team.TeamService,
113114
argoUserService argo.ArgoUserService, pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository,
114115
gitProviderReadService read.GitProviderReadService,
115-
gitMaterialReadService read2.GitMaterialReadService) *CoreAppRestHandlerImpl {
116+
gitMaterialReadService read2.GitMaterialReadService,
117+
teamReadService read3.TeamReadService) *CoreAppRestHandlerImpl {
116118
handler := &CoreAppRestHandlerImpl{
117119
logger: logger,
118120
userAuthService: userAuthService,
@@ -133,10 +135,10 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
133135
environmentRepository: environmentRepository,
134136
configMapRepository: configMapRepository,
135137
chartRepo: chartRepo,
136-
teamService: teamService,
137138
argoUserService: argoUserService,
138139
pipelineStageService: pipelineStageService,
139140
ciPipelineRepository: ciPipelineRepository,
141+
teamReadService: teamReadService,
140142
}
141143
return handler
142144
}
@@ -284,7 +286,7 @@ func (handler CoreAppRestHandlerImpl) CreateApp(w http.ResponseWriter, r *http.R
284286
}
285287

286288
//rbac starts
287-
team, err := handler.teamService.FindByTeamName(createAppRequest.Metadata.ProjectName)
289+
team, err := handler.teamReadService.FindByTeamName(createAppRequest.Metadata.ProjectName)
288290
if err != nil {
289291
handler.logger.Errorw("Error in getting team", "err", err)
290292
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
@@ -1148,7 +1150,7 @@ func (handler CoreAppRestHandlerImpl) createBlankApp(appMetadata *appBean.AppMet
11481150
return nil, err, http.StatusBadRequest
11491151
}
11501152

1151-
team, err := handler.teamService.FindByTeamName(appMetadata.ProjectName)
1153+
team, err := handler.teamReadService.FindByTeamName(appMetadata.ProjectName)
11521154
if err != nil {
11531155
handler.logger.Infow("no project found by name in CreateApp request by API")
11541156
return nil, err, http.StatusBadRequest

api/restHandler/NotificationRestHandler.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/devtron-labs/devtron/pkg/notifier"
3131
"github.com/devtron-labs/devtron/pkg/notifier/beans"
3232
"github.com/devtron-labs/devtron/pkg/pipeline"
33-
"github.com/devtron-labs/devtron/pkg/team"
33+
"github.com/devtron-labs/devtron/pkg/team/read"
3434
util "github.com/devtron-labs/devtron/util/event"
3535
"github.com/devtron-labs/devtron/util/rbac"
3636
"github.com/devtron-labs/devtron/util/response"
@@ -80,10 +80,10 @@ type NotificationRestHandlerImpl struct {
8080
sesService notifier.SESNotificationService
8181
smtpService notifier.SMTPNotificationService
8282
enforcer casbin.Enforcer
83-
teamService team.TeamService
8483
environmentService environment.EnvironmentService
8584
pipelineBuilder pipeline.PipelineBuilder
8685
enforcerUtil rbac.EnforcerUtil
86+
teamReadService read.TeamReadService
8787
}
8888

8989
type ChannelDto struct {
@@ -95,8 +95,9 @@ func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistry
9595
userAuthService user.UserService,
9696
validator *validator.Validate, notificationService notifier.NotificationConfigService,
9797
slackService notifier.SlackNotificationService, webhookService notifier.WebhookNotificationService, sesService notifier.SESNotificationService, smtpService notifier.SMTPNotificationService,
98-
enforcer casbin.Enforcer, teamService team.TeamService, environmentService environment.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder,
99-
enforcerUtil rbac.EnforcerUtil) *NotificationRestHandlerImpl {
98+
enforcer casbin.Enforcer, environmentService environment.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder,
99+
enforcerUtil rbac.EnforcerUtil,
100+
teamReadService read.TeamReadService) *NotificationRestHandlerImpl {
100101
return &NotificationRestHandlerImpl{
101102
dockerRegistryConfig: dockerRegistryConfig,
102103
logger: logger,
@@ -109,10 +110,10 @@ func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistry
109110
sesService: sesService,
110111
smtpService: smtpService,
111112
enforcer: enforcer,
112-
teamService: teamService,
113113
environmentService: environmentService,
114114
pipelineBuilder: pipelineBuilder,
115115
enforcerUtil: enforcerUtil,
116+
teamReadService: teamReadService,
116117
}
117118
}
118119

@@ -299,7 +300,7 @@ func (impl NotificationRestHandlerImpl) SaveNotificationChannelConfig(w http.Res
299300
for _, item := range slackReq.SlackConfigDtos {
300301
teamIds = append(teamIds, &item.TeamId)
301302
}
302-
teams, err := impl.teamService.FindByIds(teamIds)
303+
teams, err := impl.teamReadService.FindByIds(teamIds)
303304
if err != nil {
304305
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
305306
return
@@ -454,7 +455,7 @@ func (impl NotificationRestHandlerImpl) FindAllNotificationConfig(w http.Respons
454455
for _, item := range slackConfigs {
455456
teamIds = append(teamIds, &item.TeamId)
456457
}
457-
teams, err := impl.teamService.FindByIds(teamIds)
458+
teams, err := impl.teamReadService.FindByIds(teamIds)
458459
if err != nil {
459460
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
460461
return
@@ -692,7 +693,7 @@ func (impl NotificationRestHandlerImpl) FindAllNotificationConfigAutocomplete(w
692693
return
693694
}
694695
for _, item := range channelsResponseAll {
695-
team, err := impl.teamService.FetchOne(item.TeamId)
696+
team, err := impl.teamReadService.FindOne(item.TeamId)
696697
if err != nil {
697698
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
698699
return

api/restHandler/app/appList/AppFilteringRestHandler.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"github.com/devtron-labs/devtron/pkg/cluster/environment"
2828
bean2 "github.com/devtron-labs/devtron/pkg/cluster/environment/bean"
2929
"github.com/devtron-labs/devtron/pkg/team"
30+
bean4 "github.com/devtron-labs/devtron/pkg/team/bean"
31+
"github.com/devtron-labs/devtron/pkg/team/read"
3032
"go.uber.org/zap"
3133
"net/http"
3234
"strconv"
@@ -46,6 +48,7 @@ type AppFilteringRestHandlerImpl struct {
4648
clusterService cluster.ClusterService
4749
environmentClusterMappingsService environment.EnvironmentService
4850
cfg *bean.Config
51+
teamReadService read.TeamReadService
4952
}
5053

5154
func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger,
@@ -54,6 +57,7 @@ func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger,
5457
userService user.UserService,
5558
clusterService cluster.ClusterService,
5659
environmentClusterMappingsService environment.EnvironmentService,
60+
teamReadService read.TeamReadService,
5761
) *AppFilteringRestHandlerImpl {
5862
cfg := &bean.Config{}
5963
err := env.Parse(cfg)
@@ -70,6 +74,7 @@ func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger,
7074
clusterService: clusterService,
7175
environmentClusterMappingsService: environmentClusterMappingsService,
7276
cfg: cfg,
77+
teamReadService: teamReadService,
7378
}
7479
return appFilteringRestHandler
7580
}
@@ -170,7 +175,7 @@ func (handler AppFilteringRestHandlerImpl) GetClusterTeamAndEnvListForAutocomple
170175

171176
//getting teams for autocomplete
172177
start = time.Now()
173-
teams, err := handler.teamService.FetchForAutocomplete()
178+
teams, err := handler.teamReadService.FindAllActive()
174179
if err != nil {
175180
handler.logger.Errorw("service err, FetchForAutocomplete at teamService layer", "err", err)
176181
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
@@ -180,7 +185,7 @@ func (handler AppFilteringRestHandlerImpl) GetClusterTeamAndEnvListForAutocomple
180185
var grantedTeams = teams
181186
start = time.Now()
182187
if !handler.cfg.IgnoreAuthCheck {
183-
grantedTeams = make([]team.TeamRequest, 0)
188+
grantedTeams = make([]bean4.TeamRequest, 0)
184189
// RBAC enforcer applying
185190
var teamNameList []string
186191
for _, item := range teams {

api/restHandler/app/appList/AppListingRestHandler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import (
5959
"github.com/devtron-labs/devtron/pkg/k8s"
6060
application3 "github.com/devtron-labs/devtron/pkg/k8s/application"
6161
"github.com/devtron-labs/devtron/pkg/pipeline"
62-
"github.com/devtron-labs/devtron/pkg/team"
62+
bean6 "github.com/devtron-labs/devtron/pkg/team/bean"
6363
util2 "github.com/devtron-labs/devtron/util"
6464
"github.com/devtron-labs/devtron/util/argo"
6565
"github.com/devtron-labs/devtron/util/rbac"
@@ -125,7 +125,7 @@ type AppStatus struct {
125125
}
126126

127127
type AppAutocomplete struct {
128-
Teams []team.TeamRequest
128+
Teams []bean6.TeamRequest
129129
Environments []bean2.EnvironmentBean
130130
Clusters []bean5.ClusterBean
131131
}

api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef"
3333
security2 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning"
3434
"github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/read"
35+
read3 "github.com/devtron-labs/devtron/pkg/team/read"
3536
"io"
3637
"net/http"
3738
"strconv"
@@ -134,6 +135,7 @@ type PipelineConfigRestHandlerImpl struct {
134135
deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService
135136
chartRefService chartRef.ChartRefService
136137
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator
138+
teamReadService read3.TeamReadService
137139
}
138140

139141
func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger,
@@ -164,7 +166,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
164166
deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService,
165167
chartRefService chartRef.ChartRefService,
166168
ciCdPipelineOrchestrator pipeline.CiCdPipelineOrchestrator,
167-
gitProviderReadService gitProviderRead.GitProviderReadService) *PipelineConfigRestHandlerImpl {
169+
gitProviderReadService gitProviderRead.GitProviderReadService,
170+
teamReadService read3.TeamReadService) *PipelineConfigRestHandlerImpl {
168171
envConfig := &PipelineRestHandlerEnvConfig{}
169172
err := env.Parse(envConfig)
170173
if err != nil {
@@ -204,6 +207,7 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger
204207
chartRefService: chartRefService,
205208
ciCdPipelineOrchestrator: ciCdPipelineOrchestrator,
206209
gitProviderReadService: gitProviderReadService,
210+
teamReadService: teamReadService,
207211
}
208212
}
209213

@@ -360,7 +364,7 @@ func (handler *PipelineConfigRestHandlerImpl) CreateApp(w http.ResponseWriter, r
360364
return
361365
}
362366

363-
project, err := handler.teamService.FetchOne(createRequest.TeamId)
367+
project, err := handler.teamReadService.FindOne(createRequest.TeamId)
364368
if err != nil {
365369
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
366370
return

api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (handler PipelineTriggerRestHandlerImpl) OverrideConfig(w http.ResponseWrit
150150
triggerContext := bean3.TriggerContext{
151151
Context: ctx,
152152
}
153-
mergeResp, helmPackageName, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest)
153+
mergeResp, helmPackageName, _, err := handler.cdTriggerService.ManualCdTrigger(triggerContext, &overrideRequest)
154154
span.End()
155155
if err != nil {
156156
handler.logger.Errorw("request err, OverrideConfig", "err", err, "payload", overrideRequest)

api/team/TeamRestHandler.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package team
1919
import (
2020
"encoding/json"
2121
"fmt"
22+
bean2 "github.com/devtron-labs/devtron/pkg/team/bean"
2223
"net/http"
2324
"strconv"
2425
"strings"
@@ -93,7 +94,7 @@ func (impl TeamRestHandlerImpl) SaveTeam(w http.ResponseWriter, r *http.Request)
9394
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
9495
return
9596
}
96-
var bean team.TeamRequest
97+
var bean bean2.TeamRequest
9798
err = decoder.Decode(&bean)
9899
if err != nil {
99100
impl.logger.Errorw("request err, SaveTeam", "err", err, "payload", bean)
@@ -132,7 +133,7 @@ func (impl TeamRestHandlerImpl) FetchAll(w http.ResponseWriter, r *http.Request)
132133
return
133134
}
134135
// RBAC enforcer applying
135-
var result []team.TeamRequest
136+
var result []bean2.TeamRequest
136137
for _, item := range res {
137138
if ok := impl.enforcer.Enforce(token, casbin.ResourceTeam, casbin.ActionGet, item.Name); ok {
138139
result = append(result, item)
@@ -176,7 +177,7 @@ func (impl TeamRestHandlerImpl) UpdateTeam(w http.ResponseWriter, r *http.Reques
176177
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
177178
return
178179
}
179-
var bean team.TeamRequest
180+
var bean bean2.TeamRequest
180181
err = decoder.Decode(&bean)
181182
if err != nil {
182183
impl.logger.Errorw("request err, UpdateTeam", "err", err, "bean", bean)
@@ -212,7 +213,7 @@ func (impl TeamRestHandlerImpl) DeleteTeam(w http.ResponseWriter, r *http.Reques
212213
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
213214
return
214215
}
215-
var deleteRequest team.TeamRequest
216+
var deleteRequest bean2.TeamRequest
216217
err = decoder.Decode(&deleteRequest)
217218
if err != nil {
218219
impl.logger.Errorw("request err, DeleteTeam", "err", err, "deleteRequest", deleteRequest)
@@ -261,7 +262,7 @@ func (impl TeamRestHandlerImpl) FetchForAutocomplete(w http.ResponseWriter, r *h
261262
var grantedTeams = teams
262263
start = time.Now()
263264
if !impl.cfg.IgnoreAuthCheck {
264-
grantedTeams = make([]team.TeamRequest, 0)
265+
grantedTeams = make([]bean2.TeamRequest, 0)
265266
// RBAC enforcer applying
266267
var teamNameList []string
267268
for _, item := range teams {

api/team/wire_team.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ package team
1818

1919
import (
2020
"github.com/devtron-labs/devtron/pkg/team"
21+
"github.com/devtron-labs/devtron/pkg/team/read"
22+
"github.com/devtron-labs/devtron/pkg/team/repository"
2123
"github.com/google/wire"
2224
)
2325

2426
//depends on sql,
2527
//TODO integrate user auth module
2628

2729
var TeamsWireSet = wire.NewSet(
28-
team.NewTeamRepositoryImpl,
29-
wire.Bind(new(team.TeamRepository), new(*team.TeamRepositoryImpl)),
30+
repository.NewTeamRepositoryImpl,
31+
wire.Bind(new(repository.TeamRepository), new(*repository.TeamRepositoryImpl)),
3032
team.NewTeamServiceImpl,
3133
wire.Bind(new(team.TeamService), new(*team.TeamServiceImpl)),
3234
NewTeamRestHandlerImpl,
3335
wire.Bind(new(TeamRestHandler), new(*TeamRestHandlerImpl)),
3436
NewTeamRouterImpl,
3537
wire.Bind(new(TeamRouter), new(*TeamRouterImpl)),
38+
read.NewTeamReadService,
39+
wire.Bind(new(read.TeamReadService), new(*read.TeamReadServiceImpl)),
3640
)

0 commit comments

Comments
 (0)