(ctx context.Context, req *adminv1.RedeployProjectRequest)
| 2022 | } |
| 2023 | |
| 2024 | func (s *Server) RedeployProject(ctx context.Context, req *adminv1.RedeployProjectRequest) (*adminv1.RedeployProjectResponse, error) { |
| 2025 | observability.AddRequestAttributes(ctx, |
| 2026 | attribute.String("args.organization", req.Org), |
| 2027 | attribute.String("args.project", req.Project), |
| 2028 | ) |
| 2029 | |
| 2030 | proj, err := s.admin.DB.FindProjectByName(ctx, req.Org, req.Project) |
| 2031 | if err != nil { |
| 2032 | return nil, err |
| 2033 | } |
| 2034 | |
| 2035 | claims := auth.GetClaims(ctx) |
| 2036 | forceAccess := claims.Superuser(ctx) && req.SuperuserForceAccess |
| 2037 | if !claims.ProjectPermissions(ctx, proj.OrganizationID, proj.ID).ManageProd && !forceAccess { |
| 2038 | return nil, status.Error(codes.PermissionDenied, "does not have permission to manage deployment") |
| 2039 | } |
| 2040 | |
| 2041 | org, err := s.admin.DB.FindOrganizationByName(ctx, req.Org) |
| 2042 | if err != nil { |
| 2043 | return nil, err |
| 2044 | } |
| 2045 | |
| 2046 | // check if org has blocking billing errors |
| 2047 | err = s.admin.CheckBlockingBillingErrors(ctx, org.ID) |
| 2048 | if err != nil { |
| 2049 | if errors.Is(err, admin.ErrBlockingBillingIssue) { |
| 2050 | return nil, status.Error(codes.FailedPrecondition, err.Error()) |
| 2051 | } |
| 2052 | return nil, err |
| 2053 | } |
| 2054 | |
| 2055 | var depl *database.Deployment |
| 2056 | if proj.PrimaryDeploymentID != nil { |
| 2057 | depl, err = s.admin.DB.FindDeployment(ctx, *proj.PrimaryDeploymentID) |
| 2058 | if err != nil { |
| 2059 | return nil, err |
| 2060 | } |
| 2061 | } |
| 2062 | |
| 2063 | _, err = s.admin.RedeployProject(ctx, proj, depl) |
| 2064 | if err != nil { |
| 2065 | return nil, err |
| 2066 | } |
| 2067 | |
| 2068 | return &adminv1.RedeployProjectResponse{}, nil |
| 2069 | } |
| 2070 | |
| 2071 | func (s *Server) HibernateProject(ctx context.Context, req *adminv1.HibernateProjectRequest) (*adminv1.HibernateProjectResponse, error) { |
| 2072 | observability.AddRequestAttributes(ctx, |
nothing calls this directly
no test coverage detected