github

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package github contains logic relating to the management of github repos

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPrivateRepoForbidden is returned when creation fails due to an
	// attempt to register a private repo in a project which does not allow
	// private repos
	ErrPrivateRepoForbidden = errors.New("private repos cannot be registered in this project")
	// ErrArchivedRepoForbidden is returned when creation fails due to an
	// attempt to register an archived repo
	ErrArchivedRepoForbidden = errors.New("archived repos cannot be registered in this project")
)

Functions

This section is empty.

Types

type RepositoryService

type RepositoryService interface {
	// CreateRepository registers a GitHub repository, including creating
	// a webhook in the repo in GitHub.
	CreateRepository(
		ctx context.Context,

		provider *db.Provider,
		projectID uuid.UUID,
		repoName string,
		repoOwner string,
	) (*pb.Repository, error)
	// DeleteByID removes the webhook and deletes the repo from the database.
	DeleteByID(
		ctx context.Context,
		repoID uuid.UUID,
		projectID uuid.UUID,
	) error
	// DeleteByName removes the webhook and deletes the repo from the database.
	// Ideally, we would take provider ID instead of name. Name is used for
	// backwards compatibility with the API endpoint which calls it.
	DeleteByName(
		ctx context.Context,
		repoOwner string,
		repoName string,
		projectID uuid.UUID,
		providerName string,
	) error

	// ListRepositories retrieves all repositories for the
	// specific provider and project. Ideally, we would take
	// provider ID instead of name. Name is used for backwards
	// compatibility with the API endpoint which calls it.
	ListRepositories(
		ctx context.Context,
		projectID uuid.UUID,
		providerName string,
	) ([]db.Repository, error)

	// GetRepositoryById retrieves a repository by its ID and project.
	GetRepositoryById(ctx context.Context, repositoryID uuid.UUID, projectID uuid.UUID) (db.Repository, error)
	// GetRepositoryByName retrieves a repository by its name, owner, project and provider (if specified).
	GetRepositoryByName(
		ctx context.Context,
		repoOwner string,
		repoName string,
		projectID uuid.UUID,
		providerName string,
	) (db.Repository, error)
}

RepositoryService encapsulates logic related to registering and deleting repos TODO: get rid of the github client from this interface

func NewRepositoryService

func NewRepositoryService(
	webhookManager webhooks.WebhookManager,
	store db.Store,
	eventProducer events.Publisher,
	providerManager manager.ProviderManager,
) RepositoryService

NewRepositoryService creates an instance of the RepositoryService interface

Directories

Path Synopsis
Package clients defines the shared client interface used by github repo management code
Package clients defines the shared client interface used by github repo management code
mock
Package mock_clients is a generated GoMock package.
Package mock_clients is a generated GoMock package.
mock/fixtures
Package fixtures contains fixtures used within the github repositories package.
Package fixtures contains fixtures used within the github repositories package.
Package mock_github is a generated GoMock package.
Package mock_github is a generated GoMock package.
fixtures
Package fixtures contains code for creating RepositoryService fixtures and is used in various parts of the code.
Package fixtures contains code for creating RepositoryService fixtures and is used in various parts of the code.
Package webhooks contains logic relating to manipulating GitHub webhooks
Package webhooks contains logic relating to manipulating GitHub webhooks
mock
Package mock_webhooks is a generated GoMock package.
Package mock_webhooks is a generated GoMock package.

Jump to

Keyboard shortcuts

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