{"modulePath":"github.com/LF-Engineering/insights-connector-github","version":"v0.1.29","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package main\n\n## Constants\n\n```go\nconst (\n\t// GitHubBackendVersion - backend version\n\tGitHubBackendVersion = \"0.1.0\"\n\t// GitHubURLRoot - GitHub URL root\n\tGitHubURLRoot = \"https://github.com/\"\n\t// GitHubDefaultCachePath - default path where github users cache files are stored\n\tGitHubDefaultCachePath = \"/tmp/github-cache\"\n\t// MaxGitHubUsersFileCacheAge 90 days (in seconds) - file is considered too old anywhere between 90-180 days\n\tMaxGitHubUsersFileCacheAge = 7776000\n\t// MaxCommentBodyLength - max comment body length\n\tMaxCommentBodyLength = 4096\n\t// MaxIssueBodyLength - max issue body length\n\tMaxIssueBodyLength = 4096\n\t// MaxPullBodyLength - max pull request body length\n\tMaxPullBodyLength = 4096\n\t// MaxReviewBodyLength - max review body length\n\tMaxReviewBodyLength = 4096\n\t// MaxReviewCommentBodyLength - max review comment body length\n\tMaxReviewCommentBodyLength = 4096\n\t// ItemsPerPage - how many items in a page\n\tItemsPerPage = 100\n\t// AbuseWaitSeconds - N - wait random(N:2N) seconds if GitHub detected abuse\n\t// 7 means from 7 to 13 seconds, 10 on average\n\tAbuseWaitSeconds = 7\n\t// CacheGitHubRepo - cache this?\n\tCacheGitHubRepo = true\n\t// CacheGitHubIssues - cache this?\n\tCacheGitHubIssues = false\n\t// CacheGitHubUser - cache this?\n\tCacheGitHubUser = true\n\t// CacheGitHubUserFiles - cache this in files?\n\tCacheGitHubUserFiles = true\n\t// CacheGitHubIssueComments - cache this?\n\tCacheGitHubIssueComments = false\n\t// CacheGitHubCommentReactions - cache this?\n\tCacheGitHubCommentReactions = false\n\t// CacheGitHubIssueReactions - cache this?\n\tCacheGitHubIssueReactions = false\n\t// CacheGitHubPull - cache this?\n\tCacheGitHubPull = false\n\t// CacheGitHubPulls - cache this?\n\tCacheGitHubPulls = false\n\t// CacheGitHubPullReviews - cache this?\n\tCacheGitHubPullReviews = false\n\t// CacheGitHubPullReviewComments - cache this?\n\tCacheGitHubPullReviewComments = false\n\t// CacheGitHubReviewCommentReactions - cache this?\n\tCacheGitHubReviewCommentReactions = false\n\t// CacheGitHubPullRequestedReviewers - cache this?\n\tCacheGitHubPullRequestedReviewers = false\n\t// CacheGitHubPullCommits - cache this?\n\tCacheGitHubPullCommits = false\n\t// CacheGitHubUserOrgs - cache this?\n\tCacheGitHubUserOrgs = true\n\t// WantEnrichIssueAssignees - do we want to create rich documents for issue assignees (it contains identity data too).\n\tWantEnrichIssueAssignees = true\n\t// WantEnrichIssueCommentReactions - do we want to create rich documents for issue comment reactions (it contains identity data too).\n\tWantEnrichIssueCommentReactions = true\n\t// WantEnrichIssueReactions - do we want to create rich documents for issue reactions (it contains identity data too).\n\tWantEnrichIssueReactions = true\n\t// WantEnrichPullRequestAssignees - do we want to create rich documents for pull request assignees (it contains identity data too).\n\tWantEnrichPullRequestAssignees = true\n\t// WantEnrichPullRequestCommentReactions - do we want to create rich documents for pull request comment reactions (it contains identity data too).\n\tWantEnrichPullRequestCommentReactions = true\n\t// WantEnrichPullRequestRequestedReviewers - do we want to create rich documents for pull request requested reviewers (it contains identity data too).\n\tWantEnrichPullRequestRequestedReviewers = true\n\t// WantEnrichPullRequestCommits - do we want to create rich documents for pull request commits (it contains identity data too).\n\tWantEnrichPullRequestCommits = true\n\t// WantIssuePullRequestCommentsOnIssue - do we want to fetch pull request's issue part comments (pull requests are issues too) on the issue object?\n\tWantIssuePullRequestCommentsOnIssue = true\n\t// WantIssuePullRequestCommentsOnPullRequest - do we want to fetch pull request's issue part comments (pull requests are issues too) on the pull request object?\n\tWantIssuePullRequestCommentsOnPullRequest = true\n\t// GitHubDataSource - constant for github source\n\tGitHubDataSource = \"github\"\n\t// GitHubRepositoryDefaultStream - Stream To Publish repo stats\n\tGitHubRepositoryDefaultStream = \"PUT-S3-github-repository-stats\"\n\t// GitHubIssueDefaultStream - Stream To Publish issues\n\tGitHubIssueDefaultStream = \"PUT-S3-github-issues\"\n\t// GitHubPullRequestDefaultStream - Stream To Publish pull requests\n\tGitHubPullRequestDefaultStream = \"PUT-S3-github-pull-requests\"\n\t// GitHubConnector ...\n\tGitHubConnector = \"github-connector\"\n\t// GitHubRepository ...\n\tGitHubRepository = \"repository\"\n\t// GitHubPullrequest ...\n\tGitHubPullrequest = \"pullrequest\"\n\t// GitHubIssue ...\n\tGitHubIssue = \"issue\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// GitHubCategories - categories defined for GitHub\n\tGitHubCategories = map[string]struct{}{\"issue\": {}, \"pull_request\": {}, \"repository\": {}}\n\t// GitHubIssueRoles - roles to fetch affiliation data for github issue\n\tGitHubIssueRoles = []string{\"user_data\", \"assignee_data\", \"closed_by_data\"}\n\t// GitHubIssueCommentRoles - roles to fetch affiliation data for github issue comment\n\tGitHubIssueCommentRoles = []string{\"user_data\"}\n\t// GitHubIssueAssigneeRoles - roles to fetch affiliation data for github issue comment\n\tGitHubIssueAssigneeRoles = []string{\"assignee\"}\n\t// GitHubIssueReactionRoles - roles to fetch affiliation data for github issue reactions or issue comment reactions\n\tGitHubIssueReactionRoles = []string{\"user_data\"}\n\t// GitHubPullRequestRoles - roles to fetch affiliation data for github pull request\n\tGitHubPullRequestRoles = []string{\"user_data\", \"assignee_data\", \"merged_by_data\"}\n\t// GitHubPullRequestCommentRoles - roles to fetch affiliation data for github pull request comment\n\tGitHubPullRequestCommentRoles = []string{\"user_data\"}\n\t// GitHubPullRequestAssigneeRoles - roles to fetch affiliation data for github pull request comment\n\tGitHubPullRequestAssigneeRoles = []string{\"assignee\"}\n\t// GitHubPullRequestReactionRoles - roles to fetch affiliation data for github pull request comment reactions\n\tGitHubPullRequestReactionRoles = []string{\"user_data\"}\n\t// GitHubPullRequestRequestedReviewerRoles - roles to fetch affiliation data for github pull request requested reviewer\n\tGitHubPullRequestRequestedReviewerRoles = []string{\"requested_reviewer\"}\n\t// GitHubPullRequestReviewRoles - roles to fetch affiliation data for github pull request comment\n\tGitHubPullRequestReviewRoles = []string{\"user_data\"}\n\t// GitHubPullRequestCommitRoles - roles to fetch affiliation data for github pull request commit\n\tGitHubPullRequestCommitRoles = []string{\"author_data\", \"committer_data\"}\n)\n```\n\n## Types\n\n```go\ntype DSGitHub struct {\n\tOrg      string // github org\n\tRepo     string // github repo\n\tTokens   string // \",\" separated list of OAuth tokens\n\tCacheDir string // path to store github users cache, defaults to /tmp/github-cache\n\t// Flags\n\tFlagOrg       *string\n\tFlagRepo      *string\n\tFlagTokens    *string\n\tFlagCachePath *string\n\tFlagStream    *string\n\tFlagSourceID  *string\n\t// Others (calculated)\n\tURL                             string\n\tCategories                      []string\n\tCurrentCategory                 string\n\tClients                         []*github.Client\n\tContext                         context.Context\n\tOAuthKeys                       []string\n\tThrN                            int\n\tHint                            int\n\tRateHandled                     bool\n\tCanCache                        bool\n\tGitHubMtx                       *sync.RWMutex\n\tGitHubRepoMtx                   *sync.RWMutex\n\tGitHubIssuesMtx                 *sync.RWMutex\n\tGitHubUserMtx                   *sync.RWMutex\n\tGitHubIssueCommentsMtx          *sync.RWMutex\n\tGitHubCommentReactionsMtx       *sync.RWMutex\n\tGitHubIssueReactionsMtx         *sync.RWMutex\n\tGitHubPullMtx                   *sync.RWMutex\n\tGitHubPullsMtx                  *sync.RWMutex\n\tGitHubPullReviewsMtx            *sync.RWMutex\n\tGitHubPullReviewCommentsMtx     *sync.RWMutex\n\tGitHubReviewCommentReactionsMtx *sync.RWMutex\n\tGitHubPullRequestedReviewersMtx *sync.RWMutex\n\tGitHubPullCommitsMtx            *sync.RWMutex\n\tGitHubUserOrgsMtx               *sync.RWMutex\n\tGitHubRateMtx                   *sync.RWMutex\n\tGitHubRepo                      map[string]map[string]interface{}\n\tGitHubIssues                    map[string][]map[string]interface{}\n\tGitHubUser                      map[string]map[string]interface{}\n\tGitHubIssueComments             map[string][]map[string]interface{}\n\tGitHubCommentReactions          map[string][]map[string]interface{}\n\tGitHubIssueReactions            map[string][]map[string]interface{}\n\tGitHubPull                      map[string]map[string]interface{}\n\tGitHubPulls                     map[string][]map[string]interface{}\n\tGitHubPullReviews               map[string][]map[string]interface{}\n\tGitHubPullReviewComments        map[string][]map[string]interface{}\n\tGitHubReviewCommentReactions    map[string][]map[string]interface{}\n\tGitHubPullRequestedReviewers    map[string][]map[string]interface{}\n\tGitHubPullCommits               map[string][]map[string]interface{}\n\tGitHubUserOrgs                  map[string][]map[string]interface{}\n\tEmojisMtx                       *sync.RWMutex\n\tEmojis                          map[string]string\n\t// Publisher \u0026 stream\n\tPublisher\n\tStream string // stream to publish the data\n\tLogger logger.Logger\n\t// SourceID: the optional external source identifier (such as the repo ID from github/gitlab, or gerrit project slug)\n\t// this field is required for github, gitlab and gerrit. For github and gitlab, this is typically a numeric value\n\t// converted to a string such as 194341141. For gerrit this is the project (repository) slug.\n\tSourceID string\n\t// contains filtered or unexported fields\n}\n```\nDSGitHub - DS implementation for GitHub\n\n```go\nfunc (j *DSGitHub) AddCacheProvider()\n```\nAddCacheProvider - adds cache provider\n\n```go\nfunc (j *DSGitHub) AddFlags()\n```\nAddFlags - add GitHub specific flags\n\n```go\nfunc (j *DSGitHub) AddLogger(ctx *shared.Ctx)\n```\nAddLogger - adds logger\n\n```go\nfunc (j *DSGitHub) AddMetadata(ctx *shared.Ctx, item interface{}) (mItem map[string]interface{})\n```\nAddMetadata - add metadata to the item\n\n```go\nfunc (j *DSGitHub) AddPublisher(publisher Publisher)\n```\nAddPublisher - sets Kinesis publisher\n\n```go\nfunc (j *DSGitHub) Endpoint() string\n```\nEndpoint - return unique endpoint string representation\n\n```go\nfunc (j *DSGitHub) EnrichIssueAssignees(ctx *shared.Ctx, issue map[string]interface{}, assignees []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichIssueAssignees - return rich assignees from raw issue\n\n```go\nfunc (j *DSGitHub) EnrichIssueComments(ctx *shared.Ctx, issue map[string]interface{}, comments []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichIssueComments - return rich comments from raw issue\n\n```go\nfunc (j *DSGitHub) EnrichIssueItem(ctx *shared.Ctx, item map[string]interface{}) (rich map[string]interface{}, err error)\n```\nEnrichIssueItem - return rich item from raw item for a given author type\n\n```go\nfunc (j *DSGitHub) EnrichIssuePullRequestComments(ctx *shared.Ctx, pull map[string]interface{}, comments []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichIssuePullRequestComments - return rich comments from raw pull request (issue part)\n\n```go\nfunc (j *DSGitHub) EnrichIssueReactions(ctx *shared.Ctx, issue map[string]interface{}, reactions []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichIssueReactions - return rich reactions from raw issue and/or issue comment\n\n```go\nfunc (j *DSGitHub) EnrichItem(ctx *shared.Ctx, item map[string]interface{}) (rich map[string]interface{}, err error)\n```\nEnrichItem - return rich item from raw item for a given author type\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestAssignees(ctx *shared.Ctx, pull map[string]interface{}, assignees []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichPullRequestAssignees - return rich assignees from raw pull request\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestComments(ctx *shared.Ctx, pull map[string]interface{}, comments []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichPullRequestComments - return rich comments from raw pull request\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestCommits(ctx *shared.Ctx, pull map[string]interface{}, commits []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichPullRequestCommits - return rich commits from raw pull request\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestItem(ctx *shared.Ctx, item map[string]interface{}) (rich map[string]interface{}, err error)\n```\nEnrichPullRequestItem - return rich item from raw item for a given author type\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestReactions(ctx *shared.Ctx, pull map[string]interface{}, reactions []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichPullRequestReactions - return rich reactions from raw pull request comment\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestRequestedReviewers(ctx *shared.Ctx, pull map[string]interface{}, requestedReviewers []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichPullRequestRequestedReviewers - return rich requested reviewers from raw pull request\n\n```go\nfunc (j *DSGitHub) EnrichPullRequestReviews(ctx *shared.Ctx, pull map[string]interface{}, reviews []map[string]interface{}) (richItems []interface{}, err error)\n```\nEnrichPullRequestReviews - return rich reviews from raw pull request\n\n```go\nfunc (j *DSGitHub) EnrichRepositoryItem(ctx *shared.Ctx, item map[string]interface{}) (rich map[string]interface{}, err error)\n```\nEnrichRepositoryItem - return rich item from raw item for a given author type\n\n```go\nfunc (j *DSGitHub) FetchItemsIssue(ctx *shared.Ctx) (err error)\n```\nFetchItemsIssue - implement raw issue data for GitHub datasource\n\n```go\nfunc (j *DSGitHub) FetchItemsPullRequest(ctx *shared.Ctx) (err error)\n```\nFetchItemsPullRequest - implement raw issue data for GitHub datasource\n\n```go\nfunc (j *DSGitHub) FetchItemsRepository(ctx *shared.Ctx) (err error)\n```\nFetchItemsRepository - implement raw repository data for GitHub datasource\n\n```go\nfunc (j *DSGitHub) GetFirstIssueAttention(issue map[string]interface{}) (dt time.Time)\n```\nGetFirstIssueAttention - get first non-author action date on the issue\n\n```go\nfunc (j *DSGitHub) GetFirstPullRequestReviewDate(pull map[string]interface{}, commsAndReviews bool) (dt time.Time)\n```\nGetFirstPullRequestReviewDate - get first review date on a pull request\n\n```go\nfunc (j *DSGitHub) GetModelDataIssue(ctx *shared.Ctx, docs []interface{}) (data map[string][]interface{}, err error)\n```\nGetModelDataIssue - return issues data in lfx-event-schema format\n\n```go\nfunc (j *DSGitHub) GetModelDataPullRequest(ctx *shared.Ctx, docs []interface{}) (data map[string][]interface{}, err error)\n```\nGetModelDataPullRequest - return pull requests data in lfx-event-schema format\n\n```go\nfunc (j *DSGitHub) GetModelDataRepository(ctx *shared.Ctx, docs []interface{}) (data []repository.RepositoryUpdatedEvent, err error)\n```\nGetModelDataRepository - return repository data in lfx-event-schema format\n\n```go\nfunc (j *DSGitHub) GetRoleIdentity(ctx *shared.Ctx, item map[string]interface{}, role string) (identity map[string]interface{})\n```\nGetRoleIdentity - return identity data for a given role\n\n```go\nfunc (j *DSGitHub) GetRoles(ctx *shared.Ctx, item map[string]interface{}, roles []string, dt time.Time) (identities []map[string]interface{})\n```\nGetRoles - return identities for given roles\n\n```go\nfunc (j *DSGitHub) GitHubEnrichItems(ctx *shared.Ctx, items []interface{}, docs *[]interface{}, final bool) (err error)\n```\nGitHubEnrichItems - iterate items and enrich them items is a current pack of input items docs is a pointer to where extracted identities will be stored\n\n```go\nfunc (j *DSGitHub) GitHubIssueEnrichItemsFunc(ctx *shared.Ctx, items []interface{}, docs *[]interface{}, final bool) (err error)\n```\nGitHubIssueEnrichItemsFunc - iterate items and enrich them items is a current pack of input items docs is a pointer to where extracted identities will be stored\n\n```go\nfunc (j *DSGitHub) GitHubPullRequestEnrichItemsFunc(ctx *shared.Ctx, items []interface{}, docs *[]interface{}, final bool) (err error)\n```\nGitHubPullRequestEnrichItemsFunc - iterate items and enrich them items is a current pack of input items docs is a pointer to where extracted identities will be stored\n\n```go\nfunc (j *DSGitHub) GitHubRepositoryEnrichItemsFunc(ctx *shared.Ctx, items []interface{}, docs *[]interface{}, final bool) (err error)\n```\nGitHubRepositoryEnrichItemsFunc - iterate items and enrich them items is a current pack of input items docs is a pointer to where extracted identities will be stored\n\n```go\nfunc (j *DSGitHub) IdentityForObject(ctx *shared.Ctx, item map[string]interface{}) (identity [5]string)\n```\nIdentityForObject - construct identity from a given object\n\n```go\nfunc (j *DSGitHub) Init(ctx *shared.Ctx) (err error)\n```\nInit - initialize GitHub data source\n\n```go\nfunc (j *DSGitHub) ItemID(item interface{}) string\n```\nItemID - return unique identifier for an item\n\n```go\nfunc (j *DSGitHub) ItemNullableDate(item interface{}, field string) *time.Time\n```\nItemNullableDate - return date value for a given field name, can be null\n\n```go\nfunc (j *DSGitHub) ItemUpdatedOn(item interface{}) time.Time\n```\nItemUpdatedOn - return updated on date for an item\n\n```go\nfunc (j *DSGitHub) OutputDocs(ctx *shared.Ctx, items []interface{}, docs *[]interface{}, final bool)\n```\nOutputDocs - send output documents to the consumer\n\n```go\nfunc (j *DSGitHub) ParseArgs(ctx *shared.Ctx) (err error)\n```\nParseArgs - parse GitHub specific environment variables\n\n```go\nfunc (j *DSGitHub) ProcessIssue(ctx *shared.Ctx, inIssue map[string]interface{}) (issue map[string]interface{}, err error)\n```\nProcessIssue - add issues sub items\n\n```go\nfunc (j *DSGitHub) ProcessPull(ctx *shared.Ctx, inPull map[string]interface{}) (pull map[string]interface{}, err error)\n```\nProcessPull - add PRs sub items\n\n```go\nfunc (j *DSGitHub) PublisherPushEvents(ev, ori, src, cat, env string, v []interface{}) error\n```\nPublisherPushEvents - this is a fake function to test publisher locally FIXME: don't use when done implementing\n\n```go\nfunc (j *DSGitHub) Sync(ctx *shared.Ctx, category string) (err error)\n```\nSync - sync GitHub data source\n\n```go\nfunc (j *DSGitHub) SyncCurrentCategory(ctx *shared.Ctx) (err error)\n```\nSyncCurrentCategory - sync GitHub data source for current category\n\n```go\nfunc (j *DSGitHub) Validate(ctx *shared.Ctx) (err error)\n```\nValidate - is current DS configuration OK?\n\n```go\nfunc (j *DSGitHub) WriteLog(ctx *shared.Ctx, timestamp time.Time, status, message string) error\n```\nWriteLog - writes to log\n\n```go\ntype ItemCache struct {\n\tTimestamp      string `json:\"timestamp\"`\n\tEntityID       string `json:\"entity_id\"`\n\tSourceEntityID string `json:\"source_entity_id\"`\n\tFileLocation   string `json:\"file_location\"`\n\tHash           string `json:\"hash\"`\n\tOrphaned       bool   `json:\"orphaned\"`\n}\n```\nItemCache ...\n\n```go\ntype Publisher interface {\n\tPushEvents(action, source, eventType, subEventType, env string, data []interface{}, endpoint string) (string, error)\n}\n```\nPublisher - for streaming data to Kinesis\n\n","path":"github.com/LF-Engineering/insights-connector-github/cmd/github","name":"main","synopsis":"","isRedistributable":true}
