Fix: filter app by app_id

Signed-off-by: LiHui <andrewli@yunify.com>
This commit is contained in:
zryfish
2021-04-13 15:42:16 +08:00
committed by LiHui
parent 26e5c31d8f
commit 1031853757
2 changed files with 17 additions and 4 deletions

View File

@@ -406,10 +406,6 @@ func (h *openpitrixHandler) ListApps(req *restful.Request, resp *restful.Respons
conditions.Match[openpitrix.WorkspaceLabel] = req.PathParameter("workspace")
}
if conditions.Match[openpitrix.WorkspaceLabel] == "" {
conditions.Match[openpitrix.WorkspaceLabel] = req.QueryParameter("workspace")
}
result, err := h.openpitrix.ListApps(conditions, orderBy, reverse, limit, offset)
if err != nil {

View File

@@ -673,6 +673,17 @@ func filterApps(apps []*v1alpha1.HelmApplication, conditions *params.Conditions)
return apps
}
// filter app by param app_id
appIdMap := make(map[string]string)
if len(conditions.Match[AppId]) > 0 {
ids := strings.Split(conditions.Match[AppId], "|")
for _, id := range ids {
if len(id) > 0 {
appIdMap[id] = ""
}
}
}
curr := 0
for i := 0; i < len(apps); i++ {
if conditions.Match[Keyword] != "" {
@@ -682,6 +693,12 @@ func filterApps(apps []*v1alpha1.HelmApplication, conditions *params.Conditions)
}
}
if len(appIdMap) > 0 {
if _, exists := appIdMap[apps[i].Name]; !exists {
continue
}
}
if conditions.Match[Status] != "" {
states := strings.Split(conditions.Match[Status], "|")
fv := filterAppByStates(apps[i], states)