Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // NewClient is a variable that holds the function to create a new GitHub client. // This allows for mocking in tests. NewClient = func(httpClient *http.Client) *github.Client { return github.NewClient(httpClient) } // NewRequest is a variable that holds the function to create a new HTTP request. NewRequest = func(method, url string, body io.Reader) (*http.Request, error) { return http.NewRequest(method, url, body) } // DefaultClient is the default http client DefaultClient = &http.Client{} )
View Source
var NewAuthenticatedClient = func(ctx context.Context) *http.Client { token := os.Getenv("GITHUB_TOKEN") if token == "" { return http.DefaultClient } ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: token}, ) return oauth2.NewClient(ctx, ts) }
NewAuthenticatedClient creates a new authenticated http client.
Functions ¶
func DownloadReleaseAsset ¶
func DownloadReleaseAsset(asset *github.ReleaseAsset) ([]byte, error)
DownloadReleaseAsset downloads a release asset.
func GetLatestRelease ¶
func GetLatestRelease(owner, repo string) (*github.RepositoryRelease, error)
GetLatestRelease gets the latest release for a repository.
func ParseRepoFromURL ¶
ParseRepoFromURL parses the owner and repository from a GitHub URL.
Types ¶
type GithubClient ¶
type GithubClient interface {
GetPublicRepos(ctx context.Context, userOrOrg string) ([]string, error)
}
GithubClient is an interface for interacting with the Github API.
func NewGithubClient ¶
func NewGithubClient() GithubClient
NewGithubClient creates a new GithubClient.
Click to show internal directories.
Click to hide internal directories.