(ctx context.Context, req *adminv1.SudoUpdateOrganizationCustomDomainRequest)
| 988 | } |
| 989 | |
| 990 | func (s *Server) SudoUpdateOrganizationCustomDomain(ctx context.Context, req *adminv1.SudoUpdateOrganizationCustomDomainRequest) (*adminv1.SudoUpdateOrganizationCustomDomainResponse, error) { |
| 991 | observability.AddRequestAttributes(ctx, |
| 992 | attribute.String("args.org", req.Name), |
| 993 | attribute.String("args.custom_domain", req.CustomDomain), |
| 994 | ) |
| 995 | |
| 996 | claims := auth.GetClaims(ctx) |
| 997 | if !claims.Superuser(ctx) { |
| 998 | return nil, status.Error(codes.PermissionDenied, "only superusers can manage custom domains") |
| 999 | } |
| 1000 | |
| 1001 | org, err := s.admin.DB.FindOrganizationByName(ctx, req.Name) |
| 1002 | if err != nil { |
| 1003 | return nil, err |
| 1004 | } |
| 1005 | |
| 1006 | org, err = s.admin.DB.UpdateOrganization(ctx, org.ID, &database.UpdateOrganizationOptions{ |
| 1007 | Name: org.Name, |
| 1008 | DisplayName: org.DisplayName, |
| 1009 | Description: org.Description, |
| 1010 | LogoAssetID: org.LogoAssetID, |
| 1011 | LogoDarkAssetID: org.LogoDarkAssetID, |
| 1012 | FaviconAssetID: org.FaviconAssetID, |
| 1013 | CustomDomain: req.CustomDomain, |
| 1014 | ThumbnailAssetID: org.ThumbnailAssetID, |
| 1015 | DefaultProjectRoleID: org.DefaultProjectRoleID, |
| 1016 | QuotaProjects: org.QuotaProjects, |
| 1017 | QuotaDeployments: org.QuotaDeployments, |
| 1018 | QuotaSlotsTotal: org.QuotaSlotsTotal, |
| 1019 | QuotaSlotsPerDeployment: org.QuotaSlotsPerDeployment, |
| 1020 | QuotaOutstandingInvites: org.QuotaOutstandingInvites, |
| 1021 | QuotaStorageLimitBytesPerDeployment: org.QuotaStorageLimitBytesPerDeployment, |
| 1022 | BillingCustomerID: org.BillingCustomerID, |
| 1023 | PaymentCustomerID: org.PaymentCustomerID, |
| 1024 | BillingEmail: org.BillingEmail, |
| 1025 | BillingPlanName: org.BillingPlanName, |
| 1026 | BillingPlanDisplayName: org.BillingPlanDisplayName, |
| 1027 | CreatedByUserID: org.CreatedByUserID, |
| 1028 | }) |
| 1029 | if err != nil { |
| 1030 | return nil, err |
| 1031 | } |
| 1032 | |
| 1033 | // If the custom domain changed, we need to update the deployment annotations for this org so that the new custom domain is picked up. |
| 1034 | if req.CustomDomain != org.CustomDomain { |
| 1035 | if err := s.admin.UpdateOrgDeploymentAnnotations(ctx, org); err != nil { |
| 1036 | return nil, err |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | return &adminv1.SudoUpdateOrganizationCustomDomainResponse{ |
| 1041 | Organization: s.organizationToDTO(org, true), |
| 1042 | }, nil |
| 1043 | } |
| 1044 | |
| 1045 | func (s *Server) organizationToDTO(o *database.Organization, privileged bool) *adminv1.Organization { |
| 1046 | var logoURL string |
nothing calls this directly
no test coverage detected