Skip to content

Commit b0c54b9

Browse files
committed
GetAppMetadataListByEnvironment
1 parent 2598130 commit b0c54b9

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ func (handler *PipelineConfigRestHandlerImpl) GetAppMetadataListByEnvironment(w
23272327

23282328
resp, err := handler.pipelineBuilder.GetAppMetadataListByEnvironment(envId, appIds)
23292329
if err != nil {
2330-
handler.Logger.Errorw("service err, GetAppMetadataListByEnvironment", "err", err, "envId", envId)
2330+
handler.Logger.Errorw("service err, GetAppMetadataListByEnvironment", "envId", envId, "err", err)
23312331
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
23322332
return
23332333
}
@@ -2346,12 +2346,7 @@ func (handler *PipelineConfigRestHandlerImpl) GetAppMetadataListByEnvironment(w
23462346

23472347
// get rbac objects for the appids
23482348
rbacObjectsWithAppId := handler.enforcerUtil.GetRbacObjectsByAppIds(appIds)
2349-
rbacObjects := make([]string, len(rbacObjectsWithAppId))
2350-
itr := 0
2351-
for _, object := range rbacObjectsWithAppId {
2352-
rbacObjects[itr] = object
2353-
itr++
2354-
}
2349+
rbacObjects := maps.Values(rbacObjectsWithAppId)
23552350
// enforce rbac in batch
23562351
rbacResult := handler.enforcer.EnforceInBatch(token, casbin.ResourceApplications, casbin.ActionGet, rbacObjects)
23572352
// filter out rbac passed apps

internal/sql/repository/AppListingRepository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type AppListingRepository interface {
5151
DeploymentDetailByArtifactId(ciArtifactId int, envId int) (AppView.DeploymentDetailContainer, error)
5252
FindAppCount(isProd bool) (int, error)
5353
FetchAppsByEnvironmentV2(appListingFilter helper.AppListingFilter) ([]*AppView.AppEnvironmentContainer, int, error)
54-
FetchAppsEnvContainers(envId, limit, offset int, appIds []int) ([]*AppView.AppEnvironmentContainer, error)
54+
FetchAppsEnvContainers(envId int, appIds []int, limit, offset int) ([]*AppView.AppEnvironmentContainer, error)
5555
FetchLastDeployedImage(appId, envId int) (*LastDeployed, error)
5656
}
5757

@@ -137,7 +137,7 @@ func (impl *AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*Ap
137137
return jobContainers, nil
138138
}
139139

140-
func (impl *AppListingRepositoryImpl) FetchAppsEnvContainers(envId int, limit, offset int, appIds []int) ([]*AppView.AppEnvironmentContainer, error) {
140+
func (impl *AppListingRepositoryImpl) FetchAppsEnvContainers(envId int, appIds []int, limit, offset int) ([]*AppView.AppEnvironmentContainer, error) {
141141
query := ` SELECT a.id as app_id,a.app_name,aps.status as app_status, ld.last_deployed_time, p.id as pipeline_id
142142
FROM app a
143143
INNER JOIN pipeline p ON p.app_id = a.id and p.deleted = false and p.environment_id = ?

pkg/app/AppListingService.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type AppListingService interface {
7373

7474
FetchAppsByEnvironmentV2(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*AppView.AppEnvironmentContainer, int, error)
7575
FetchOverviewAppsByEnvironment(envId, limit, offset int) (*OverviewAppsByEnvironmentBean, error)
76-
FetchAppsEnvContainers(envId, limit, offset int, appIds []int) ([]*AppView.AppEnvironmentContainer, error)
76+
FetchAppsEnvContainers(envId int, appIds []int, limit, offset int) ([]*AppView.AppEnvironmentContainer, error)
7777
}
7878

7979
const (
@@ -236,7 +236,7 @@ func (impl AppListingServiceImpl) FetchOverviewAppsByEnvironment(envId, limit, o
236236
}
237237
}
238238
var appIds []int
239-
envContainers, err := impl.FetchAppsEnvContainers(envId, limit, offset, appIds)
239+
envContainers, err := impl.FetchAppsEnvContainers(envId, appIds, limit, offset)
240240
if err != nil {
241241
impl.Logger.Errorw("failed to fetch env containers", "err", err, "envId", envId)
242242
return resp, err
@@ -290,8 +290,8 @@ func getUniqueArtifacts(artifactIds []int) (uniqueArtifactIds []int) {
290290
return uniqueArtifactIds
291291
}
292292

293-
func (impl AppListingServiceImpl) FetchAppsEnvContainers(envId, limit, offset int, appIds []int) ([]*AppView.AppEnvironmentContainer, error) {
294-
envContainers, err := impl.appListingRepository.FetchAppsEnvContainers(envId, limit, offset, appIds)
293+
func (impl AppListingServiceImpl) FetchAppsEnvContainers(envId int, appIds []int, limit, offset int) ([]*AppView.AppEnvironmentContainer, error) {
294+
envContainers, err := impl.appListingRepository.FetchAppsEnvContainers(envId, appIds, limit, offset)
295295
if err != nil {
296296
impl.Logger.Errorw("failed to fetch environment containers", "err", err, "envId", envId)
297297
return nil, err

pkg/pipeline/BuildPipelineConfigService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ func (impl *CiPipelineConfigServiceImpl) CreateExternalCiAndAppWorkflowMapping(a
21652165

21662166
func (impl *CiPipelineConfigServiceImpl) GetAppMetadataListByEnvironment(envId int, appIds []int) (appMetadataListBean pipelineConfigBean.AppMetadataListBean, err error) {
21672167
appMetadataListBean = pipelineConfigBean.AppMetadataListBean{}
2168-
envContainers, err := impl.appListingService.FetchAppsEnvContainers(envId, 0, 0, appIds)
2168+
envContainers, err := impl.appListingService.FetchAppsEnvContainers(envId, appIds, 0, 0)
21692169
if err != nil {
21702170
impl.logger.Errorw("failed to fetch env containers", "err", err, "envId", envId)
21712171
return appMetadataListBean, err

0 commit comments

Comments
 (0)