gitea

package
v0.0.0-...-043f5fd Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventNotSpecifiedToParse    = errors.New("no Event specified to parse")
	ErrInvalidHTTPMethod           = errors.New("invalid HTTP Method")
	ErrMissingGiteaEventHeader     = errors.New("missing X-Gitea-Event Header")
	ErrMissingGiteaSignatureHeader = errors.New("missing X-Gitea-Signature Header")
	ErrEventNotFound               = errors.New("event not defined to be parsed")
	ErrParsingPayload              = errors.New("error parsing payload")
	ErrHMACVerificationFailed      = errors.New("HMAC verification failed")
)

parse errors

View Source
var Options = WebhookOptions{}

Options is a namespace var for configuration options

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID            int64     `json:"id"`
	Name          string    `json:"name"`
	Size          int64     `json:"size"`
	DownloadCount int64     `json:"download_count"`
	Created       time.Time `json:"created_at"`
	UUID          string    `json:"uuid"`
	DownloadURL   string    `json:"browser_download_url"`
}

Attachment a generic attachment

type ChangesFromPayload

type ChangesFromPayload struct {
	From string `json:"from"`
}

ChangesFromPayload FIXME

type ChangesPayload

type ChangesPayload struct {
	Title *ChangesFromPayload `json:"title,omitempty"`
	Body  *ChangesFromPayload `json:"body,omitempty"`
	Ref   *ChangesFromPayload `json:"ref,omitempty"`
}

ChangesPayload represents the payload information of issue change

type Comment

type Comment struct {
	ID               int64     `json:"id"`
	HTMLURL          string    `json:"html_url"`
	PRURL            string    `json:"pull_request_url"`
	IssueURL         string    `json:"issue_url"`
	Poster           *User     `json:"user"`
	OriginalAuthor   string    `json:"original_author"`
	OriginalAuthorID int64     `json:"original_author_id"`
	Body             string    `json:"body"`
	Created          time.Time `json:"created_at"`
	Updated          time.Time `json:"updated_at"`
}

Comment represents a comment on a commit or issue

type CreatePayload

type CreatePayload struct {
	Sha     string      `json:"sha"`
	Ref     string      `json:"ref"`
	RefType string      `json:"ref_type"`
	Repo    *Repository `json:"repository"`
	Sender  *User       `json:"sender"`
}

CreatePayload represents a payload create reposoitory

type DeletePayload

