(ctx context.Context, s *database.Space)
| 644 | } |
| 645 | |
| 646 | func (c *SpaceComponent) status(ctx context.Context, s *database.Space) (string, string, error) { |
| 647 | if !s.HasAppFile { |
| 648 | if s.Sdk == scheduler.NGINX.Name { |
| 649 | return "", SpaceStatusNoNGINXConf, nil |
| 650 | } |
| 651 | return "", SpaceStatusNoAppFile, nil |
| 652 | } |
| 653 | // get latest Deploy for space by space id |
| 654 | deploy, err := c.deploy.GetLatestDeployBySpaceID(ctx, s.ID) |
| 655 | if err != nil || deploy == nil { |
| 656 | slog.Error("fail to get latest space deploy by space id", slog.Any("SpaceID", s.ID)) |
| 657 | return "", SpaceStatusStopped, fmt.Errorf("can't get space deployment,%w", err) |
| 658 | } |
| 659 | |
| 660 | namespace, name := s.Repository.NamespaceAndName() |
| 661 | // request space deploy status by deploy id |
| 662 | srvName, code, _, err := c.deployer.Status(ctx, types.DeployRepo{ |
| 663 | DeployID: deploy.ID, |
| 664 | SpaceID: deploy.SpaceID, |
| 665 | ModelID: deploy.ModelID, |
| 666 | Namespace: namespace, |
| 667 | Name: name, |
| 668 | SvcName: deploy.SvcName, |
| 669 | }, true) |
| 670 | if err != nil { |
| 671 | slog.Error("error happen when get space status", slog.Any("error", err), slog.String("path", s.Repository.Path)) |
| 672 | return "", SpaceStatusStopped, err |
| 673 | } |
| 674 | return srvName, deployStatusCodeToString(code), nil |
| 675 | } |
| 676 | |
| 677 | func (c *SpaceComponent) Status(ctx context.Context, namespace, name string) (string, string, error) { |
| 678 | s, err := c.ss.FindByPath(ctx, namespace, name) |
no test coverage detected