remote

package
v0.0.0-...-4cbfb34 Latest Latest
Warning

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

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

Documentation

Overview

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capabilities

func Capabilities(c context.Context, u *model.User) (*model.Capabilities, error)

Capabilities generates the user's capabilities

func CompareBranches

func CompareBranches(c context.Context, u *model.User, r *model.Repo, ref1 string, ref2 string, owner string) (model.BranchCompare, error)

func CreateEmptyCommit

func CreateEmptyCommit(c context.Context, u *model.User, r *model.Repo, sha, msg string) (string, error)

CreateEmptyCommit creates an empty commit from the provided parent sha.

func CreatePR

func CreatePR(c context.Context, u *model.User, r *model.Repo, title, head, base, body string) (int, error)

CreatePR creates a new pull request

func CreateReference

func CreateReference(c context.Context, u *model.User, r *model.Repo, sha, name string) (string, error)

CreateReference creates a reference pointing to the provided commit

func CreateURLCompare

func CreateURLCompare(c context.Context, u *model.User, r *model.Repo, sha1, sha2 string) string

CreateURLCompare creates a URL that prepares a diff of two commits

func DelHook

func DelHook(c context.Context, u *model.User, r *model.Repo, hook string) error

DelHook deletes a webhook from the remote repository.

func DelOrgHook

func DelOrgHook(c context.Context, u *model.User, o *model.OrgDb, hook string) error

DelOrgHook deletes a webhook from the remote organization.

func DeleteBranch

func DeleteBranch(c context.Context, u *model.User, repo *model.Repo, ref string) error

func GetAllComments

func GetAllComments(c context.Context, u *model.User, r *model.Repo, num int) ([]*model.Comment, error)

GetAllComments gets pull request comments from the remote system.

func GetAllReviews

func GetAllReviews(c context.Context, u *model.User, r *model.Repo, num int) ([]*model.Review, error)

GetAllReviews gets pull request reviews from the remote system.

func GetCollaborators

func GetCollaborators(c context.Context, user *model.User, owner, name string) ([]*model.Person, error)

GetCollaborators gets an collaborators member list from the remote system. Looks for information about each person in the long term cache.

func GetCommentsSinceHead

func GetCommentsSinceHead(c context.Context, u *model.User, r *model.Repo, num int, noUIMerge bool) ([]*model.Comment, error)

GetCommentsSinceHead gets pull request comments from the remote system since the head commit was committed

func GetCommits

func GetCommits(c context.Context, u *model.User, r *model.Repo, sha string, page, perPage int) ([]string, int, error)

GetCommits gets one page of git commits

func GetContents

func GetContents(c context.Context, u *model.User, r *model.Repo, path string) ([]byte, error)

GetContents gets the file contents from the remote system.

func GetIssue

func GetIssue(c context.Context, u *model.User, r *model.Repo, number int) (model.Issue, error)

GetIssue returns the issue associated with a issue number

func GetOrg

func GetOrg(c context.Context, user *model.User, owner string) (*model.OrgDb, error)

func GetOrgMembers

func GetOrgMembers(c context.Context, user *model.User, org string) ([]*model.Person, error)

GetOrgMembers gets an organization member list from the remote system. Looks for information about each person in the long term cache.

func GetOrgPerm

func GetOrgPerm(c context.Context, user *model.User, owner string) (*model.Perm, error)

func GetOrgRepos

func GetOrgRepos(c context.Context, user *model.User, owner string) ([]*model.Repo, error)

func GetOrgs

func GetOrgs(c context.Context, user *model.User) ([]*model.GitHubOrg, error)

GetOrgs returns the list of user organizations from the cache associated with the current context.

func GetPerm

func GetPerm(c context.Context, user *model.User, owner, name string) (*model.Perm, error)

GetPerm returns the user permissions repositories from the cache associated with the current repository.

func GetPerson

func GetPerson(c context.Context, user *model.User, login string) (*model.Person, error)

