From bc7ea7c9de829a5ee04a84c4bd206ecd88892986 Mon Sep 17 00:00:00 2001 From: Sai Date: Tue, 17 Dec 2024 17:45:18 +0800 Subject: [PATCH] try fix i18n no data --- internal/appmgr/cache_for_api.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/internal/appmgr/cache_for_api.go b/internal/appmgr/cache_for_api.go index bb55732..b88c86f 100644 --- a/internal/appmgr/cache_for_api.go +++ b/internal/appmgr/cache_for_api.go @@ -252,6 +252,17 @@ func ReadCacheApplicationsWithMap(names []string) map[string]*models.Application result := make(map[string]*models.ApplicationInfo) + // If names is an empty array, return all data + if len(names) == 0 { + for _, app := range cacheApplications { + copyApp := deepCopyApplication(app) + result[app.Name] = copyApp + } + glog.Infof("---------->on ReadCacheApplicationsWithMap: Returning all applications, count: %s", len(result)) + return result + } + + // Otherwise, return the specified applications by name for _, name := range names { for _, app := range cacheApplications { if app.Name == name { @@ -267,6 +278,27 @@ func ReadCacheApplicationsWithMap(names []string) map[string]*models.Application return result } +// func ReadCacheApplicationsWithMap(names []string) map[string]*models.ApplicationInfo { +// mu.Lock() // Lock to ensure thread safety +// defer mu.Unlock() + +// result := make(map[string]*models.ApplicationInfo) + +// for _, name := range names { +// for _, app := range cacheApplications { +// if app.Name == name { +// copyApp := deepCopyApplication(app) +// result[name] = copyApp +// break +// } +// } +// } + +// glog.Infof("---------->on ReadCacheApplicationsWithMap: %s", len(result)) + +// return result +// } + func updateCacheI18n() { for _, app := range cacheApplications { i18nData := getAppI18n(app.ChartName, app.Locale)