Skip to content
Merged
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
32 changes: 22 additions & 10 deletions api/restHandler/AppListingRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ func (handler AppListingRestHandlerImpl) FetchAppDetails(w http.ResponseWriter,
common.WriteJsonResp(w, err, "pipeline Not found in database", http.StatusNotFound)
return
}
if err != nil {
handler.logger.Errorw("error in fetching pipelines from db", "appId", appId, "envId", envId)
common.WriteJsonResp(w, err, "error in fetching pipeline from database", http.StatusInternalServerError)
return
}
if len(pipelines) == 0 {
common.WriteJsonResp(w, fmt.Errorf("app deleted"), nil, http.StatusNotFound)
return
Expand Down Expand Up @@ -700,16 +705,7 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite
common.WriteJsonResp(w, fmt.Errorf("error in parsing envId : %s must be integer", envIdParam), nil, http.StatusBadRequest)
return
}
pipelines, err := handler.pipelineRepository.FindActiveByAppIdAndEnvironmentId(appId, envId)
if err == pg.ErrNoRows {
common.WriteJsonResp(w, err, "pipeline Not found in database", http.StatusNotFound)
return
}
if len(pipelines) != 1 {
common.WriteJsonResp(w, err, "multiple pipelines found for an envId", http.StatusBadRequest)
return
}
cdPipeline := pipelines[0]

appDetail, err, appId = handler.getAppDetails(r.Context(), appIdParam, installedAppIdParam, envId)
if err != nil {
handler.logger.Errorw("error occurred while getting app details", "appId", appIdParam, "installedAppId", installedAppIdParam, "envId", envId)
Expand Down Expand Up @@ -742,6 +738,22 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite
common.WriteJsonResp(w, fmt.Errorf("error in getting acd token"), nil, http.StatusInternalServerError)
return
}
pipelines, err := handler.pipelineRepository.FindActiveByAppIdAndEnvironmentId(appId, envId)
if err != nil && err != pg.ErrNoRows {
handler.logger.Errorw("error in fetching pipelines from db", "appId", appId, "envId", envId)
common.WriteJsonResp(w, err, "error in fetching pipelines from db", http.StatusInternalServerError)
return
}
if len(pipelines) == 0 {
common.WriteJsonResp(w, err, "deployment not found, unable to fetch resource tree", http.StatusNotFound)
return
}
if len(pipelines) > 1 {
common.WriteJsonResp(w, err, "multiple pipelines found for an envId", http.StatusBadRequest)
return
}

cdPipeline := pipelines[0]
appDetail, err = handler.fetchResourceTree(w, r, appId, envId, appDetail, acdToken, cdPipeline)
}

Expand Down