Skip to content

Commit 7a36320

Browse files
committed
Merge branch 'hibernated-fix' into hibernated-fix-refact
2 parents 7b9cc28 + ba51241 commit 7a36320

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

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

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

22132213
resp, err := handler.pipelineBuilder.GetAppMetadataListByEnvironment(envId, appIds)
22142214
if err != nil {
2215-
handler.Logger.Errorw("service err, GetAppMetadataListByEnvironment", "err", err, "envId", envId)
2215+
handler.Logger.Errorw("service err, GetAppMetadataListByEnvironment", "envId", envId, "err", err)
22162216
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
22172217
return
22182218
}
@@ -2231,12 +2231,7 @@ func (handler *PipelineConfigRestHandlerImpl) GetAppMetadataListByEnvironment(w
22312231

22322232
// get rbac objects for the appids
22332233
rbacObjectsWithAppId := handler.enforcerUtil.GetRbacObjectsByAppIds(appIds)
2234-
rbacObjects := make([]string, len(rbacObjectsWithAppId))
2235-
itr := 0
2236-
for _, object := range rbacObjectsWithAppId {
2237-
rbacObjects[itr] = object
2238-
itr++
2239-
}
2234+
rbacObjects := maps.Values(rbacObjectsWithAppId)
22402235
// enforce rbac in batch
22412236
rbacResult := handler.enforcer.EnforceInBatch(token, casbin.ResourceApplications, casbin.ActionGet, rbacObjects)
22422237
// filter out rbac passed apps

env_gen.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

env_gen.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
| DEX_CSTOREKEY | string | | | | false |
169169
| DEX_JWTKEY | string | | | | false |
170170
| DEX_RURL | string |http://127.0.0.1:8080/callback | | | false |
171+
| DEX_SCOPES | | | | | false |
171172
| DEX_SECRET | string | | | | false |
172173
| DEX_URL | string | | | | false |
173174
| ECR_REPO_NAME_PREFIX | string |test/ | | | false |

internal/sql/repository/AppListingRepository.go

Lines changed: 6 additions & 7 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,15 +137,16 @@ 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 = ?
144144
LEFT JOIN app_status aps ON aps.app_id = a.id and aps.env_id = ?
145145
LEFT JOIN
146146
(SELECT pco.pipeline_id,MAX(pco.created_on) as last_deployed_time from pipeline_config_override pco
147147
GROUP BY pco.pipeline_id) ld ON ld.pipeline_id = p.id
148-
WHERE a.active = true`
148+
WHERE a.active = true
149+
ORDER BY a.app_name `
149150

150151
queryParams := []interface{}{envId, envId}
151152

@@ -155,14 +156,12 @@ func (impl *AppListingRepositoryImpl) FetchAppsEnvContainers(envId int, limit, o
155156
queryParams = append(queryParams, pg.In(appIds))
156157
}
157158

158-
query += " ORDER BY a.app_name"
159-
160159
if limit > 0 {
161-
query += " LIMIT ?"
160+
query += fmt.Sprintf("LIMIT ? ")
162161
queryParams = append(queryParams, limit)
163162
}
164163
if offset > 0 {
165-
query += " OFFSET ?"
164+
query += fmt.Sprintf("OFFSET ? ")
166165
queryParams = append(queryParams, offset)
167166
}
168167

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

wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)