type DeletePayload struct {
	Ref        string      `json:"ref"`
	RefType    string      `json:"ref_type"`
	PusherType PusherType  `json:"pusher_type"`
	Repo       *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

DeletePayload represents delete payload

type Event

type Event string

Event defines a GitLab hook event type by the X-Gitlab-Event Header

const (
	CreateEvent               Event = "create"
	DeleteEvent               Event = "delete"
	ForkEvent                 Event = "fork"
	IssuesEvent               Event = "issues"
	IssueAssignEvent          Event = "issue_assign"
	IssueLabelEvent           Event = "issue_label"
	IssueMilestoneEvent       Event = "issue_milestone"
	IssueCommentEvent         Event = "issue_comment"
	PushEvent                 Event = "push"
	PullRequestEvent          Event = "pull_request"
	PullRequestAssignEvent    Event = "pull_request_assign"
	PullRequestLabelEvent     Event = "pull_request_label"
	PullRequestMilestoneEvent Event = "pull_request_milestone"
	PullRequestCommentEvent   Event = "pull_request_comment"
	PullRequestReviewEvent    Event = "pull_request_review"
	PullRequestSyncEvent      Event = "pull_request_sync"
	RepositoryEvent           Event = "repository"
	ReleaseEvent              Event = "release"
)

Gitea hook types https://github.com/go-gitea/gitea/blob/bf7b083cfe47cc922090ce7922b89f7a5030a44d/models/webhook/hooktask.go#L31

type ExternalTracker

type ExternalTracker struct {
	ExternalTrackerURL    string `json:"external_tracker_url"`
	ExternalTrackerFormat string `json:"external_tracker_format"`
	ExternalTrackerStyle  string `json:"external_tracker_style"`
}

ExternalTracker represents settings for external tracker

type ExternalWiki

type ExternalWiki struct {
	ExternalWikiURL string `json:"external_wiki_url"`
}

ExternalWiki represents setting for external wiki

type ForkPayload

type ForkPayload struct {
	Forkee *Repository `json:"forkee"`
	Repo   *Repository `json:"repository"`
	Sender *User       `json:"sender"`
}

ForkPayload represents fork payload

type HookIssueAction

type HookIssueAction string

HookIssueAction FIXME

type HookIssueCommentAction

type HookIssueCommentAction string

HookIssueCommentAction defines hook issue comment action

type HookReleaseAction

type HookReleaseAction string

HookReleaseAction defines hook release action type

type HookRepoAction

type HookRepoAction string

HookRepoAction an action that happens to a repo

type InternalTracker

type InternalTracker struct {
	EnableTimeTracker                bool `json:"enable_time_tracker"`
	AllowOnlyContributorsToTrackTime bool `json:"allow_only_contributors_to_track_time"`
	EnableIssueDependencies          bool `json:"enable_issue_dependencies"`
}

InternalTracker represents settings for internal tracker

type Issue

type Issue struct {
	ID               int64            `json:"id"`
	URL              string           `json:"url"`
	HTMLURL          string           `json:"html_url"`
	Index            int64            `json:"number"`
	Poster           *User            `json:"user"`
	OriginalAuthor   string           `json:"original_author"`
	OriginalAuthorID int64            `json:"original_author_id"`
	Title            string           `json:"title"`
	Body             string           `json:"body"`
	Ref              string           `json:"ref"`
	Labels           []*Label         `json:"labels"`
	Milestone        *Milestone       `json:"milestone"`
	Assignee         *User            `json:"assignee"`
	Assignees        []*User          `json:"assignees"`
	State            StateType        `json:"state"`
	IsLocked         bool             `json:"is_locked"`
	Comments         int              `json:"comments"`
	Created          time.Time        `json:"created_at"`
	Updated          time.Time        `json:"updated_at"`
	Closed           *time.Time       `json:"closed_at"`
	Deadline         *time.Time       `json:"due_date"`
	PullRequest      *PullRequestMeta `json:"pull_request"`
	Repo             *RepositoryMeta  `json:"repository"`
}

Issue represents an issue in a repository

type IssueCommentPayload

type IssueCommentPayload struct {
	Action     HookIssueCommentAction `json:"action"`
	Issue      *Issue                 `json:"issue"`
	Comment    *Comment               `json:"comment"`
	Changes    *ChangesPayload        `json:"changes,omitempty"`
	Repository *Repository            `json:"repository"`
	Sender     *User                  `json:"sender"`
	IsPull     bool                   `json:"is_pull"`
}

IssueCommentPayload represents a payload information of issue comment event.

type IssuePayload

type IssuePayload struct {
	Action     HookIssueAction `json:"action"`
	Index      int64           `json:"number"`
	Changes    *ChangesPayload `json:"changes,omitempty"`
	Issue      *Issue          `json:"issue"`
	Repository *Repository     `json:"repository"`
	Sender     *User           `json:"sender"`
}

IssuePayload represents the payload information that is sent along with an issue event.

type Label

type Label struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description"`
	URL         string `json:"url"`
}

Label a label to an issue or a pr

type Milestone

type Milestone struct {
	ID           int64      `json:"id"`
	Title        string     `json:"title"`
	Description  string     `json:"description"`
	State        StateType  `json:"state"`
	OpenIssues   int        `json:"open_issues"`
	ClosedIssues int        `json:"closed_issues"`
	Created      time.Time  `json:"created_at"`
	Updated      *time.Time `json:"updated_at"`
	Closed       *time.Time `json:"closed_at"`
	Deadline     *time.Time `json:"due_on"`
}

Milestone milestone is a collection of issues on one repository

type Option

type Option func(*Webhook) error

Option is a configuration option for the webhook

type PRBranchInfo

type PRBranchInfo struct {
	Name       string      `json:"label"`
	Ref        string      `json:"ref"`
	Sha        string      `json:"sha"`
	RepoID     int64       `json:"repo_id"`
	Repository *Repository `json:"repo"`
}

PRBranchInfo information about a branch

type PayloadCommit

type PayloadCommit struct {
	// sha1 hash of the commit
	ID           string                     `json:"id"`
	Message      string                     `json:"message"`
	URL          string                     `json:"url"`
	Author       *PayloadUser               `json:"author"`
	Committer    *PayloadUser               `json:"committer"`
	Verification *PayloadCommitVerification `json:"verification"`
	// swagger:strfmt date-time
	Timestamp time.Time `json:"timestamp"`
	Added     []string  `json:"added"`
	Removed   []string  `json:"removed"`
	Modified  []string  `json:"modified"`
}

PayloadCommit represents a commit

