(ctx context.Context, serviceId string, releaseId string)
| 412 | } |
| 413 | |
| 414 | func (i *imlPublishModule) CheckPublish(ctx context.Context, serviceId string, releaseId string) (*dto.DiffOut, error) { |
| 415 | _, err := i.serviceService.Check(ctx, serviceId, asServer) |
| 416 | if err != nil { |
| 417 | return nil, err |
| 418 | } |
| 419 | err = i.checkPublish(ctx, serviceId, releaseId) |
| 420 | if err != nil { |
| 421 | return nil, err |
| 422 | } |
| 423 | |
| 424 | running, err := i.releaseService.GetRunning(ctx, serviceId) |
| 425 | if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { |
| 426 | return nil, err |
| 427 | } |
| 428 | runningReleaseId := "" |
| 429 | if running != nil { |
| 430 | runningReleaseId = running.UUID |
| 431 | } |
| 432 | if releaseId == "" { |
| 433 | // 发布latest 版本 |
| 434 | diff, _, err := i.projectDiffModule.DiffForLatest(ctx, serviceId, runningReleaseId) |
| 435 | if err != nil { |
| 436 | return nil, err |
| 437 | } |
| 438 | return i.projectDiffModule.Out(ctx, diff) |
| 439 | } else { |
| 440 | // 发布 releaseId 版本, 返回 与当前版本的差异 |
| 441 | diff, err := i.projectDiffModule.Diff(ctx, serviceId, runningReleaseId, releaseId) |
| 442 | if err != nil { |
| 443 | return nil, err |
| 444 | } |
| 445 | return i.projectDiffModule.Out(ctx, diff) |
| 446 | } |
| 447 | |
| 448 | } |
| 449 | func (i *imlPublishModule) checkPublish(ctx context.Context, serviceId string, releaseId string) error { |
| 450 | flows, err := i.publishService.ListForStatus(ctx, serviceId, publish.StatusApply, publish.StatusAccept) |
| 451 | if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { |
nothing calls this directly
no test coverage detected