GetPerson retrieves metadata information about a user with the remote system.

func GetPullRequest

func GetPullRequest(c context.Context, u *model.User, r *model.Repo, number int) (model.PullRequest, error)

func GetPullRequestCommits

func GetPullRequestCommits(c context.Context, u *model.User, r *model.Repo, number int) ([]model.Commit, error)

func GetPullRequestFiles

func GetPullRequestFiles(c context.Context, u *model.User, r *model.Repo, number int) ([]model.CommitFile, error)

func GetPullRequestsForCommit

func GetPullRequestsForCommit(c context.Context, u *model.User, r *model.Repo, sha *string) ([]model.PullRequest, error)

func GetRepo

func GetRepo(c context.Context, u *model.User, owner, name string) (*model.Repo, error)

GetRepo gets a repository from the remote system.

func GetReviewsSinceHead

func GetReviewsSinceHead(c context.Context, u *model.User, r *model.Repo, num int, noUIMerge bool) ([]*model.Review, error)

GetReviewsSinceHead gets pull request reviews from the remote system since the head commit was committed

func GetStatus

func GetStatus(c context.Context, u *model.User, r *model.Repo, sha string) (model.CombinedStatus, error)

GetStatus gets the commit statuses in the remote system.

func GetTeamMembers

func GetTeamMembers(c context.Context, user *model.User, org string, team string) ([]*model.Person, error)

GetTeamMembers gets an repo's team members list from the remote system. Looks for information about each person in the long term cache.

func GetUser

GetUser authenticates a user with the remote system.

func GetUserRepos

func GetUserRepos(c context.Context, user *model.User) ([]*model.Repo, error)

func GetUserToken

func GetUserToken(c context.Context, token string) (string, error)

GetUserToken authenticates a user with the remote system using the remote systems OAuth token.

func HasRequiredStatus

func HasRequiredStatus(c context.Context, u *model.User, r *model.Repo, branch, sha string) (bool, error)

HasRequiredStatus tests whether the required commit statuses are passing.

func IsHeadUIMerge

func IsHeadUIMerge(c context.Context, u *model.User, r *model.Repo, num int) (bool, error)

IsHeadUIMerge tests whether the HEAD of the pull request is a user interface merge.

func ListTags

func ListTags(c context.Context, u *model.User, r *model.Repo) ([]model.Tag, error)

func ListTeams

func ListTeams(c context.Context, user *model.User, org string) (set.Set, error)

ListTeams returns the list of team names from the cache associated with the current context.

func MergePR

func MergePR(c context.Context, u *model.User, r *model.Repo, pullRequest model.PullRequest, approvers []*model.Person, message string, mergeMethod string) (string, error)

func RevokeAuthorization

func RevokeAuthorization(c context.Context, user *model.User) error

RevokeAuthorization revokes the OAuth token

func ScheduleDeployment

func ScheduleDeployment(c context.Context, u *model.User, r *model.Repo, d model.DeploymentInfo) error

func SetHook

func SetHook(c context.Context, u *model.User, r *model.Repo, hook string) error

SetHook adds a webhook to the remote repository.

func SetOrgHook

func SetOrgHook(c context.Context, u *model.User, o *model.OrgDb, hook string) error

SetOrgHook adds a webhook to the remote organization.

func SetStatus

func SetStatus(c context.Context, u *model.User, r *model.Repo, sha, context, status, desc string) error

SetStatus adds or updates the commit status in the remote system.

func Tag

func Tag(c context.Context, u *model.User, r *model.Repo, tag string, sha string) error

func ToContext

func ToContext(c Setter, client Remote)

ToContext adds the Remote client to this context if it supports the Setter interface.

func WriteComment

func WriteComment(c context.Context, u *model.User, r *model.Repo, num int, message string) error

Types

type Account

type Account struct {
	Login  string `json:"login"`
	Avatar string `json:"avatar"`
	Kind   string `json:"type"`
}

Account represents a user or team account.

type Comment

type Comment struct {
	Author string `json:"author"`
	Body   string `json:"body"`
}

Comment represents a user comment on an issue or pull request.

type Issue

type Issue struct {
	Number int    `json:"issue"`
	Title  string `json:"title"`
	Author string `json:"author"`
}

Issue represents an issue or pull request.

type Remote

type Remote interface {
	// Capabilities generates the user's capabilities
	Capabilities(context.Context, *model.User) (*model.Capabilities, error)

	// GetUser authenticates a user with the remote system.
	GetUser(context.Context, http.ResponseWriter, *http.Request) (*model.User, error)

	// GetUserToken authenticates a user with the remote system using
	// the remote systems OAuth token.
	GetUserToken(context.Context, string) (string, error)

	// RevokeAuthorization revokes the OAuth token
	RevokeAuthorization(c context.Context, user *model.User) error

	// GetPerson retrieves metadata information about a user with the remote system.
	GetPerson(c context.Context, user *model.User, login string) (*model.Person, error)

	// GetOrgs gets a organization list from the remote system.
	GetOrgs(context.Context, *model.User) ([]*model.GitHubOrg, error)

	// ListTeams gets the repo's list of team names
	ListTeams(c context.Context, user *model.User, org string) (set.Set, error)

	// GetOrgMembers gets an organization member list from the remote system.
	GetOrgMembers(context.Context, *model.User, string) (set.Set, error)

	// GetTeamMembers gets an org's team members list from the remote system.
	GetTeamMembers(c context.Context, user *model.User, org string, team string) (set.Set, error)

	// GetCollaborators gets a collaborators list from the remote system.
	GetCollaborators(context.Context, *model.User, string, string) (set.Set, error)

	// GetRepo gets a repository from the remote system.
	GetRepo(context.Context, *model.User, string, string) (*model.Repo, error)

	// GetPerm gets a repository permission from the remote system.
	GetPerm(context.Context, *model.User, string, string) (*model.Perm, error)

	// SetHook adds a webhook to the remote repository.
	SetHook(context.Context, *model.User, *model.Repo, string) error

	// DelHook deletes a webhook from the remote repository.
	DelHook(context.Context, *model.User, *model.Repo, string) error

	// GetAllComments gets pull request comments from the remote system.
	GetAllComments(context.Context, *model.User, *model.Repo, int) ([]*model.Comment, error)

	// GetCommentsSinceHead gets pull request comments from the remote system since the head commit was committed.
	GetCommentsSinceHead(context.Context, *model.User, *model.Repo, int, bool) ([]*model.Comment, error)

	// GetAllReviews gets pull request reviews from the remote system.
	GetAllReviews(context.Context, *model.User, *model.Repo, int) ([]*model.Review, error)

	// GetReviewsSinceHead gets pull request reviews from the remote system since the head commit was committed.
	GetReviewsSinceHead(context.Context, *model.User, *model.Repo, int, bool) ([]*model.Review, error)

	// IsHeadUIMerge tests whether the HEAD of the pull request is a user interface merge.
	IsHeadUIMerge(c context.Context, u *model.User, r *model.Repo, num int) (bool, error)

	// CreateCompareURL creates a URL that prepares a diff of two commits
	CreateURLCompare(c context.Context, u *model.User, r *model.Repo, sha1, sha2 string) string

	// GetCommits gets one page of git commits
	GetCommits(context.Context, *model.User, *model.Repo, string, int, int) ([]string, int, error)

	// GetContents gets the file contents from the remote system.
	GetContents(context.Context, *model.User, *model.Repo, string) ([]byte, error)

	// GetStatus gets the commit statuses in the remote system.
	GetStatus(c context.Context, u *model.User, r *model.Repo, sha string) (model.CombinedStatus, error)

	// HasRequiredStatus tests whether the required commit statuses are passing.
	HasRequiredStatus(c context.Context, u *model.User, r *model.Repo, branch, sha string) (bool, error)

	// SetStatus adds or updates the commit status in the remote system.
	SetStatus(c context.Context, u *model.User, r *model.Repo, sha, context, status, desc string) error

	// CreateEmptyCommit creates an empty commit from the provided parent sha.
	CreateEmptyCommit(c context.Context, u *model.User, r *model.Repo, sha, msg string) (string, error)

	// CreateReference creates a reference pointing to the provided commit
	CreateReference(ctx context.Context, u *model.User, r *model.Repo, sha, name string) (string, error)

	// CreatePR creates a new pull request
	CreatePR(c context.Context, u *model.User, r *model.Repo, title, head, base, body string) (int, error)

	// MergePR merges the named pull request from the remote system
	MergePR(c context.Context, u *model.User, r *model.Repo, pullRequest model.PullRequest, approvers []*model.Person, message string, mergeMethod string) (string, error)

	// CompareBranches compares two branches for changes
	CompareBranches(c context.Context, u *model.User, repo *model.Repo, base string, head string, owner string) (model.BranchCompare, error)

	// DeleteBranch deletes a branch with the given reference
	DeleteBranch(c context.Context, u *model.User, repo *model.Repo, ref string) error

	// GetMaxExistingTag finds the highest tag across all tags
	ListTags(c context.Context, u *model.User, r *model.Repo) ([]model.Tag, error)

	// Tag applies a tag with the specified string to the specified sha
	Tag(c context.Context, u *model.User, r *model.Repo, tag string, sha string) error

	// GetPullRequest returns the pull request associated with a pull request number
	GetPullRequest(c context.Context, u *model.User, r *model.Repo, number int) (model.PullRequest, error)

	// GetPullRequestFiles returns the changed files associated with a pull request number
	GetPullRequestFiles(c context.Context, u *model.User, r *model.Repo, number int) ([]model.CommitFile, error)

	// GetPullRequestCommits returns the commits associated with a pull request number
	GetPullRequestCommits(c context.Context, u *model.User, r *model.Repo, number int) ([]model.Commit, error)

	// GetPullRequestsForCommit returns all pull requests associated with a commit SHA
	GetPullRequestsForCommit(c context.Context, u *model.User, r *model.Repo, sha *string) ([]model.PullRequest, error)

	// GetIssue returns the issue associated with a issue number
	GetIssue(c context.Context, u *model.User, r *model.Repo, number int) (model.Issue, error)

	// WriteComment puts a new comment into the PR
	WriteComment(c context.Context, u *model.User, r *model.Repo, num int, message string) error

	ScheduleDeployment(c context.Context, u *model.User, r *model.Repo, d model.DeploymentInfo) error

	GetOrgPerm(c context.Context, user *model.User, owner string) (*model.Perm, error)

	// SetOrgHook adds a webhook to the remote organization.
	SetOrgHook(context.Context, *model.User, *model.OrgDb, string) error

	// DelOrgHook deletes a webhook from the remote organization.
	DelOrgHook(context.Context, *model.User, *model.OrgDb, string) error

	GetOrg(c context.Context, user *model.User, owner string) (*model.OrgDb, error)

	// GetOrgRepos gets the organization repository list from the remote system.
	GetOrgRepos(c context.Context, u *model.User, owner string) ([]*model.Repo, error)

	// GetUserRepos gets the user repository list from the remote system.
	GetUserRepos(context.Context, *model.User) ([]*model.Repo, error)
}

func FromContext

func FromContext(c context.Context) Remote

FromContext returns the Remote client associated with this context.

func Get

func Get() Remote

todo use some more dynamic way to register which git repository we are interacting with. For now, todo we only have github support, but might add support for other repo types at some point.

type Setter

type Setter interface {
	Set(string, interface{})
}

Setter defines a context that enables setting values.

Directories

Path Synopsis
SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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