MCPcopy Index your code
hub / github.com/rilldata/rill / GetRepoMeta

Method GetRepoMeta

admin/server/repos.go:19–95  ·  view source on GitHub ↗
(ctx context.Context, req *adminv1.GetRepoMetaRequest)

Source from the content-addressed store, hash-verified

17)
18
19func (s *Server) GetRepoMeta(ctx context.Context, req *adminv1.GetRepoMetaRequest) (*adminv1.GetRepoMetaResponse, error) {
20 observability.AddRequestAttributes(ctx,
21 attribute.String("args.project_id", req.ProjectId),
22 )
23
24 proj, err := s.admin.DB.FindProject(ctx, req.ProjectId)
25 if err != nil {
26 return nil, err
27 }
28
29 claims := auth.GetClaims(ctx)
30 perms := claims.ProjectPermissions(ctx, proj.OrganizationID, proj.ID)
31 if !perms.ReadProdStatus && !perms.ReadDevStatus {
32 return nil, status.Error(codes.PermissionDenied, "does not have permission to read project repo")
33 }
34
35 if proj.ArchiveAssetID != nil {
36 asset, err := s.admin.DB.FindAsset(ctx, *proj.ArchiveAssetID)
37 if err != nil {
38 return nil, err
39 }
40
41 downloadURL, err := s.generateSignedDownloadURL(asset)
42 if err != nil {
43 return nil, status.Error(codes.Internal, err.Error())
44 }
45 return &adminv1.GetRepoMetaResponse{
46 ExpiresOn: timestamppb.New(time.Now().Add(time.Hour * 24 * 365)), // Setting to a year because it doesn't need to be refreshed
47 LastUpdatedOn: timestamppb.New(proj.UpdatedOn),
48 ArchiveId: asset.ID,
49 ArchiveDownloadUrl: downloadURL,
50 ArchiveCreatedOn: timestamppb.New(asset.CreatedOn),
51 }, nil
52 }
53
54 if proj.GitRemote == nil || proj.GithubInstallationID == nil {
55 return nil, status.Error(codes.FailedPrecondition, "project does not have a github integration")
56 }
57
58 var depl *database.Deployment
59 if claims.OwnerType() == auth.OwnerTypeDeployment {
60 var err error
61 depl, err = s.admin.DB.FindDeployment(ctx, claims.OwnerID())
62 if err != nil {
63 return nil, err
64 }
65 }
66
67 repoID, err := s.githubRepoIDForProject(ctx, proj)
68 if err != nil {
69 return nil, err
70 }
71
72 token, expiresAt, err := s.admin.Github.InstallationToken(ctx, *proj.GithubInstallationID, repoID)
73 if err != nil {
74 return nil, err
75 }
76

Callers

nothing calls this directly

Calls 15

AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
StringMethod · 0.65
FindProjectMethod · 0.65
ProjectPermissionsMethod · 0.65
FindAssetMethod · 0.65
AddMethod · 0.65
OwnerTypeMethod · 0.65
FindDeploymentMethod · 0.65
OwnerIDMethod · 0.65

Tested by

no test coverage detected