type PayloadCommitVerification

type PayloadCommitVerification struct {
	Verified  bool         `json:"verified"`
	Reason    string       `json:"reason"`
	Signature string       `json:"signature"`
	Signer    *PayloadUser `json:"signer"`
	Payload   string       `json:"payload"`
}

PayloadCommitVerification represents the GPG verification of a commit

type PayloadUser

type PayloadUser struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	UserName string `json:"username"`
}

PayloadUser represents the author or committer of a commit

type Permission

type Permission struct {
	Admin bool `json:"admin"`
	Push  bool `json:"push"`
	Pull  bool `json:"pull"`
}

Permission represents a set of permissions

type PullRequest

type PullRequest struct {
	ID             int64         `json:"id"`
	URL            string        `json:"url"`
	Index          int64         `json:"number"`
	Poster         *User         `json:"user"`
	Title          string        `json:"title"`
	Body           string        `json:"body"`
	Labels         []*Label      `json:"labels"`
	Milestone      *Milestone    `json:"milestone"`
	Assignee       *User         `json:"assignee"`
	Assignees      []*User       `json:"assignees"`
	State          StateType     `json:"state"`
	IsLocked       bool          `json:"is_locked"`
	Comments       int           `json:"comments"`
	HTMLURL        string        `json:"html_url"`
	DiffURL        string        `json:"diff_url"`
	PatchURL       string        `json:"patch_url"`
	Mergeable      bool          `json:"mergeable"`
	HasMerged      bool          `json:"merged"`
	Merged         *time.Time    `json:"merged_at"`
	MergedCommitID *string       `json:"merge_commit_sha"`
	MergedBy       *User         `json:"merged_by"`
	Base           *PRBranchInfo `json:"base"`
	Head           *PRBranchInfo `json:"head"`
	MergeBase      string        `json:"merge_base"`
	Deadline       *time.Time    `json:"due_date"`
	Created        *time.Time    `json:"created_at"`
	Updated        *time.Time    `json:"updated_at"`
	Closed         *time.Time    `json:"closed_at"`
}

PullRequest represents a pull request

type PullRequestMeta

type PullRequestMeta struct {
	HasMerged bool       `json:"merged"`
	Merged    *time.Time `json:"merged_at"`
}

PullRequestMeta PR info if an issue is a PR

type PullRequestPayload

type PullRequestPayload struct {
	Action      HookIssueAction `json:"action"`
	Index       int64           `json:"number"`
	Changes     *ChangesPayload `json:"changes,omitempty"`
	PullRequest *PullRequest    `json:"pull_request"`
	Repository  *Repository     `json:"repository"`
	Sender      *User           `json:"sender"`
	Review      *ReviewPayload  `json:"review"`
}

PullRequestPayload represents a payload information of pull request event.

type PushPayload

type PushPayload struct {
	Ref        string           `json:"ref"`
	Before     string           `json:"before"`
	After      string           `json:"after"`
	CompareURL string           `json:"compare_url"`
	Commits    []*PayloadCommit `json:"commits"`
	HeadCommit *PayloadCommit   `json:"head_commit"`
	Repo       *Repository      `json:"repository"`
	Pusher     *User            `json:"pusher"`
	Sender     *User            `json:"sender"`
}

PushPayload represents a payload information of push event.

type PusherType

type PusherType string

PusherType define the type to push

type Release

type Release struct {
	ID           int64         `json:"id"`
	TagName      string        `json:"tag_name"`
	Target       string        `json:"target_commitish"`
	Title        string        `json:"name"`
	Note         string        `json:"body"`
	URL          string        `json:"url"`
	HTMLURL      string        `json:"html_url"`
	TarURL       string        `json:"tarball_url"`
	ZipURL       string        `json:"zipball_url"`
	IsDraft      bool          `json:"draft"`
	IsPrerelease bool          `json:"prerelease"`
	CreatedAt    time.Time     `json:"created_at"`
	PublishedAt  time.Time     `json:"published_at"`
	Publisher    *User         `json:"author"`
	Attachments  []*Attachment `json:"assets"`
}

Release represents a repository release

type ReleasePayload

type ReleasePayload struct {
	Action     HookReleaseAction `json:"action"`
	Release    *Release          `json:"release"`
	Repository *Repository       `json:"repository"`
	Sender     *User             `json:"sender"`
}

ReleasePayload represents a payload information of release event.

type Repository

