(ctx context.Context, req types.DeployReq)
| 598 | } |
| 599 | |
| 600 | func (c *UserComponent) ListServerless(ctx context.Context, req types.DeployReq) ([]types.DeployRepo, int, error) { |
| 601 | user, err := c.us.FindByUsername(ctx, req.CurrentUser) |
| 602 | if err != nil { |
| 603 | newError := fmt.Errorf("failed to check for the presence of the user:%s, error:%w", req.CurrentUser, err) |
| 604 | return nil, 0, newError |
| 605 | } |
| 606 | isAdmin := c.repoComponent.isAdminRole(user) |
| 607 | if !isAdmin { |
| 608 | return nil, 0, fmt.Errorf("user %s does not have admin privileges", req.CurrentUser) |
| 609 | } |
| 610 | deploys, total, err := c.deploy.ListServerless(ctx, req) |
| 611 | if err != nil { |
| 612 | newError := fmt.Errorf("failed to get user serverless for %s with error:%w", req.RepoType, err) |
| 613 | return nil, 0, newError |
| 614 | } |
| 615 | |
| 616 | var resDeploys []types.DeployRepo |
| 617 | for _, deploy := range deploys { |
| 618 | repoPath := strings.TrimPrefix(deploy.GitPath, string(req.RepoType)+"s_") |
| 619 | resDeploys = append(resDeploys, types.DeployRepo{ |
| 620 | DeployID: deploy.ID, |
| 621 | DeployName: deploy.DeployName, |
| 622 | Path: repoPath, |
| 623 | RepoID: deploy.RepoID, |
| 624 | SvcName: deploy.SvcName, |
| 625 | Status: deployStatusCodeToString(deploy.Status), |
| 626 | Hardware: deploy.Hardware, |
| 627 | Env: deploy.Env, |
| 628 | RuntimeFramework: deploy.RuntimeFramework, |
| 629 | ImageID: deploy.ImageID, |
| 630 | MinReplica: deploy.MinReplica, |
| 631 | MaxReplica: deploy.MaxReplica, |
| 632 | GitPath: deploy.GitPath, |
| 633 | GitBranch: deploy.GitBranch, |
| 634 | ClusterID: deploy.ClusterID, |
| 635 | SecureLevel: deploy.SecureLevel, |
| 636 | CreatedAt: deploy.CreatedAt, |
| 637 | UpdatedAt: deploy.UpdatedAt, |
| 638 | Type: deploy.Type, |
| 639 | SKU: deploy.SKU, |
| 640 | }) |
| 641 | } |
| 642 | return resDeploys, total, nil |
| 643 | } |
no test coverage detected