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

Method CheckExist

agent/app/service/app_install.go:133–175  ·  view source on GitHub ↗
(req request.AppInstalledInfo)

Source from the content-addressed store, hash-verified

131}
132
133func (a *AppInstallService) CheckExist(req request.AppInstalledInfo) (*response.AppInstalledCheck, error) {
134 res := &response.AppInstalledCheck{
135 IsExist: false,
136 }
137
138 app, err := appRepo.GetFirst(appRepo.WithKey(req.Key))
139 if err != nil {
140 return res, nil
141 }
142 res.App = app.Name
143
144 var appInstall model.AppInstall
145 if len(req.Name) == 0 {
146 appInstall, _ = appInstallRepo.GetFirst(appInstallRepo.WithAppId(app.ID))
147 } else {
148 appInstall, _ = appInstallRepo.GetFirst(appInstallRepo.WithAppId(app.ID), repo.WithByName(req.Name))
149 }
150
151 if reflect.DeepEqual(appInstall, model.AppInstall{}) {
152 return res, nil
153 }
154 if err = syncAppInstallStatus(&appInstall, false); err != nil {
155 return nil, err
156 }
157
158 res.ContainerName = appInstall.ContainerName
159 res.Name = appInstall.Name
160 res.Version = appInstall.Version
161 res.CreatedAt = appInstall.CreatedAt
162 res.Status = appInstall.Status
163 res.AppInstallID = appInstall.ID
164 res.IsExist = true
165 res.InstallPath = path.Join(global.Dir.AppInstallDir, appInstall.App.Key, appInstall.Name)
166 res.HttpPort = appInstall.HttpPort
167 res.HttpsPort = appInstall.HttpsPort
168
169 if appInstall.App.Key == "openresty" {
170 websiteDir, _ := settingRepo.GetValueByKey("WEBSITE_DIR")
171 res.WebsiteDir = websiteDir
172 }
173
174 return res, nil
175}
176
177func (a *AppInstallService) LoadPort(req dto.OperationWithNameAndType) (int64, error) {
178 app, err := appInstallRepo.LoadBaseInfo(req.Type, req.Name)

Callers

nothing calls this directly

Calls 5

syncAppInstallStatusFunction · 0.85
GetFirstMethod · 0.65
WithKeyMethod · 0.65
WithAppIdMethod · 0.65
GetValueByKeyMethod · 0.65

Tested by

no test coverage detected