github

package
v0.2.7-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitHubBaseAPIURL = "https://api.github.com"
)

GitHubBaseAPIURL is the base Github API

View Source
const (
	GitHubGophrPackageOrgName = "gophr-packages"
)

GitHubGophrPackageOrgName is the Github organization name for all versioned packages

Variables

This section is empty.

Functions

func BuildGitHubBranch

func BuildGitHubBranch(ref string) string

BuildGitHubBranch creates a new ref based on a hash of the old ref

func BuildNewGitHubRepoName

func BuildNewGitHubRepoName(author string, repo string) string

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

func CheckIfRefExists(author, repo string, ref string) (bool, error)

CheckIfRefExists checks whether a given ref exists in the remote refs list.

func ParseStarCount

func ParseStarCount(responseBody map[string]interface{}) int

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

type RequestServiceParams

type RequestServiceParams struct {
	ForIndexer bool
	Conf       *config.Config
	Session    *gocql.Session
}

RequestServiceParams passes import Kubernetes configuration and secrets. Also can dictate whether request service is being used by indexer.

Jump to

Keyboard shortcuts

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