MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / GetAppDetail

Method GetAppDetail

agent/app/service/app.go:234–330  ·  view source on GitHub ↗
(appID uint, version, appType string)

Source from the content-addressed store, hash-verified

232}
233
234func (a AppService) GetAppDetail(appID uint, version, appType string) (response.AppDetailDTO, error) {
235 var (
236 appDetailDTO response.AppDetailDTO
237 opts []repo.DBOption
238 )
239 opts = append(opts, appDetailRepo.WithAppId(appID), appDetailRepo.WithVersion(version))
240 detail, err := appDetailRepo.GetFirst(opts...)
241 if err != nil {
242 return appDetailDTO, err
243 }
244 appDetailDTO.AppDetail = detail
245 appDetailDTO.Enable = true
246
247 if appType == "runtime" {
248 app, err := appRepo.GetFirst(repo.WithByID(appID))
249 if err != nil {
250 return appDetailDTO, err
251 }
252 fileOp := files.NewFileOp()
253
254 versionPath := filepath.Join(app.GetAppResourcePath(), detail.Version)
255 if !fileOp.Stat(versionPath) || detail.Update {
256 if err = downloadApp(app, detail, nil, nil); err != nil && !fileOp.Stat(versionPath) {
257 return appDetailDTO, err
258 }
259 }
260 switch app.Type {
261 case constant.RuntimePHP:
262 paramsPath := filepath.Join(versionPath, "data.yml")
263 if !fileOp.Stat(paramsPath) {
264 return appDetailDTO, buserr.WithDetail("ErrFileNotExist", paramsPath, nil)
265 }
266 param, err := fileOp.GetContent(paramsPath)
267 if err != nil {
268 return appDetailDTO, err
269 }
270 paramMap := make(map[string]interface{})
271 if err = yaml.Unmarshal(param, &paramMap); err != nil {
272 return appDetailDTO, err
273 }
274 appDetailDTO.Params = paramMap["additionalProperties"]
275 composePath := filepath.Join(versionPath, "docker-compose.yml")
276 if !fileOp.Stat(composePath) {
277 return appDetailDTO, buserr.WithDetail("ErrFileNotExist", composePath, nil)
278 }
279 compose, err := fileOp.GetContent(composePath)
280 if err != nil {
281 return appDetailDTO, err
282 }
283 composeMap := make(map[string]interface{})
284 if err := yaml.Unmarshal(compose, &composeMap); err != nil {
285 return appDetailDTO, err
286 }
287 if service, ok := composeMap["services"]; ok {
288 servicesMap := service.(map[string]interface{})
289 for k := range servicesMap {
290 appDetailDTO.Image = k
291 }

Callers

nothing calls this directly

Calls 12

StatMethod · 0.95
GetContentMethod · 0.95
downloadAppFunction · 0.85
isHostModelFunction · 0.85
checkLimitFunction · 0.85
GetAppResourcePathMethod · 0.80
WithAppIdMethod · 0.65
WithVersionMethod · 0.65
GetFirstMethod · 0.65
WithByIDMethod · 0.65
UpdateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected