github

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: 24 Imported by: 0

Documentation

Overview

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.

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.

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.

Index

Constants

View Source
const (
	DefaultURL   = "https://github.com"
	DefaultAPI   = "https://api.github.com/"
	DefaultScope = "read:org,repo:status"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Protection struct {
		Enabled bool `json:"enabled"`
		Checks  struct {
			Enforcement string   `json:"enforcement_level"`
			Contexts    []string `json:"contexts"`
		} `json:"required_status_checks"`
	} `json:"protection"`
}

type Client

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

func NewClient

func NewClient(uri string) *Client

NewClient returns a client at the specified url.

func NewClientToken

func NewClientToken(uri, token string) *Client

NewClientToken returns a client at the specified url that authenticates all outbound requests with the given token.

func (*Client) SetClient

func (c *Client) SetClient(client *http.Client)

SetClient sets the default http client. This should be used in conjunction with golang.org/x/oauth2 to authenticate requests to the server.

type Github

type Github struct {
	URL    string
	API    string
	Client string
	Secret string
}

func Get

func Get() *Github

func (*Github) Capabilities

func (g *Github) Capabilities(ctx context.Context, u *model.User) (*model.Capabilities, error)

func (*Github) CompareBranches

func (g *Github) CompareBranches(ctx context.Context, u *model.User, repo *model.Repo, base string, head string, owner string) (model.BranchCompare, error)

func (*Github) CreateEmptyCommit

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

func (*Github) CreatePR

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

func (*Github) CreateReference

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

func (*Github) CreateURLCompare

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

func (*Github) DelHook

func (g *Github) DelHook(ctx context.Context, user *model.User, repo *model.Repo, link string) error

func (*Github) DelOrgHook

func (g *Github) DelOrgHook(ctx context.Context, user *model.User, org *model.OrgDb, link string) error

func (*Github) DeleteBranch

func (g *Github) DeleteBranch(ctx context.Context, u *model.User, repo *model.Repo, name string) error

func (*Github) GetAllComments

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

func (*Github) GetAllReviews

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

func (*Github) GetCollaborators

func (g *Github) GetCollaborators(ctx context.Context, user *model.User, owner, name string) (set.Set, error)

func (*Github) GetCommentsSinceHead

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

func (*Github) GetCommits

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

func (*Github) GetContents

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

func (*Github) GetIssue

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

func (*Github) GetOrg

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

func (*Github) GetOrgMembers

func (g *Github) GetOrgMembers(ctx context.Context, user *model.User, org string) (set.Set, error)

func (*Github) GetOrgPerm

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

func (*Github) GetOrgRepos

func (g *Github) GetOrgRepos(ctx context.Context, u *model.User, owner string) ([]*model.Repo, error)

func (*Github) GetOrgs

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

func (*Github) GetPerm

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

func (*Github) GetPerson

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

func (*Github) GetPullRequest

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

func (*Github) GetPullRequestCommits

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

func (*Github) GetPullRequestFiles

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

func (*Github) GetPullRequestsForCommit

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

func (*Github) GetRepo

func (g *Github) GetRepo(ctx context.Context, user *model.User, owner, name string) (*model.Repo, error)

func (*Github) GetReviewsSinceHead

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

func (*Github) GetScopes

func (g *Github) GetScopes(ctx context.Context, token string) (string, error)

func (*Github) GetStatus

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

func (*Github) GetTeamMembers

func (g *Github) GetTeamMembers(ctx context.Context, user *model.User, org string, team string) (set.Set, error)

func (*Github) GetUser

func (g *Github) GetUser(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error)

func (*Github) GetUserRepos

func (g *Github) GetUserRepos(ctx context.Context, u *model.User) ([]*model.Repo, error)

func (*Github) GetUserToken

func (g *Github) GetUserToken(ctx context.Context, token string) (string, error)

func (*Github) HasRequiredStatus

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

func (*Github) IsHeadUIMerge

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

func (*Github) ListTags

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

func (*Github) ListTeams

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

func (*Github) MergePR

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

func (*Github) RevokeAuthorization

func (g *Github) RevokeAuthorization(ctx context.Context, user *model.User) error

func (*Github) ScheduleDeployment

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

func (*Github) SetHook

func (g *Github) SetHook(ctx context.Context, user *model.User, repo *model.Repo, link string) error

func (*Github) SetOrgHook

func (g *Github) SetOrgHook(ctx context.Context, user *model.User, org *model.OrgDb, link string) error

func (*Github) SetStatus

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

func (*Github) Tag

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

func (*Github) WriteComment

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

type UserTransport

type UserTransport struct {
	Login string
	Event string
	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

func (*UserTransport) RoundTrip

func (t *UserTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

Jump to

Keyboard shortcuts

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