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

Method CreateManagedGitRepo

admin/server/github.go:464–503  ·  view source on GitHub ↗
(ctx context.Context, req *adminv1.CreateManagedGitRepoRequest)

Source from the content-addressed store, hash-verified

462}
463
464func (s *Server) CreateManagedGitRepo(ctx context.Context, req *adminv1.CreateManagedGitRepoRequest) (*adminv1.CreateManagedGitRepoResponse, error) {
465 observability.AddRequestAttributes(ctx,
466 attribute.String("args.organization", req.Org),
467 attribute.String("args.name", req.Name),
468 attribute.Bool("args.auto_init", req.AutoInit),
469 )
470
471 // Find org
472 org, err := s.admin.DB.FindOrganizationByName(ctx, req.Org)
473 if err != nil {
474 return nil, err
475 }
476
477 claims := auth.GetClaims(ctx)
478 if !claims.OrganizationPermissions(ctx, org.ID).CreateProjects {
479 return nil, status.Error(codes.PermissionDenied, "does not have permission to create projects")
480 }
481
482 repo, err := s.admin.CreateManagedGitRepo(ctx, org, req.Name, claims.OwnerID(), req.AutoInit)
483 if err != nil {
484 return nil, err
485 }
486
487 id, err := s.admin.Github.ManagedOrgInstallationID()
488 if err != nil {
489 return nil, err
490 }
491 token, expiresAt, err := s.admin.Github.InstallationToken(ctx, id, *repo.ID)
492 if err != nil {
493 return nil, err
494 }
495
496 return &adminv1.CreateManagedGitRepoResponse{
497 Remote: *repo.CloneURL,
498 Username: "x-access-token",
499 Password: token,
500 DefaultBranch: valOrDefault(repo.DefaultBranch, "main"),
501 PasswordExpiresAt: timestamppb.New(expiresAt),
502 }, nil
503}
504
505// registerGithubEndpoints registers the non-gRPC endpoints for the Github integration.
506func (s *Server) registerGithubEndpoints(mux *http.ServeMux) {

Callers

nothing calls this directly

Calls 11

AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
valOrDefaultFunction · 0.70
StringMethod · 0.65
CreateManagedGitRepoMethod · 0.65
OwnerIDMethod · 0.65
InstallationTokenMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected