{"modulePath":"github.com/cruxstack/github-ops-app","version":"v0.2.0","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\nPackage github provides GitHub API client with App authentication. handles JWT generation, installation token management, and automatic token refresh.\n\nPackage github provides PR compliance checking against branch protection rules.\n\nPackage github provides GitHub team management and membership sync.\n\nPackage github provides webhook event parsing and signature validation.\n\n## Functions\n\n```go\nfunc ValidateWebhookSignature(payload []byte, signature string, secret string) error\n```\nValidateWebhookSignature verifies HMAC-SHA256 webhook signature. returns error if signature is invalid or missing when required.\n\n## Types\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient wraps the GitHub API client with App authentication. automatically refreshes installation tokens before expiry.\n\n```go\nfunc NewAppClient(appID, installationID int64, privateKeyPEM []byte, org string) (*Client, error)\n```\nNewAppClient creates a GitHub App client with default base URL.\n\n```go\nfunc NewAppClientWithBaseURL(appID, installationID int64, privateKeyPEM []byte, org, baseURL string) (*Client, error)\n```\nNewAppClientWithBaseURL creates a GitHub App client with custom base URL. supports GitHub Enterprise Server instances.\n\n```go\nfunc (c *Client) CheckPRCompliance(ctx context.Context, owner, repo string, prNumber int) (*PRComplianceResult, error)\n```\nCheckPRCompliance verifies if a merged PR met branch protection requirements. checks review requirements, status checks, and user bypass permissions.\n\n```go\nfunc (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)\n```\nDo executes an HTTP request with authentication. ensures token is valid before executing request.\n\n```go\nfunc (c *Client) GetAppSlug(ctx context.Context) (string, error)\n```\nGetAppSlug fetches the GitHub App slug identifier. used to detect changes made by the app itself.\n\n```go\nfunc (c *Client) GetClient() *github.Client\n```\nGetClient returns the underlying go-github client.\n\n```go\nfunc (c *Client) GetOrCreateTeam(ctx context.Context, teamName, privacy string) (*github.Team, error)\n```\nGetOrCreateTeam fetches an existing team by slug or creates it if missing.\n\n```go\nfunc (c *Client) GetOrg() string\n```\nGetOrg returns the GitHub organization name.\n\n```go\nfunc (c *Client) GetTeamMembers(ctx context.Context, teamSlug string) ([]string, error)\n```\nGetTeamMembers returns GitHub usernames of all team members.\n\n```go\nfunc (c *Client) IsExternalCollaborator(ctx context.Context, username string) (bool, error)\n```\nIsExternalCollaborator checks if a user is an outside collaborator rather than an organization member. returns true if user is not a full org member.\n\n```go\nfunc (c *Client) ListOrgMembers(ctx context.Context) ([]string, error)\n```\nListOrgMembers returns all organization members excluding external collaborators.\n\n```go\nfunc (c *Client) SyncTeamMembers(ctx context.Context, teamSlug string, desiredMembers []string, safetyThreshold float64) (*TeamSyncResult, error)\n```\nSyncTeamMembers adds and removes members to match desired state. collects errors for individual operations but continues processing. skips removal of external collaborators (outside org members). applies safety threshold to prevent mass removal during outages.\n\n```go\ntype ComplianceViolation struct {\n\tType        string\n\tDescription string\n}\n```\nComplianceViolation represents a single branch protection rule violation.\n\n```go\ntype MembershipEvent struct {\n\tAction       string               `json:\"action\"`\n\tScope        string               `json:\"scope\"`\n\tMember       *github.User         `json:\"member\"`\n\tTeam         *github.Team         `json:\"team\"`\n\tOrganization *github.Organization `json:\"organization\"`\n\tSender       *github.User         `json:\"sender\"`\n\tInstallation *github.Installation `json:\"installation\"`\n}\n```\nMembershipEvent represents a GitHub membership webhook payload.\n\n```go\nfunc ParseMembershipEvent(payload []byte) (*MembershipEvent, error)\n```\nParseMembershipEvent unmarshals and validates a membership webhook.\n\n```go\nfunc (e *MembershipEvent) GetInstallationID() int64\n```\nGetInstallationID returns the GitHub App installation ID.\n\n```go\nfunc (e *MembershipEvent) GetSenderLogin() string\n```\nGetSenderLogin returns the username of the user who triggered the event.\n\n```go\nfunc (e *MembershipEvent) GetSenderType() string\n```\nGetSenderType returns the sender's type (User or Bot).\n\n```go\nfunc (e *MembershipEvent) GetTeamSlug() string\n```\nGetTeamSlug returns the team's URL-friendly identifier.\n\n```go\nfunc (e *MembershipEvent) IsTeamScope() bool\n```\nIsTeamScope returns true if the membership event is for a team.\n\n```go\ntype PRComplianceResult struct {\n\tPR               *github.PullRequest\n\tBaseBranch       string\n\tProtection       *github.Protection\n\tViolations       []ComplianceViolation\n\tUserHasBypass    bool\n\tUserBypassReason string\n}\n```\nPRComplianceResult contains PR compliance check results including violations and user bypass permissions.\n\n```go\nfunc (r *PRComplianceResult) HasViolations() bool\n```\nHasViolations returns true if any compliance violations were detected.\n\n```go\nfunc (r *PRComplianceResult) WasBypassed() bool\n```\nWasBypassed returns true if violations exist and user had bypass permission.\n\n```go\ntype PullRequestEvent struct {\n\tAction       string               `json:\"action\"`\n\tNumber       int                  `json:\"number\"`\n\tPullRequest  *github.PullRequest  `json:\"pull_request\"`\n\tRepository   *github.Repository   `json:\"repository\"`\n\tSender       *github.User         `json:\"sender\"`\n\tInstallation *github.Installation `json:\"installation\"`\n}\n```\nPullRequestEvent represents a GitHub pull\\_request webhook payload.\n\n```go\nfunc ParsePullRequestEvent(payload []byte) (*PullRequestEvent, error)\n```\nParsePullRequestEvent unmarshals and validates a pull\\_request webhook. returns error if required fields are missing.\n\n```go\nfunc (e *PullRequestEvent) GetBaseBranch() string\n```\nGetBaseBranch returns the target branch name.\n\n```go\nfunc (e *PullRequestEvent) GetInstallationID() int64\n```\nGetInstallationID returns the GitHub App installation ID.\n\n```go\nfunc (e *PullRequestEvent) GetRepoFullName() string\n```\nGetRepoFullName returns the repository in owner/name format.\n\n```go\nfunc (e *PullRequestEvent) GetRepoName() string\n```\nGetRepoName returns the repository name without owner.\n\n```go\nfunc (e *PullRequestEvent) GetRepoOwner() string\n```\nGetRepoOwner returns the repository owner login.\n\n```go\nfunc (e *PullRequestEvent) IsMerged() bool\n```\nIsMerged returns true if the PR was closed via merge.\n\n```go\ntype TeamChangeDetail struct {\n\tFrom string `json:\"from\"`\n}\n```\nTeamChangeDetail contains the previous value before a change.\n\n```go\ntype TeamChanges struct {\n\tName        *TeamChangeDetail `json:\"name,omitempty\"`\n\tDescription *TeamChangeDetail `json:\"description,omitempty\"`\n\tPrivacy     *TeamChangeDetail `json:\"privacy,omitempty\"`\n\tRepository  *TeamChangeDetail `json:\"repository,omitempty\"`\n}\n```\nTeamChanges contains details about what changed in a team event.\n\n```go\ntype TeamEvent struct {\n\tAction       string               `json:\"action\"`\n\tTeam         *github.Team         `json:\"team\"`\n\tChanges      *TeamChanges         `json:\"changes,omitempty\"`\n\tRepository   *github.Repository   `json:\"repository,omitempty\"`\n\tOrganization *github.Organization `json:\"organization\"`\n\tSender       *github.User         `json:\"sender\"`\n\tInstallation *github.Installation `json:\"installation\"`\n}\n```\nTeamEvent represents a GitHub team webhook payload.\n\n```go\nfunc ParseTeamEvent(payload []byte) (*TeamEvent, error)\n```\nParseTeamEvent unmarshals and validates a team webhook.\n\n```go\nfunc (e *TeamEvent) GetInstallationID() int64\n```\nGetInstallationID returns the GitHub App installation ID.\n\n```go\nfunc (e *TeamEvent) GetSenderLogin() string\n```\nGetSenderLogin returns the username of the user who triggered the event.\n\n```go\nfunc (e *TeamEvent) GetSenderType() string\n```\nGetSenderType returns the sender's type (User or Bot).\n\n```go\nfunc (e *TeamEvent) GetTeamSlug() string\n```\nGetTeamSlug returns the team's URL-friendly identifier.\n\n```go\ntype TeamSyncResult struct {\n\tTeamName               string\n\tMembersAdded           []string\n\tMembersRemoved         []string\n\tMembersSkippedExternal []string\n\tErrors                 []string\n}\n```\nTeamSyncResult contains the results of syncing team membership.\n\n","path":"github.com/cruxstack/github-ops-app/internal/github","name":"github","synopsis":"Package github provides GitHub API client with App authentication.","isRedistributable":true}
