(websiteID uint)
| 2214 | } |
| 2215 | |
| 2216 | func (w WebsiteService) GetWebsiteResource(websiteID uint) ([]response.Resource, error) { |
| 2217 | website, err := websiteRepo.GetFirst(repo.WithByID(websiteID)) |
| 2218 | if err != nil { |
| 2219 | return nil, err |
| 2220 | } |
| 2221 | var ( |
| 2222 | res []response.Resource |
| 2223 | databaseID uint |
| 2224 | databaseType string |
| 2225 | ) |
| 2226 | if website.Type == constant.Runtime { |
| 2227 | runtime, err := runtimeRepo.GetFirst(context.Background(), repo.WithByID(website.RuntimeID)) |
| 2228 | if err != nil { |
| 2229 | return nil, err |
| 2230 | } |
| 2231 | res = append(res, response.Resource{ |
| 2232 | Name: runtime.Name, |
| 2233 | Type: "runtime", |
| 2234 | ResourceID: runtime.ID, |
| 2235 | Detail: runtime, |
| 2236 | }) |
| 2237 | } |
| 2238 | if website.Type == constant.Deployment { |
| 2239 | install, err := appInstallRepo.GetFirst(repo.WithByID(website.AppInstallID)) |
| 2240 | if err != nil { |
| 2241 | return nil, err |
| 2242 | } |
| 2243 | res = append(res, response.Resource{ |
| 2244 | Name: install.Name, |
| 2245 | Type: "app", |
| 2246 | ResourceID: install.ID, |
| 2247 | Detail: install, |
| 2248 | }) |
| 2249 | installResources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID)) |
| 2250 | for _, resource := range installResources { |
| 2251 | if resource.Key == constant.AppMysql || resource.Key == constant.AppMariaDB || resource.Key == constant.AppPostgres || resource.Key == constant.AppPostgresql { |
| 2252 | databaseType = resource.Key |
| 2253 | databaseID = resource.ResourceId |
| 2254 | } |
| 2255 | } |
| 2256 | } |
| 2257 | if website.DbID > 0 { |
| 2258 | databaseType = website.DbType |
| 2259 | databaseID = website.DbID |
| 2260 | } |
| 2261 | if databaseID > 0 { |
| 2262 | switch databaseType { |
| 2263 | case constant.AppMysql, constant.AppMariaDB: |
| 2264 | db, _ := mysqlRepo.Get(repo.WithByID(databaseID)) |
| 2265 | if db.ID > 0 { |
| 2266 | res = append(res, response.Resource{ |
| 2267 | Name: db.Name, |
| 2268 | Type: "database", |
| 2269 | ResourceID: db.ID, |
| 2270 | Detail: db, |
| 2271 | }) |
| 2272 | } |
| 2273 | case constant.AppPostgresql, constant.AppPostgres: |
nothing calls this directly
no test coverage detected