{"modulePath":"github.com/cruxstack/github-ops-app","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package webhooks\n\nPackage webhooks validates GitHub webhook signatures and parses the pull\\_request, team, and membership events the application handles.\n\n## Constants\n\n```go\nconst (\n\tEventPing        = \"ping\"\n\tEventPullRequest = \"pull_request\"\n\tEventTeam        = \"team\"\n\tEventMembership  = \"membership\"\n)\n```\nEvent types the application handles.\n\n## Functions\n\n```go\nfunc Sign(payload []byte, secret string) string\n```\nSign returns the X-Hub-Signature-256 header value for a payload.\n\n```go\nfunc ValidateSignature(payload []byte, signature, secret string) error\n```\nValidateSignature verifies the X-Hub-Signature-256 HMAC of a payload. An empty secret is rejected, so a missing configuration never accepts unsigned requests.\n\n## Types\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\t// contains filtered or unexported fields\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) GetOrgLogin() string\n```\nGetOrgLogin returns the login of the organization the team belongs to.\n\n```go\nfunc (e MembershipEvent) GetSenderLogin() string\n```\nGetSenderLogin returns the login of the user who triggered the event.\n\n```go\nfunc (e MembershipEvent) GetSenderType() string\n```\nGetSenderType returns the type of the sender, such as User or Bot.\n\n```go\nfunc (e *MembershipEvent) GetTeamSlug() string\n```\nGetTeamSlug returns the team's slug.\n\n```go\nfunc (e *MembershipEvent) IsTeamScope() bool\n```\nIsTeamScope returns true if the membership event is for a team.\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\t// contains filtered or unexported fields\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.\n\n```go\nfunc (e *PullRequestEvent) GetBaseBranch() string\n```\nGetBaseBranch returns the target branch name.\n\n```go\nfunc (e *PullRequestEvent) GetNumber() int\n```\nGetNumber returns the PR number.\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) GetSenderLogin() string\n```\nGetSenderLogin returns the login of the user who triggered the event.\n\n```go\nfunc (e PullRequestEvent) GetSenderType() string\n```\nGetSenderType returns the type of the sender, such as User or Bot.\n\n```go\nfunc (e *PullRequestEvent) IsMerged() bool\n```\nIsMerged returns true if the PR was closed via merge.\n\n```go\ntype TeamChanges struct {\n\tName *struct {\n\t\tFrom string `json:\"from\"`\n\t} `json:\"name,omitempty\"`\n}\n```\nTeamChanges holds the previous values of an edited team's fields.\n\n```go\ntype TeamEvent struct {\n\tAction       string               `json:\"action\"`\n\tTeam         *github.Team         `json:\"team\"`\n\tChanges      *TeamChanges         `json:\"changes,omitempty\"`\n\tOrganization *github.Organization `json:\"organization\"`\n\t// contains filtered or unexported fields\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) AffectsMembership() bool\n```\nAffectsMembership returns true if the change can affect which team the sync maps a group to: a team was created, deleted, or renamed. Changes to a team's description, privacy, or repository access cannot.\n\n```go\nfunc (e *TeamEvent) GetOrgLogin() string\n```\nGetOrgLogin returns the login of the organization the team belongs to.\n\n```go\nfunc (e *TeamEvent) GetPreviousTeamSlug() string\n```\nGetPreviousTeamSlug returns the slug the team had before it was renamed, or \"\".\n\n```go\nfunc (e TeamEvent) GetSenderLogin() string\n```\nGetSenderLogin returns the login of the user who triggered the event.\n\n```go\nfunc (e TeamEvent) GetSenderType() string\n```\nGetSenderType returns the type of the sender, such as User or Bot.\n\n```go\nfunc (e *TeamEvent) GetTeamSlug() string\n```\nGetTeamSlug returns the team's slug.\n\n","path":"github.com/cruxstack/github-ops-app/internal/github/webhooks","name":"webhooks","synopsis":"Package webhooks validates GitHub webhook signatures and parses the pull_request, team, and membership events the application handles.","isRedistributable":true}
