provider

package
v0.0.0-...-081ecb4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized    = errors.New("no VCS provider authorization")
	ErrRepoWasArchived = errors.New("repo was archived so is read-only")
	ErrNoFreeOrgSeats  = errors.New("no free seats in GitHub organization") // TODO: remove github
	ErrNotFound        = errors.New("not found in VCS provider")
)

Functions

func IsPermanentError

func IsPermanentError(err error) bool

Types

type Branch

type Branch struct {
	CommitSHA string
}

type Commit

type Commit struct {
	SHA       string
	Author    *CommitAuthor
	Committer *CommitAuthor
}

type CommitAuthor

type CommitAuthor struct {
	Email string
}

type CommitStatus

type CommitStatus struct {
	Description string
	State       string
	Context     string
	TargetURL   string
}

type Hook

type Hook struct {
	ID int
	HookConfig
}

type HookConfig

type HookConfig struct {
	Name        string
	Events      []string
	URL         string
	ContentType string
}

type ListOrgsConfig

type ListOrgsConfig struct {
	// MembershipState Indicates the state of the memberships to return.
	// Can be either active or pending.
	// If not specified, the API returns both active and pending memberships.
	MembershipState string
	MaxPages        int
}

type ListReposConfig

type ListReposConfig struct {
	Visibility string // public|all
	Sort       string
	MaxPages   int
}

type OrgMembership

type OrgMembership struct {
	ID      int
	Name    string
	IsAdmin bool
}

type Provider

type Provider interface {
	Name() string

	LinkToPullRequest(repo *models.Repo, num int) string

	SetBaseURL(url string) error

	GetBranch(ctx context.Context, owner, repo, branch string) (*Branch, error)
	GetRepoByName(ctx context.Context, owner, repo string) (*Repo, error)
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

	GetOrgMembershipByName(ctx context.Context, org string) (*OrgMembership, error)

	ListRepoHooks(ctx context.Context, owner, repo string) ([]Hook, error)
	CreateRepoHook(ctx context.Context, owner, repo string, hook *HookConfig) (*Hook, error)
	DeleteRepoHook(ctx context.Context, owner, repo string, hookID int) error

	ListRepos(ctx context.Context, cfg *ListReposConfig) ([]Repo, error)
	ListOrgMemberships(ctx context.Context, cfg *ListOrgsConfig) ([]OrgMembership, error)

	ListPullRequestCommits(ctx context.Context, owner, repo string, number int) ([]*Commit, error)
	SetCommitStatus(ctx context.Context, owner, repo, ref string, status *CommitStatus) error

	ParsePullRequestEvent(ctx context.Context, payload []byte) (*PullRequestEvent, error)

	AddCollaborator(ctx context.Context, owner, repo, username string) (*RepoInvitation, error)
	RemoveCollaborator(ctx context.Context, owner, repo, username string) error
	AcceptRepoInvitation(ctx context.Context, invitationID int) error
}

type PullRequest

type PullRequest struct {
	Head  *Branch
	State string // MERGED|CLOSED
}

type PullRequestAction

type PullRequestAction string
const (
	Opened       PullRequestAction = "opened"
	Synchronized PullRequestAction = "synchronize"
)

type PullRequestEvent

type PullRequestEvent struct {
	Repo              *Repo
	Head              *Branch
	PullRequestNumber int
	Action            PullRequestAction
}

type Repo

type Repo struct {
	ID            int
	FullName      string
	IsAdmin       bool
	IsPrivate     bool
	DefaultBranch string

	// The parent and source objects are present when the repository is a fork.
	// parent is the repository this repository was forked from,
	// source is the ultimate source for the network.
	Source *Repo

	StargazersCount int
	Language        string
	Organization    string
	OwnerID         int
}

Repo represents provider repository. On any incompatible change don't forget to bump cache version in fetchProviderReposCached

func (Repo) Name

func (r Repo) Name() string

func (Repo) Owner

func (r Repo) Owner() string

type RepoInvitation

type RepoInvitation struct {
	ID                    int
	IsAlreadyCollaborator bool
}

Jump to

Keyboard shortcuts

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