Documentation ¶
Index ¶
- Constants
- Variables
- func CheckGithubAPILimit(token string) (int64, error)
- func CopyS3File(awsAuth *aws.Auth, fromS3URL string, toS3URL string, permissionACL string) error
- func GetGitHubMergeBaseRevision(oauthToken, repoOwner, repo, baseRevision string, currentCommit *GithubCommit) (string, error)
- func GetGithubAPIStatus() (string, error)
- func GetGithubFileURL(owner, repo, remotePath, revision string) string
- func GetGithubUser(token string) (githubUser *GithubLoginUser, githubOrganizations []GithubOrganization, ...)
- func GetS3File(auth *aws.Auth, s3URL string) (io.ReadCloser, error)
- func GetS3Location(s3URL string) (string, string, error)
- func GitApplyNumstat(patch string) (*bytes.Buffer, error)
- func IsFileNotFound(err error) bool
- func NewS3Session(auth *aws.Auth, region aws.Region) *s3.S3
- func NextGithubPageLink(header http.Header) string
- func ParseGitSummary(gitOutput fmt.Stringer) (summaries []patch.Summary, err error)
- func PutS3File(pushAuth *aws.Auth, localFilePath, s3URL, contentType, permissionACL string) error
- func S3CopyFile(awsAuth *aws.Auth, ...) error
- func SignAWSRequest(auth aws.Auth, canonicalPath string, req *http.Request)
- type APIRequestError
- type APIResponseError
- type APIUnmarshalError
- type AuthorDetails
- type BranchEvent
- type CommitAuthor
- type CommitDetails
- type CommitEvent
- type CopyObjectError
- type CopyObjectResult
- type CrowdUser
- type File
- type FileDecodeError
- type FileNotFoundError
- type GitHubCompareResponse
- type GithubAuthParameters
- type GithubAuthResponse
- type GithubCommit
- type GithubFile
- type GithubLoginUser
- type GithubOrganization
- type GithubUser
- type JiraCreateTicketResponse
- type JiraHandler
- func (jiraHandler *JiraHandler) CreateTicket(fields map[string]interface{}) (*JiraCreateTicketResponse, error)
- func (jiraHandler *JiraHandler) GetJIRATicket(key string) (*JiraTicket, error)
- func (jiraHandler *JiraHandler) JQLSearch(query string, startAt, maxResults int) (*JiraSearchResults, error)
- func (jiraHandler *JiraHandler) JQLSearchAll(query string) ([]JiraTicket, error)
- func (jiraHandler *JiraHandler) JiraHost() string
- func (jiraHandler *JiraHandler) UpdateTicket(key string, fields map[string]interface{}) error
- type JiraProject
- type JiraResolution
- type JiraSearchResults
- type JiraStatus
- type JiraTicket
- type Link
- type Parent
- type PatchSummary
- type RESTCrowdService
- type ResponseReadError
- type Session
- type SessionLink
- type SessionUser
- type Stats
- type TicketFields
- type TicketType
- type Tree
- type User
- type WrapCrowdUser
- type YAMLFormatError
Constants ¶
const ( GithubBase = "https://github.com" NumGithubRetries = 5 GithubSleepTimeSecs = 1 GithubAPIBase = "https://api.github.com" GithubStatusBase = "https://status.github.com" GithubAPIStatusMinor = "minor" GithubAPIStatusMajor = "major" GithubAPIStatusGood = "good" )
Variables ¶
var (
MaxRedirects = 10
)
Functions ¶
func CheckGithubAPILimit ¶
CheckGithubAPILimit queries Github for the number of API requests remaining
func CopyS3File ¶
func GetGitHubMergeBaseRevision ¶
func GetGitHubMergeBaseRevision(oauthToken, repoOwner, repo, baseRevision string, currentCommit *GithubCommit) (string, error)
func GetGithubAPIStatus ¶
func GetGithubFileURL ¶
GetGithubFileURL returns a URL that locates a github file given the owner, repo,remote path and revision
func GetGithubUser ¶
func GetGithubUser(token string) (githubUser *GithubLoginUser, githubOrganizations []GithubOrganization, err error)
GetGithubUser does a GET from GitHub for the user, email, and organizations information and returns the GithubLoginUser and its associated GithubOrganizations after authentication
func GetS3Location ¶
This is used to get the bucket and filename, ignoring any username/password so that it can be securely printed in logs Returns: (bucket, filename, error)
func GitApplyNumstat ¶
GitApplyNumstat attempts to apply a given patch; it returns the patch's bytes if it is successful
func IsFileNotFound ¶
func NextGithubPageLink ¶
NextPageLink returns the link to the next page for a given header's "Link" key based on http://developer.github.com/v3/#pagination For full details see http://tools.ietf.org/html/rfc5988
func ParseGitSummary ¶
ParseGitSummary takes in a buffer of data and parses it into a slice of git summaries. It returns an error if it is unable to parse the data
func PutS3File ¶
PutS3File writes the specified file to an s3 bucket using the given permissions and content type. The details of where to put the file are included in the s3URL
func S3CopyFile ¶
func SignAWSRequest ¶
Taken from https://github.com/mitchellh/goamz/blob/master/s3/sign.go Modified to access the headers/params on an HTTP req directly.
Types ¶
type APIRequestError ¶
type APIRequestError struct { Message string `json:"message"` DocumentationUrl string `json:"documentation_url"` }
When attempting to access the some API using authentication, requests may return 404 Not Found, instead of 403 Forbidden, under certain circumstances. For example, see https://developer.github.com/v3/#authentication. This struct should be used for errors in fetching a requested remote config.
func (APIRequestError) Error ¶
func (are APIRequestError) Error() string
type APIResponseError ¶
type APIResponseError struct {
// contains filtered or unexported fields
}
func (APIResponseError) Error ¶
func (are APIResponseError) Error() string
type APIUnmarshalError ¶
type APIUnmarshalError struct {
// contains filtered or unexported fields
}
func (APIUnmarshalError) Error ¶
func (ue APIUnmarshalError) Error() string
type AuthorDetails ¶
type BranchEvent ¶
type BranchEvent struct { Name string Commit GithubCommit Author CommitAuthor Parents []Parent URL string Commiter AuthorDetails Links Link }
func GetBranchEvent ¶
func GetBranchEvent(oauthToken, repoOwner, repo, branch string) (*BranchEvent, error)
GetBranchEvent gets the head of the a given branch via an API call to GitHub
type CommitDetails ¶
type CommitDetails struct { URL string Author CommitAuthor Committer CommitAuthor Message string Tree Tree }
type CommitEvent ¶
type CommitEvent struct { URL string SHA string Commit CommitDetails Author AuthorDetails Committer AuthorDetails Parents []Tree Stats Stats Files []File }
func GetCommitEvent ¶
func GetCommitEvent(oauthToken, repoOwner, repo, githash string) (*CommitEvent, error)
type CopyObjectError ¶
type CopyObjectError struct { XMLName xml.Name `xml:"Error"` Code string `xml:"Code"` Message string `xml:"Message"` Resource string `xml:"Resource"` RequestId string `xml:"RequestId"` ErrMsg string }
func (CopyObjectError) Error ¶
func (e CopyObjectError) Error() string
type CopyObjectResult ¶
type CopyObjectResult struct { XMLName xml.Name `xml:"CopyObjectResult"` LastModified string `xml:"LastModified"` ETag string `xml:"ETag"` }
For our S3 copy operations, S3 either returns an CopyObjectResult or a CopyObjectError body. In order to determine what kind of response was returned we read the body returned from the API call
type CrowdUser ¶
type CrowdUser struct { Active bool `json:"active"` DispName string `json:"display-name"` EmailAddress string `json:"email"` FirstName string `json:"first-name"` LastName string `json:"last-name"` Name string `json:"name"` }
func (*CrowdUser) DisplayName ¶
type FileDecodeError ¶
type FileDecodeError struct {
Message string
}
func (FileDecodeError) Error ¶
func (f FileDecodeError) Error() string
type FileNotFoundError ¶
type FileNotFoundError struct {
// contains filtered or unexported fields
}
This error should be returned when the requested remote configuration file can not be found.
func (FileNotFoundError) Error ¶
func (nfe FileNotFoundError) Error() string
type GitHubCompareResponse ¶
type GitHubCompareResponse struct { Url string `json:"url"` HtmlUrl string `json:"html_url"` PermalinkUrl string `json:"permalink_url"` DiffUrl string `json:"diff_url"` PatchUrl string `json:"patch_url"` BaseCommit CommitEvent `json:"base_commit"` Author AuthorDetails `json:"author"` Committer AuthorDetails `json:"committer"` Parents []Parent `json:"parents"` MergeBaseCommit CommitEvent `json:"merge_base_commit"` Files File `json:"file"` Commits []CommitDetails `json:"commits"` TotalCommits int `json:"total_commits"` BehindBy int `json:"behind_by"` AheadBy int `json:"ahead_by"` Status string `json:"status"` }
type GithubAuthParameters ¶
type GithubAuthResponse ¶
type GithubAuthResponse struct { AccessToken string `json:"access_token"` Scope string `json:"scope"` TokenType string `json:"token_type"` }
func GithubAuthenticate ¶
func GithubAuthenticate(code, clientId, clientSecret string) (githubResponse *GithubAuthResponse, err error)
GithubAuthenticate does a POST to github with the code that it received, the ClientId, ClientSecret And returns the response which contains the accessToken associated with the user.
type GithubCommit ¶
type GithubCommit struct { Url string SHA string Commit CommitDetails Author CommitAuthor Committer CommitAuthor Parents []Parent }
func GetGithubCommits ¶
func GetGithubCommits(oauthToken, commitsURL string) ( githubCommits []GithubCommit, header http.Header, err error)
GetGithubCommits returns a slice of GithubCommit objects from the given commitsURL when provided a valid oauth token
type GithubFile ¶
type GithubFile struct { Name string Path string SHA string Size int URL string HtmlURL string GitURL string Type string Content string Encoding string Links Link }
func GetGithubFile ¶
func GetGithubFile(oauthToken, fileURL string) (githubFile *GithubFile, err error)
GetGithubFile returns a struct that contains the contents of files within a repository as Base64 encoded content.
type GithubLoginUser ¶
type GithubLoginUser struct { Login string Id int Company string EmailAddress string `json:"email"` Name string OrganizationsURL string }
func (*GithubLoginUser) DisplayName ¶
func (u *GithubLoginUser) DisplayName() string
func (*GithubLoginUser) Email ¶
func (u *GithubLoginUser) Email() string
func (*GithubLoginUser) Username ¶
func (u *GithubLoginUser) Username() string
type GithubOrganization ¶
type GithubUser ¶
type JiraCreateTicketResponse ¶
type JiraCreateTicketResponse struct { Id string `json:"id"` Key string `json:"key"` Self string `json:"self"` }
JiraCreateTicketResponse contains the results of a JIRA create ticket API call.
type JiraHandler ¶
func NewJiraHandler ¶
func NewJiraHandler(server string, user string, password string) JiraHandler
func (*JiraHandler) CreateTicket ¶
func (jiraHandler *JiraHandler) CreateTicket(fields map[string]interface{}) (*JiraCreateTicketResponse, error)
CreateTicket takes a map of fields to initialize a JIRA ticket with. Returns a response containing the new ticket's key, id, and API URL. See the JIRA API documentation for help.
func (*JiraHandler) GetJIRATicket ¶
func (jiraHandler *JiraHandler) GetJIRATicket(key string) (*JiraTicket, error)
GetJIRATicket returns the ticket with the given key.
func (*JiraHandler) JQLSearch ¶
func (jiraHandler *JiraHandler) JQLSearch(query string, startAt, maxResults int) (*JiraSearchResults, error)
JQLSearch runs the given JQL query against the given jira instance and returns the results in a JiraSearchResults
func (*JiraHandler) JQLSearchAll ¶
func (jiraHandler *JiraHandler) JQLSearchAll(query string) ([]JiraTicket, error)
JQLSearchAll performs repeated JQL searches until the query has been exhausted
func (*JiraHandler) JiraHost ¶
func (jiraHandler *JiraHandler) JiraHost() string
JiraHost returns the hostname of the jira service as configured.
func (*JiraHandler) UpdateTicket ¶
func (jiraHandler *JiraHandler) UpdateTicket(key string, fields map[string]interface{}) error
UpdateTicket sets the given fields of the ticket with the given key. Returns any errors JIRA returns.
type JiraProject ¶
type JiraResolution ¶
type JiraSearchResults ¶
type JiraSearchResults struct { Expand string `json:"expand"` StartAt int `json:"startAt"` MaxResults int `json:"maxResults"` Total int `json:"total"` Issues []JiraTicket `json:"issues"` }
JiraSearchResults marshal to and unmarshal from the json search results returned by the rest api at /rest/api/2/search?jql={jql}
type JiraStatus ¶
type JiraTicket ¶
type JiraTicket struct { Key string `json:"key"` Expand string `json:"expand"` Fields *TicketFields `json:"fields"` }
JiraTickets marshal to and unmarshal from the json issue returned by the rest api at /rest/api/latest/issue/{ticket_id}
type PatchSummary ¶
Github API response structs
type RESTCrowdService ¶
type RESTCrowdService struct {
// contains filtered or unexported fields
}
func NewRESTCrowdService ¶
func NewRESTCrowdService(crowdUsername string, crowdPassword string, baseUrl string) (*RESTCrowdService, error)
func (*RESTCrowdService) CreateSession ¶
func (self *RESTCrowdService) CreateSession(username, password string) (*Session, error)
func (*RESTCrowdService) GetUser ¶
func (self *RESTCrowdService) GetUser(username string) (*CrowdUser, error)
func (*RESTCrowdService) GetUserFromToken ¶
func (self *RESTCrowdService) GetUserFromToken(token string) (*CrowdUser, error)
type ResponseReadError ¶
type ResponseReadError struct {
// contains filtered or unexported fields
}
func (ResponseReadError) Error ¶
func (re ResponseReadError) Error() string
type Session ¶
type Session struct { Expand string `json:"active"` CreatedDate int64 `json:"created-date"` ExpiryDate int64 `json:"expiry-date"` User SessionUser `json:"user"` Link SessionLink `json:"link"` Token string `json:"token"` }
type SessionLink ¶
type SessionUser ¶
type SessionUser struct { Name string `json:"name"` Link SessionLink `json:"link"` }
type TicketFields ¶
type TicketFields struct { IssueType *TicketType `json:"issuetype"` Summary string `json:"summary"` Description string `json:"description"` Reporter *User `json:"reporter"` Assignee *User `json:"assignee"` Project *JiraProject `json:"project"` Resolution *JiraResolution `json:"resolution"` Created string `json:"created"` Updated string `json:"updated"` Status *JiraStatus `json:"status"` }
type TicketType ¶
type WrapCrowdUser ¶
type WrapCrowdUser struct {
User CrowdUser `json:"user"`
}
type YAMLFormatError ¶
type YAMLFormatError struct {
Message string
}
func (YAMLFormatError) Error ¶
func (y YAMLFormatError) Error() string