service

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIntegrationNotEnabled = errors.New("github integration is not enabled")
View Source
var ErrNotSetup = errors.New("not setup")

Functions

func Module

func Module(c *di.Container)

Types

type ClonerQueue

type ClonerQueue interface {
	Enqueue(context.Context, *github.CloneRepositoryEvent) error
}

type GitHubRepo

type GitHubRepo struct {
	InstallationID int64
	RepositoryID   int64

	Owner string
	Name  string
}

type GitHubUserError

type GitHubUserError struct {
	// contains filtered or unexported fields
}

func (GitHubUserError) Error

func (g GitHubUserError) Error() string

type ImporterQueue

type ImporterQueue interface {
	Enqueue(ctx context.Context, codebaseID string, userID string) error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(
	logger *zap.Logger,

	gitHubRepositoryRepo db_github.GitHubRepositoryRepo,
	gitHubInstallationRepo db_github.GitHubInstallationRepo,
	gitHubUserRepo db_github.GitHubUserRepo,
	gitHubPullRequestRepo db_github.GitHubPRRepo,
	gitHubAppConfig *config_github.GitHubAppConfig,
	gitHubInstallationClientProvider github_client.InstallationClientProvider,
	gitHubPersonalClientProvider github_client.PersonalClientProvider,
	gitHubAppClientProvider github_client.AppClientProvider,

	gitHubPullRequestImporterQueue *ImporterQueue,
	gitHubCloneQueue *ClonerQueue,

	workspaceWriter db_workspace.WorkspaceWriter,
	workspaceReader db_workspace.WorkspaceReader,
	codebaseUserRepo db_codebase.CodebaseUserRepository,
	codebaseRepo db_codebase.CodebaseRepository,

	executorProvider executor.Provider,
	snap snapshotter.Snapshotter,
	analyticsClient analytics.Client,
	notificationSender sender.NotificationSender,
	eventsSender events.EventSender,

	userService service_user.Service,
) *Service

func (*Service) AddUser

func (svc *Service) AddUser(codebaseID, userID string) error

func (*Service) AddUserToCodebases

func (svc *Service) AddUserToCodebases(ctx context.Context, userID string) error

AddUserToCodebases adds finds all GitHub installations and repositories that this user can see, and adds the user to all of those codebases.

func (*Service) Clone

func (svc *Service) Clone(
	codebaseID string,
	installationID int64,
	gitHubRepositoryID int64,
	senderUserID string,
) error

Clone processes events to initiate the initial cloning of a codebase

When a webhook event is received from GitHub that the app has been installed on a repository

  1. The webhook handler creates a Codebase{isReady: false}, a partial GitHubRepository, and potentially a CodebaseUser for the user that initiated the installation (if one can be identified)
  2. An event is sent to this queue
  3. This worker, clones the repository, populates the GitHubRepository, discovers all users that should have access, and last sets isReady to true.

func (*Service) CloneMissingRepositories

func (svc *Service) CloneMissingRepositories(ctx context.Context, userID string) error

func (*Service) CreateNonReadyCodebaseAndClone

func (svc *Service) CreateNonReadyCodebaseAndClone(ctx context.Context, ghRepo *gh.Repository, installationID int64, sender *gh.User, addUserID *string, organizationID *string) (*codebase.Codebase, error)

func (*Service) CreateNonReadyCodebaseAndCloneByIDs

func (svc *Service) CreateNonReadyCodebaseAndCloneByIDs(ctx context.Context, installationID, repositoryID int64, userID, organizationID string) (*codebase.Codebase, error)

func (*Service) CreateOrUpdatePullRequest

func (svc *Service) CreateOrUpdatePullRequest(ctx context.Context, ws *workspace.Workspace, patchIDs []string) (*github.GitHubPullRequest, error)

func (*Service) EnqueueGitHubPullRequestImport

func (svc *Service) EnqueueGitHubPullRequestImport(ctx context.Context, codebaseID, userID string) error

func (*Service) GetAppMetadata

func (svc *Service) GetAppMetadata() (*config.GitHubAppMetadata, error)

func (*Service) GetRepositoryByCodebaseID

func (s *Service) GetRepositoryByCodebaseID(_ context.Context, codebaseID string) (*github.GitHubRepository, error)

func (*Service) GetRepositoryByInstallationAndRepoID

func (s *Service) GetRepositoryByInstallationAndRepoID(_ context.Context, installationID, repositoryID int64) (*github.GitHubRepository, error)

func (*Service) GrantCollaboratorsAccess

func (svc *Service) GrantCollaboratorsAccess(ctx context.Context, codebaseID string, authAsUserID *string) error

func (*Service) ImportOpenPullRequestsByUser

func (svc *Service) ImportOpenPullRequestsByUser(ctx context.Context, codebaseID, userID string) error

func (*Service) ListAllAccessibleRepositoriesFromGitHub

func (svc *Service) ListAllAccessibleRepositoriesFromGitHub(ctx context.Context, userID string) ([]GitHubRepo, error)

func (*Service) MergePullRequest

func (svc *Service) MergePullRequest(ctx context.Context, workspaceID string) error

func (*Service) Push

func (s *Service) Push(ctx context.Context, gitHubRepository *github.GitHubRepository, change *change.Change) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL