@@ -40,8 +40,9 @@ func (h *handlers) getAppConfig(ctx *fiber.Ctx) error {
4040 "message" : fmt .Sprintf ("Application not found" ),
4141 })
4242 }
43+ username := ctx .Locals ("username" ).(string )
4344
44- path := getAppPath (app )
45+ path := getAppPath (username , app )
4546 appCfgPath := filepath .Join (path , constants .AppCfgFileName )
4647 data , err := os .ReadFile (appCfgPath )
4748 if err != nil {
@@ -57,7 +58,7 @@ func (h *handlers) getAppConfig(ctx *fiber.Ctx) error {
5758 //var appcfg application.AppConfiguration
5859 //err = yaml.Unmarshal(data, &appcfg)
5960
60- appcfg , err := utils .GetAppConfig (data )
61+ appcfg , err := utils .GetAppConfig (username , data )
6162 if err != nil {
6263 klog .Error ("parse app cfg error, " , err )
6364 klog .Error (string (data ))
@@ -74,15 +75,17 @@ func (h *handlers) getAppConfig(ctx *fiber.Ctx) error {
7475}
7576
7677func (h * handlers ) updateAppConfig (ctx * fiber.Ctx ) error {
78+
7779 app := ctx .Query ("app" )
7880 if app == "" {
7981 return ctx .JSON (fiber.Map {
8082 "code" : http .StatusNotFound ,
8183 "message" : fmt .Sprintf ("Application not found" ),
8284 })
8385 }
86+ username := ctx .Locals ("username" ).(string )
8487
85- path := getAppPath (app )
88+ path := getAppPath (username , app )
8689 appCfgPath := filepath .Join (path , constants .AppCfgFileName )
8790
8891 var appcfg oachecker.AppConfiguration
@@ -122,7 +125,7 @@ func (h *handlers) updateAppConfig(ctx *fiber.Ctx) error {
122125 "message" : fmt .Sprintf ("Save OlaresManifest.yaml error: %v" , err ),
123126 })
124127 }
125- err = command .CheckCfg ().WithDir (BaseDir ).Run (ctx .Context (), app )
128+ err = command .CheckCfg ().WithDir (BaseDir ).Run (ctx .Context (), username , app )
126129 if err != nil {
127130 klog .Error ("check app cfg error, " , err )
128131 return ctx .JSON (fiber.Map {
@@ -138,58 +141,58 @@ func (h *handlers) updateAppConfig(ctx *fiber.Ctx) error {
138141
139142}
140143
141- func (h * handlers ) listMyContainers (ctx * fiber.Ctx ) error {
142- sql := `select a.*, b.pod_selector, b.app_id, b.container_name, c.app_name
143- from dev_containers a
144- left join dev_app_containers b on a.id = b.container_id
145- left join dev_apps c on b.app_id = c.id
146- order by a.create_time desc`
147- list := make ([]* model.DevContainerInfo , 0 )
148-
149- err := h .db .DB .Raw (sql ).Scan (& list ).Error
150- if err != nil {
151- klog .Error ("exec sql error, " , err , ", " , sql )
152- return ctx .JSON (fiber.Map {
153- "code" : http .StatusBadRequest ,
154- "message" : fmt .Sprintf ("Exec sql failed: %v" , err ),
155- })
156- }
157-
158- unbind := ctx .Query ("unbind" ) == "true"
159- ret := make ([]* model.DevContainerInfo , 0 , len (list ))
160-
161- for i , c := range list {
162- ret = append (ret , list [i ])
163- if c .AppID != nil {
164-
165- // filter binding dev container
166- if unbind {
167- ret = append (ret [:i ], ret [i + 1 :]... )
168- continue
169- }
170- // container is bind into an app, check the container running status
171- // ignore error, cause state is not a critical message
172- state , devPort , _ := container .GetContainerStatus (ctx .Context (), h .kubeConfig , c )
173- c .State = & state
174-
175- port := "/proxy/" + devPort + "/"
176- c .DevPath = & port
177- appcfg , err := readAppInfo (filepath .Join (BaseDir , * c .AppName , constants .AppCfgFileName ))
178- if err != nil {
179- klog .Error ("readCfgFromFile error, " , err )
180- continue
181- }
182-
183- list [i ].Icon = & appcfg .Metadata .Icon
184- }
185- }
186-
187- return ctx .JSON (fiber.Map {
188- "code" : http .StatusOK ,
189- "data" : ret ,
190- })
191-
192- }
144+ // func (h *handlers) listMyContainers(ctx *fiber.Ctx) error {
145+ // sql := `select a.*, b.pod_selector, b.app_id, b.container_name, c.app_name
146+ // from dev_containers a
147+ // left join dev_app_containers b on a.id = b.container_id
148+ // left join dev_apps c on b.app_id = c.id
149+ // order by a.create_time desc`
150+ // list := make([]*model.DevContainerInfo, 0)
151+ //
152+ // err := h.db.DB.Raw(sql).Scan(&list).Error
153+ // if err != nil {
154+ // klog.Error("exec sql error, ", err, ", ", sql)
155+ // return ctx.JSON(fiber.Map{
156+ // "code": http.StatusBadRequest,
157+ // "message": fmt.Sprintf("Exec sql failed: %v", err),
158+ // })
159+ // }
160+ //
161+ // unbind := ctx.Query("unbind") == "true"
162+ // ret := make([]*model.DevContainerInfo, 0, len(list))
163+ //
164+ // for i, c := range list {
165+ // ret = append(ret, list[i])
166+ // if c.AppID != nil {
167+ //
168+ // // filter binding dev container
169+ // if unbind {
170+ // ret = append(ret[:i], ret[i+1:]...)
171+ // continue
172+ // }
173+ // // container is bind into an app, check the container running status
174+ // // ignore error, cause state is not a critical message
175+ // state, devPort, _ := container.GetContainerStatus(ctx.Context(), h.kubeConfig, c)
176+ // c.State = &state
177+ //
178+ // port := "/proxy/" + devPort + "/"
179+ // c.DevPath = &port
180+ // appcfg, err := readAppInfo(filepath.Join(BaseDir, *c.AppName, constants.AppCfgFileName))
181+ // if err != nil {
182+ // klog.Error("readCfgFromFile error, ", err)
183+ // continue
184+ // }
185+ //
186+ // list[i].Icon = &appcfg.Metadata.Icon
187+ // }
188+ // }
189+ //
190+ // return ctx.JSON(fiber.Map{
191+ // "code": http.StatusOK,
192+ // "data": ret,
193+ // })
194+ //
195+ // }
193196
194197func (h * handlers ) bindContainer (ctx * fiber.Ctx ) error {
195198 var postData struct {
@@ -354,9 +357,10 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
354357 "message" : fmt .Sprintf ("Application Not Found" ),
355358 })
356359 }
360+ username := ctx .Locals ("username" ).(string )
357361
358362 appName := fmt .Sprintf ("%s-dev" , app )
359- testNamespace := fmt .Sprintf ("%s-%s" , appName , constants . Owner )
363+ testNamespace := fmt .Sprintf ("%s-%s" , appName , username )
360364
361365 // mock vals
362366 values := make (map [string ]interface {})
@@ -408,7 +412,7 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
408412
409413 values ["gpu" ] = "nvidia"
410414
411- path := getAppPath (app )
415+ path := getAppPath (username , app )
412416 appCfgPath := filepath .Join (path , constants .AppCfgFileName )
413417 data , err := os .ReadFile (appCfgPath )
414418 if err != nil {
@@ -419,7 +423,7 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
419423 })
420424 }
421425
422- appcfg , err := utils .GetAppConfig (data )
426+ appcfg , err := utils .GetAppConfig (username , data )
423427
424428 if err != nil {
425429 klog .Error ("parse app cfg error, " , err )
@@ -436,7 +440,7 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
436440 }
437441 values ["domain" ] = entries
438442
439- manifest , err := helm .DryRun (ctx .Context (), h .kubeConfig , testNamespace , appName , getAppPath (app ), values )
443+ manifest , err := helm .DryRun (ctx .Context (), h .kubeConfig , testNamespace , appName , getAppPath (username , app ), values )
440444 if err != nil {
441445 return ctx .JSON (fiber.Map {
442446 "code" : http .StatusBadRequest ,
@@ -475,7 +479,7 @@ func (h *handlers) listAppContainersInChart(ctx *fiber.Ctx) error {
475479 containers [i ].AppID = pointer .Int (int (da .ID ))
476480 if container .IsSysAppDevImage (containers [i ].Image ) {
477481 containers [i ].DevPath = pointer .String ("/proxy/3000/" )
478- userspace := "user-space-" + constants . Owner
482+ userspace := "os-framework"
479483 pods , err := client .CoreV1 ().Pods (userspace ).List (ctx .Context (), metav1.ListOptions {
480484 LabelSelector : containers [i ].PodSelector ,
481485 })
@@ -791,10 +795,10 @@ func (h *handlers) updateDevContainer(ctx *fiber.Ctx) error {
791795 })
792796}
793797
794- func GetAppContainersInChart (app string ) ([]* helm.ContainerInfo , error ) {
798+ func GetAppContainersInChart (owner , app string ) ([]* helm.ContainerInfo , error ) {
795799
796800 appName := fmt .Sprintf ("%s-dev" , app )
797- testNamespace := fmt .Sprintf ("%s-%s" , appName , constants . Owner )
801+ testNamespace := fmt .Sprintf ("%s-%s" , appName , owner )
798802
799803 // mock vals
800804 values := make (map [string ]interface {})
@@ -846,15 +850,15 @@ func GetAppContainersInChart(app string) ([]*helm.ContainerInfo, error) {
846850
847851 values ["gpu" ] = "nvidia"
848852
849- path := getAppPath (app )
853+ path := getAppPath (owner , app )
850854 appCfgPath := filepath .Join (path , constants .AppCfgFileName )
851855 data , err := os .ReadFile (appCfgPath )
852856 if err != nil {
853857 klog .Error ("read app cfg error, " , err , ", " , app , ", " , appCfgPath )
854858 return nil , err
855859 }
856860
857- appcfg , err := utils .GetAppConfig (data )
861+ appcfg , err := utils .GetAppConfig (owner , data )
858862
859863 if err != nil {
860864 klog .Error ("parse app cfg error, " , err )
@@ -872,7 +876,7 @@ func GetAppContainersInChart(app string) ([]*helm.ContainerInfo, error) {
872876 return nil , err
873877 }
874878
875- manifest , err := helm .DryRun (context .TODO (), kubeConfig , testNamespace , appName , getAppPath (app ), values )
879+ manifest , err := helm .DryRun (context .TODO (), kubeConfig , testNamespace , appName , getAppPath (owner , app ), values )
876880 if err != nil {
877881 return nil , err
878882 }
@@ -901,7 +905,7 @@ func GetAppContainersInChart(app string) ([]*helm.ContainerInfo, error) {
901905 containers [i ].AppID = pointer .Int (int (da .ID ))
902906 if container .IsSysAppDevImage (containers [i ].Image ) {
903907 containers [i ].DevPath = pointer .String ("/proxy/3000/" )
904- userspace := "user-space-" + constants . Owner
908+ userspace := "os-framework"
905909 pods , err := client .CoreV1 ().Pods (userspace ).List (context .TODO (), metav1.ListOptions {
906910 LabelSelector : containers [i ].PodSelector ,
907911 })
0 commit comments