github_api

package
v0.0.0-...-b203053 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPagedResults

func GetPagedResults[T any](
	config *config.AppConfig,
	options *github.ListOptions,
	operation func(config *config.AppConfig, options *github.ListOptions) ([]T, *github.Response, error)) ([]T, error)

GetPagedResults handles executing the provide API method until all results are retrieved. The number of results per page is determined the github.ListOptions.

func WaitForRateLimit

func WaitForRateLimit(err error, resp *github.Response) bool

Waits for the GitHub API rate limit to be reset.

Types

type GHClient

type GHClient struct {
	Client *github.Client
	Ctx    context.Context
}

GHClient struct - contains the context and a pointer to a github.Client that will be used to execute GitHub API methods

func NewClient

func NewClient(token string) *GHClient

Creates a new GitHub Client

func (*GHClient) CodeSearch

func (ghClient *GHClient) CodeSearch(repo api_results.GHRepo, tokens []string, config *config.AppConfig) (*api_results.CodeScanResults, error)

Calls the GitHub search API looking for the set of tokens provided.

func (*GHClient) GetLanguages

func (ghClient *GHClient) GetLanguages(languagesUrl string) ([]api_results.GHLanguage, error)

GitHub Languages Request

There is not a provided method for retrieving the list of language for a repository in the Go GitHub API.

Create and call the request using the provided teams URL

func (*GHClient) GetRepoData

func (ghClient *GHClient) GetRepoData(
	repoScanResults api_results.RepoScanResult,
	owner string,
	teamsToIgnore config.TeamsToIgnore) (*api_results.GHRepo, error)

Retrieves the repository data for the provided dependency scan results

func (*GHClient) GetReposForOrg

func (ghClient *GHClient) GetReposForOrg(config *config.AppConfig) (api_results.GHRepos, error)

Get the organization's repositories for the provided config values

Config values of interest - PerPage - Owner

func (*GHClient) GetTeams

func (ghClient *GHClient) GetTeams(teamsUrl string, teamsToIgnore config.TeamsToIgnore) (string, error)

GitHub Teams Request

There is not a provided method for retrieving the list of teams for a repository in the Go GitHub API

Create and call the request using the provided teams URL

func (*GHClient) ScanPackageDeps

func (ghClient *GHClient) ScanPackageDeps(config *config.AppConfig) (api_results.RepoScanResults, error)

Initiates a code search that looks for the instance of the dependecies defined

in the application configuration. It then returns a slice of RepoScanResult

containing the repository, location and version of the dependency that was searched.

func (*GHClient) SearchReposByLanguage

func (ghClient *GHClient) SearchReposByLanguage(config *config.AppConfig) (api_results.GHRepos, error)

func (*GHClient) SearchReposByLanguages

func (ghClient *GHClient) SearchReposByLanguages(config *config.AppConfig, listOptions *github.ListOptions) ([]api_results.GHRepo, *github.Response, error)

Jump to

Keyboard shortcuts

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