Documentation ¶
Index ¶
- Constants
- func BuildGitHubBranch(ref string) string
- func BuildNewGitHubRepoName(author string, repo string) string
- func BuildRemoteURL(packageModel *models.PackageModel, ref string) string
- func CheckIfRefExists(author, repo string, ref string) (bool, error)
- func ParseStarCount(responseBody map[string]interface{}) int
- type APIKeyChain
- type APIKeyModel
- type RequestService
- func (gitHubRequestService *RequestService) CheckGitHubRepoExists(packageModel models.PackageModel) error
- func (gitHubRequestService *RequestService) CreateNewGitHubRepo(packageModel models.PackageModel) error
- func (gitHubRequestService *RequestService) FetchCommitSHA(author string, repo string, timestamp time.Time) (string, error)
- func (gitHubRequestService *RequestService) FetchCommitTimestamp(packageModel *models.PackageModel, commitSHA string) (time.Time, error)
- func (gitHubRequestService *RequestService) FetchGitHubDataForPackageModel(packageModel models.PackageModel) (map[string]interface{}, error)
- type RequestServiceParams
Constants ¶
const (
GitHubBaseAPIURL = "https://api.github.com"
)
GitHubBaseAPIURL is the base Github API
const (
GitHubGophrPackageOrgName = "gophr-packages"
)
GitHubGophrPackageOrgName is the Github organization name for all versioned packages
Variables ¶
This section is empty.
Functions ¶
func BuildGitHubBranch ¶
BuildGitHubBranch creates a new ref based on a hash of the old ref
func BuildNewGitHubRepoName ¶
BuildNewGitHubRepoName creates a new repo name hash uses for repo creation and lookup. Eliminates collision between similar usernames and packages
func BuildRemoteURL ¶
func BuildRemoteURL(packageModel *models.PackageModel, ref string) string
BuildRemoteURL creates a remote url for a packageModel based on it's ref
func CheckIfRefExists ¶
CheckIfRefExists checks whether a given ref exists in the remote refs list.
func ParseStarCount ¶
ParseStarCount TODO Won't need this after implementing FFJSON
Types ¶
type APIKeyChain ¶
type APIKeyChain struct { GitHubAPIKeys []APIKeyModel CurrentKey APIKeyModel }
APIKeyChain is responsible for managing GitHubAPIKeymodels and cycling through keys that hit their request limit
func NewAPIKeyChain ¶
func NewAPIKeyChain(params RequestServiceParams) *APIKeyChain
NewAPIKeyChain intializes and returns a new GitHubAPIKeyChain and instantiates all available keys in the db as APIKeyModels
type APIKeyModel ¶
type APIKeyModel struct { Key string RemainingUses int RequestsPerHour int RateLimitResetTime time.Time }
APIKeyModel represents a single Github API keys, it's responsible for keeping track of API usage via that key
type RequestService ¶
type RequestService struct {
APIKeyChain *APIKeyChain
}
RequestService is the library responsible for managing all outbound requests to GitHub
func NewRequestService ¶
func NewRequestService(params RequestServiceParams) *RequestService
NewRequestService initialies a new GitHubRequestService and APIKeyChain
func (*RequestService) CheckGitHubRepoExists ¶
func (gitHubRequestService *RequestService) CheckGitHubRepoExists( packageModel models.PackageModel, ) error
CheckGitHubRepoExists returns whether a repo exists TODO(Shikkic): Instead of pinging try downloading refs, might be more sustainable?
func (*RequestService) CreateNewGitHubRepo ¶
func (gitHubRequestService *RequestService) CreateNewGitHubRepo( packageModel models.PackageModel, ) error
CreateNewGitHubRepo if repo doesn't already exist will create a new repo on the GitHubGophrPackageOrgName repo
func (*RequestService) FetchCommitSHA ¶
func (gitHubRequestService *RequestService) FetchCommitSHA( author string, repo string, timestamp time.Time, ) (string, error)
FetchCommitSHA Fetches a commitSHA closest to a given timestamp
func (*RequestService) FetchCommitTimestamp ¶
func (gitHubRequestService *RequestService) FetchCommitTimestamp( packageModel *models.PackageModel, commitSHA string, ) (time.Time, error)
FetchCommitTimestamp fetches the timestamp of a commit from Github API
func (*RequestService) FetchGitHubDataForPackageModel ¶
func (gitHubRequestService *RequestService) FetchGitHubDataForPackageModel( packageModel models.PackageModel, ) (map[string]interface{}, error)
FetchGitHubDataForPackageModel fetchs current repo data of a given packageModel TODO optimize this with FFJSON models