type Repository struct {
	ID                        int64            `json:"id"`
	Owner                     *User            `json:"owner"`
	Name                      string           `json:"name"`
	FullName                  string           `json:"full_name"`
	Description               string           `json:"description"`
	Empty                     bool             `json:"empty"`
	Private                   bool             `json:"private"`
	Fork                      bool             `json:"fork"`
	Template                  bool             `json:"template"`
	Parent                    *Repository      `json:"parent"`
	Mirror                    bool             `json:"mirror"`
	Size                      int              `json:"size"`
	HTMLURL                   string           `json:"html_url"`
	SSHURL                    string           `json:"ssh_url"`
	CloneURL                  string           `json:"clone_url"`
	OriginalURL               string           `json:"original_url"`
	Website                   string           `json:"website"`
	Stars                     int              `json:"stars_count"`
	Forks                     int              `json:"forks_count"`
	Watchers                  int              `json:"watchers_count"`
	OpenIssues                int              `json:"open_issues_count"`
	OpenPulls                 int              `json:"open_pr_counter"`
	Releases                  int              `json:"release_counter"`
	DefaultBranch             string           `json:"default_branch"`
	Archived                  bool             `json:"archived"`
	Created                   time.Time        `json:"created_at"`
	Updated                   time.Time        `json:"updated_at"`
	Permissions               *Permission      `json:"permissions,omitempty"`
	HasIssues                 bool             `json:"has_issues"`
	InternalTracker           *InternalTracker `json:"internal_tracker,omitempty"`
	ExternalTracker           *ExternalTracker `json:"external_tracker,omitempty"`
	HasWiki                   bool             `json:"has_wiki"`
	ExternalWiki              *ExternalWiki    `json:"external_wiki,omitempty"`
	HasPullRequests           bool             `json:"has_pull_requests"`
	HasProjects               bool             `json:"has_projects"`
	IgnoreWhitespaceConflicts bool             `json:"ignore_whitespace_conflicts"`
	AllowMerge                bool             `json:"allow_merge_commits"`
	AllowRebase               bool             `json:"allow_rebase"`
	AllowRebaseMerge          bool             `json:"allow_rebase_explicit"`
	AllowSquash               bool             `json:"allow_squash_merge"`
	DefaultMergeStyle         string           `json:"default_merge_style"`
	AvatarURL                 string           `json:"avatar_url"`
	Internal                  bool             `json:"internal"`
	MirrorInterval            string           `json:"mirror_interval"`
}

Repository represents a repository

type RepositoryMeta

type RepositoryMeta struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	Owner    string `json:"owner"`
	FullName string `json:"full_name"`
}

RepositoryMeta basic repository information

type RepositoryPayload

type RepositoryPayload struct {
	Action       HookRepoAction `json:"action"`
	Repository   *Repository    `json:"repository"`
	Organization *User          `json:"organization"`
	Sender       *User          `json:"sender"`
}

RepositoryPayload payload for repository webhooks

type ReviewPayload

type ReviewPayload struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

ReviewPayload FIXME

type StateType

type StateType string

StateType issue state type

type User

type User struct {
	ID            int64     `json:"id"`
	UserName      string    `json:"login"`
	FullName      string    `json:"full_name"`
	Email         string    `json:"email"`
	AvatarURL     string    `json:"avatar_url"`
	Language      string    `json:"language"`
	IsAdmin       bool      `json:"is_admin"`
	LastLogin     time.Time `json:"last_login,omitempty"`
	Created       time.Time `json:"created,omitempty"`
	Restricted    bool      `json:"restricted"`
	IsActive      bool      `json:"active"`
	ProhibitLogin bool      `json:"prohibit_login"`
	Location      string    `json:"location"`
	Website       string    `json:"website"`
	Description   string    `json:"description"`
	Visibility    string    `json:"visibility"`
	Followers     int       `json:"followers_count"`
	Following     int       `json:"following_count"`
	StarredRepos  int       `json:"starred_repos_count"`
}

User represents a user

type Webhook

type Webhook struct {
	// contains filtered or unexported fields
}

Webhook instance contains all methods needed to process events

func New

func New(options ...Option) (*Webhook, error)

New creates and returns a WebHook instance denoted by the Provider type

func (Webhook) Parse

func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)

Parse verifies and parses the events specified and returns the payload object or an error

type WebhookOptions

type WebhookOptions struct{}

WebhookOptions is a namespace for configuration option methods

func (WebhookOptions) Secret

func (WebhookOptions) Secret(secret string) Option

Secret registers the GitLab secret

Jump to

Keyboard shortcuts

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