githubrepo

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package githubrepo implements clients.RepoClient for GitHub.

Index

Constants

This section is empty.

Variables

View Source
var (
	// RemainingTokens measures the remaining number of API tokens.
	RemainingTokens = stats.Int64("RemainingTokens",
		"Measures the remaining count of API tokens", stats.UnitDimensionless)

	// TokenIndex is the tag key for specifying a unique token.
	TokenIndex = tag.MustNewKey("tokenIndex")
	// ResourceType specifies the type of GitHub resource.
	ResourceType = tag.MustNewKey("resourceType")

	// GithubTokens tracks the usage/remaining stats per token per resource-type.
	GithubTokens = view.View{
		Name:        "GithubTokens",
		Description: "Token usage/remaining stats for Github API tokens",
		Measure:     RemainingTokens,
		TagKeys:     []tag.Key{TokenIndex, ResourceType},
		Aggregation: view.LastValue(),
	}
)

Functions

func CreateGithubRepoClient

func CreateGithubRepoClient(ctx context.Context,
	client *github.Client, graphClient *githubv4.Client) clients.RepoClient

CreateGithubRepoClient returns a Client which implements RepoClient interface.

func MakeGitHubTransport

func MakeGitHubTransport(innerTransport http.RoundTripper, accessTokens []string) http.RoundTripper

MakeGitHubTransport wraps input RoundTripper with GitHub authorization logic.

Types

type Client

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

Client is GitHub-specific implementation of RepoClient.

func (*Client) Close

func (client *Client) Close() error

Close implements RepoClient.Close.

func (*Client) GetDefaultBranch

func (client *Client) GetDefaultBranch() (clients.BranchRef, error)

GetDefaultBranch implements RepoClient.GetDefaultBranch.

func (*Client) GetFileContent

func (client *Client) GetFileContent(filename string) ([]byte, error)

GetFileContent implements RepoClient.GetFileContent.

func (*Client) InitRepo

func (client *Client) InitRepo(owner, repoName string) error

InitRepo sets up the GitHub repo in local storage for improving performance and GitHub token usage efficiency.

func (*Client) IsArchived added in v2.1.3

func (client *Client) IsArchived() (bool, error)

IsArchived implements RepoClient.IsArchived.

func (*Client) ListCommits added in v2.1.3

func (client *Client) ListCommits() ([]clients.Commit, error)

ListCommits implements RepoClient.ListCommits.

func (*Client) ListFiles

func (client *Client) ListFiles(predicate func(string) (bool, error)) ([]string, error)

ListFiles implements RepoClient.ListFiles.

func (*Client) ListMergedPRs

func (client *Client) ListMergedPRs() ([]clients.PullRequest, error)

ListMergedPRs implements RepoClient.ListMergedPRs.

Jump to

Keyboard shortcuts

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