Upgrade golang to 1.25.1 and add descriptions for the swagger structs' fields (#35418)

This commit is contained in:
Lunny Xiao
2025-09-06 09:52:41 -07:00
committed by GitHub
parent b8f1c9f048
commit c290682521
51 changed files with 1928 additions and 656 deletions

View File

@@ -17,17 +17,27 @@ var ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webho
// Hook a hook is a web hook when one repository changed
type Hook struct {
ID int64 `json:"id"`
Type string `json:"type"`
BranchFilter string `json:"branch_filter"`
URL string `json:"-"`
Config map[string]string `json:"config"`
Events []string `json:"events"`
AuthorizationHeader string `json:"authorization_header"`
Active bool `json:"active"`
// The unique identifier of the webhook
ID int64 `json:"id"`
// The type of the webhook (e.g., gitea, slack, discord)
Type string `json:"type"`
// Branch filter pattern to determine which branches trigger the webhook
BranchFilter string `json:"branch_filter"`
// The URL of the webhook endpoint (hidden in JSON)
URL string `json:"-"`
// Configuration settings for the webhook
Config map[string]string `json:"config"`
// List of events that trigger this webhook
Events []string `json:"events"`
// Authorization header to include in webhook requests
AuthorizationHeader string `json:"authorization_header"`
// Whether the webhook is active and will be triggered
Active bool `json:"active"`
// swagger:strfmt date-time
// The date and time when the webhook was last updated
Updated time.Time `json:"updated_at"`
// swagger:strfmt date-time
// The date and time when the webhook was created
Created time.Time `json:"created_at"`
}
@@ -42,23 +52,34 @@ type CreateHookOptionConfig map[string]string
type CreateHookOption struct {
// required: true
// enum: dingtalk,discord,gitea,gogs,msteams,slack,telegram,feishu,wechatwork,packagist
// The type of the webhook to create
Type string `json:"type" binding:"Required"`
// required: true
Config CreateHookOptionConfig `json:"config" binding:"Required"`
Events []string `json:"events"`
BranchFilter string `json:"branch_filter" binding:"GlobPattern"`
AuthorizationHeader string `json:"authorization_header"`
// Configuration settings for the webhook
Config CreateHookOptionConfig `json:"config" binding:"Required"`
// List of events that will trigger this webhook
Events []string `json:"events"`
// Branch filter pattern to determine which branches trigger the webhook
BranchFilter string `json:"branch_filter" binding:"GlobPattern"`
// Authorization header to include in webhook requests
AuthorizationHeader string `json:"authorization_header"`
// default: false
// Whether the webhook should be active upon creation
Active bool `json:"active"`
}
// EditHookOption options when modify one hook
type EditHookOption struct {
Config map[string]string `json:"config"`
Events []string `json:"events"`
BranchFilter string `json:"branch_filter" binding:"GlobPattern"`
AuthorizationHeader string `json:"authorization_header"`
Active *bool `json:"active"`
// Configuration settings for the webhook
Config map[string]string `json:"config"`
// List of events that trigger this webhook
Events []string `json:"events"`
// Branch filter pattern to determine which branches trigger the webhook
BranchFilter string `json:"branch_filter" binding:"GlobPattern"`
// Authorization header to include in webhook requests
AuthorizationHeader string `json:"authorization_header"`
// Whether the webhook is active and will be triggered
Active *bool `json:"active"`
}
// Payloader payload is some part of one hook
@@ -82,26 +103,40 @@ type PayloadUser struct {
// PayloadCommit represents a commit
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"`
ID string `json:"id"`
// The commit message
Message string `json:"message"`
// The URL to view this commit
URL string `json:"url"`
// The author of the commit
Author *PayloadUser `json:"author"`
// The committer of the commit
Committer *PayloadUser `json:"committer"`
// GPG verification information for the commit
Verification *PayloadCommitVerification `json:"verification"`
// swagger:strfmt date-time
// The timestamp when the commit was made
Timestamp time.Time `json:"timestamp"`
Added []string `json:"added"`
Removed []string `json:"removed"`
Modified []string `json:"modified"`
// List of files added in this commit
Added []string `json:"added"`
// List of files removed in this commit
Removed []string `json:"removed"`
// List of files modified in this commit
Modified []string `json:"modified"`
}
// PayloadCommitVerification represents the GPG verification of a commit
type PayloadCommitVerification struct {
Verified bool `json:"verified"`
Reason string `json:"reason"`
Signature string `json:"signature"`
Signer *PayloadUser `json:"signer"`
Payload string `json:"payload"`
// Whether the commit signature is verified
Verified bool `json:"verified"`
// The reason for the verification status
Reason string `json:"reason"`
// The GPG signature of the commit
Signature string `json:"signature"`
// The user who signed the commit
Signer *PayloadUser `json:"signer"`
// The signed payload content
Payload string `json:"payload"`
}
var (
@@ -119,11 +154,16 @@ var (
// CreatePayload represents a payload information of create event.
type CreatePayload struct {
Sha string `json:"sha"`
Ref string `json:"ref"`
RefType string `json:"ref_type"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
// The SHA hash of the created reference
Sha string `json:"sha"`
// The full name of the created reference
Ref string `json:"ref"`
// The type of reference created (branch or tag)
RefType string `json:"ref_type"`
// The repository where the reference was created
Repo *Repository `json:"repository"`
// The user who created the reference
Sender *User `json:"sender"`
}
// JSONPayload return payload information
@@ -161,11 +201,16 @@ const (
// DeletePayload represents delete payload
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"`
// The name of the deleted reference
Ref string `json:"ref"`
// The type of reference deleted (branch or tag)
RefType string `json:"ref_type"`
// The type of entity that performed the deletion
PusherType PusherType `json:"pusher_type"`
// The repository where the reference was deleted
Repo *Repository `json:"repository"`
// The user who deleted the reference
Sender *User `json:"sender"`
}
// JSONPayload implements Payload
@@ -175,9 +220,12 @@ func (p *DeletePayload) JSONPayload() ([]byte, error) {
// ForkPayload represents fork payload
type ForkPayload struct {
// The forked repository (the new fork)
Forkee *Repository `json:"forkee"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
// The original repository that was forked
Repo *Repository `json:"repository"`
// The user who created the fork
Sender *User `json:"sender"`
}
// JSONPayload implements Payload
@@ -197,14 +245,22 @@ const (
// IssueCommentPayload represents a payload information of issue comment event.
type IssueCommentPayload struct {
Action HookIssueCommentAction `json:"action"`
Issue *Issue `json:"issue"`
PullRequest *PullRequest `json:"pull_request,omitempty"`
Comment *Comment `json:"comment"`
Changes *ChangesPayload `json:"changes,omitempty"`
Repository *Repository `json:"repository"`
Sender *User `json:"sender"`
IsPull bool `json:"is_pull"`
// The action performed on the comment (created, edited, deleted)
Action HookIssueCommentAction `json:"action"`
// The issue that the comment belongs to
Issue *Issue `json:"issue"`
// The pull request if the comment is on a pull request
PullRequest *PullRequest `json:"pull_request,omitempty"`
// The comment that was acted upon
Comment *Comment `json:"comment"`
// Changes made to the comment (for edit actions)
Changes *ChangesPayload `json:"changes,omitempty"`
// The repository containing the issue/pull request
Repository *Repository `json:"repository"`
// The user who performed the action
Sender *User `json:"sender"`
// Whether this comment is on a pull request
IsPull bool `json:"is_pull"`
}
// JSONPayload implements Payload
@@ -224,10 +280,14 @@ const (
// ReleasePayload represents a payload information of release event.
type ReleasePayload struct {
Action HookReleaseAction `json:"action"`
Release *Release `json:"release"`
Repository *Repository `json:"repository"`
Sender *User `json:"sender"`
// The action performed on the release (published, updated, deleted)
Action HookReleaseAction `json:"action"`
// The release that was acted upon
Release *Release `json:"release"`
// The repository containing the release
Repository *Repository `json:"repository"`
// The user who performed the action
Sender *User `json:"sender"`
}
// JSONPayload implements Payload
@@ -237,16 +297,26 @@ func (p *ReleasePayload) JSONPayload() ([]byte, error) {
// PushPayload represents a payload information of push event.
type PushPayload struct {
Ref string `json:"ref"`
Before string `json:"before"`
After string `json:"after"`
CompareURL string `json:"compare_url"`
Commits []*PayloadCommit `json:"commits"`
TotalCommits int `json:"total_commits"`
HeadCommit *PayloadCommit `json:"head_commit"`
Repo *Repository `json:"repository"`
Pusher *User `json:"pusher"`
Sender *User `json:"sender"`
// The full name of the pushed reference
Ref string `json:"ref"`
// The SHA of the most recent commit before the push
Before string `json:"before"`
// The SHA of the most recent commit after the push
After string `json:"after"`
// URL to compare the changes in this push
CompareURL string `json:"compare_url"`
// List of commits included in the push
Commits []*PayloadCommit `json:"commits"`
// Total number of commits in the push
TotalCommits int `json:"total_commits"`
// The most recent commit in the push
HeadCommit *PayloadCommit `json:"head_commit"`
// The repository that was pushed to
Repo *Repository `json:"repository"`
// The user who performed the push
Pusher *User `json:"pusher"`
// The user who triggered the webhook
Sender *User `json:"sender"`
}
// JSONPayload FIXME
@@ -313,13 +383,20 @@ const (
// IssuePayload represents the payload information that is sent along with an issue event.
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"`
CommitID string `json:"commit_id"`
// The action performed on the issue
Action HookIssueAction `json:"action"`
// The index number of the issue
Index int64 `json:"number"`
// Changes made to the issue (for edit actions)
Changes *ChangesPayload `json:"changes,omitempty"`
// The issue that was acted upon
Issue *Issue `json:"issue"`
// The repository containing the issue
Repository *Repository `json:"repository"`
// The user who performed the action
Sender *User `json:"sender"`
// The commit ID related to the issue action
CommitID string `json:"commit_id"`
}
// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces.
@@ -329,27 +406,40 @@ func (p *IssuePayload) JSONPayload() ([]byte, error) {
// ChangesFromPayload FIXME
type ChangesFromPayload struct {
// The previous value before the change
From string `json:"from"`
}
// ChangesPayload represents the payload information of issue change
type ChangesPayload struct {
// Changes made to the title
Title *ChangesFromPayload `json:"title,omitempty"`
Body *ChangesFromPayload `json:"body,omitempty"`
Ref *ChangesFromPayload `json:"ref,omitempty"`
// Changes made to the body/description
Body *ChangesFromPayload `json:"body,omitempty"`
// Changes made to the reference
Ref *ChangesFromPayload `json:"ref,omitempty"`
}
// PullRequestPayload represents a payload information of pull request event.
type PullRequestPayload struct {
Action HookIssueAction `json:"action"`
Index int64 `json:"number"`
Changes *ChangesPayload `json:"changes,omitempty"`
PullRequest *PullRequest `json:"pull_request"`
RequestedReviewer *User `json:"requested_reviewer"`
Repository *Repository `json:"repository"`
Sender *User `json:"sender"`
CommitID string `json:"commit_id"`
Review *ReviewPayload `json:"review"`
// The action performed on the pull request
Action HookIssueAction `json:"action"`
// The index number of the pull request
Index int64 `json:"number"`
// Changes made to the pull request (for edit actions)
Changes *ChangesPayload `json:"changes,omitempty"`
// The pull request that was acted upon
PullRequest *PullRequest `json:"pull_request"`
// The reviewer that was requested (for review request actions)
RequestedReviewer *User `json:"requested_reviewer"`
// The repository containing the pull request
Repository *Repository `json:"repository"`
// The user who performed the action
Sender *User `json:"sender"`
// The commit ID related to the pull request action
CommitID string `json:"commit_id"`
// The review information (for review actions)
Review *ReviewPayload `json:"review"`
}
// JSONPayload FIXME
@@ -359,7 +449,9 @@ func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
// ReviewPayload FIXME
type ReviewPayload struct {
Type string `json:"type"`
// The type of review (approved, rejected, comment)
Type string `json:"type"`
// The content/body of the review
Content string `json:"content"`
}
@@ -377,11 +469,16 @@ const (
// WikiPayload payload for repository webhooks
type WikiPayload struct {
Action HookWikiAction `json:"action"`
Repository *Repository `json:"repository"`
Sender *User `json:"sender"`
Page string `json:"page"`
Comment string `json:"comment"`
// The action performed on the wiki page
Action HookWikiAction `json:"action"`
// The repository containing the wiki
Repository *Repository `json:"repository"`
// The user who performed the action
Sender *User `json:"sender"`
// The name of the wiki page
Page string `json:"page"`
// The comment/commit message for the wiki change
Comment string `json:"comment"`
}
// JSONPayload JSON representation of the payload
@@ -401,10 +498,14 @@ const (
// RepositoryPayload payload for repository webhooks
type RepositoryPayload struct {
Action HookRepoAction `json:"action"`
Repository *Repository `json:"repository"`
Organization *User `json:"organization"`
Sender *User `json:"sender"`
// The action performed on the repository
Action HookRepoAction `json:"action"`
// The repository that was acted upon
Repository *Repository `json:"repository"`
// The organization that owns the repository (if applicable)
Organization *User `json:"organization"`
// The user who performed the action
Sender *User `json:"sender"`
}
// JSONPayload JSON representation of the payload
@@ -424,11 +525,16 @@ const (
// PackagePayload represents a package payload
type PackagePayload struct {
Action HookPackageAction `json:"action"`
Repository *Repository `json:"repository"`
Package *Package `json:"package"`
Organization *Organization `json:"organization"`
Sender *User `json:"sender"`
// The action performed on the package
Action HookPackageAction `json:"action"`
// The repository associated with the package
Repository *Repository `json:"repository"`
// The package that was acted upon
Package *Package `json:"package"`
// The organization that owns the package (if applicable)
Organization *Organization `json:"organization"`
// The user who performed the action
Sender *User `json:"sender"`
}
// JSONPayload implements Payload
@@ -438,11 +544,16 @@ func (p *PackagePayload) JSONPayload() ([]byte, error) {
// WorkflowDispatchPayload represents a workflow dispatch payload
type WorkflowDispatchPayload struct {
Workflow string `json:"workflow"`
Ref string `json:"ref"`
Inputs map[string]any `json:"inputs"`
Repository *Repository `json:"repository"`
Sender *User `json:"sender"`
// The name or path of the workflow file
Workflow string `json:"workflow"`
// The git reference (branch, tag, or commit SHA) to run the workflow on
Ref string `json:"ref"`
// Input parameters for the workflow dispatch event
Inputs map[string]any `json:"inputs"`
// The repository containing the workflow
Repository *Repository `json:"repository"`
// The user who triggered the workflow dispatch
Sender *User `json:"sender"`
}
// JSONPayload implements Payload
@@ -453,18 +564,29 @@ func (p *WorkflowDispatchPayload) JSONPayload() ([]byte, error) {
// CommitStatusPayload represents a payload information of commit status event.
type CommitStatusPayload struct {
// TODO: add Branches per https://docs.github.com/en/webhooks/webhook-events-and-payloads#status
Commit *PayloadCommit `json:"commit"`
Context string `json:"context"`
// The commit that the status is associated with
Commit *PayloadCommit `json:"commit"`
// The context/identifier for this status check
Context string `json:"context"`
// swagger:strfmt date-time
CreatedAt time.Time `json:"created_at"`
Description string `json:"description"`
ID int64 `json:"id"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
SHA string `json:"sha"`
State string `json:"state"`
TargetURL string `json:"target_url"`
// The date and time when the status was created
CreatedAt time.Time `json:"created_at"`
// A short description of the status
Description string `json:"description"`
// The unique identifier of the status
ID int64 `json:"id"`
// The repository containing the commit
Repo *Repository `json:"repository"`
// The user who created the status
Sender *User `json:"sender"`
// The SHA hash of the commit
SHA string `json:"sha"`
// The state of the status (pending, success, error, failure)
State string `json:"state"`
// The target URL to associate with this status
TargetURL string `json:"target_url"`
// swagger:strfmt date-time
// The date and time when the status was last updated
UpdatedAt *time.Time `json:"updated_at"`
}
@@ -475,13 +597,20 @@ func (p *CommitStatusPayload) JSONPayload() ([]byte, error) {
// WorkflowRunPayload represents a payload information of workflow run event.
type WorkflowRunPayload struct {
Action string `json:"action"`
Workflow *ActionWorkflow `json:"workflow"`
WorkflowRun *ActionWorkflowRun `json:"workflow_run"`
PullRequest *PullRequest `json:"pull_request,omitempty"`
Organization *Organization `json:"organization,omitempty"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
// The action performed on the workflow run
Action string `json:"action"`
// The workflow definition
Workflow *ActionWorkflow `json:"workflow"`
// The workflow run that was acted upon
WorkflowRun *ActionWorkflowRun `json:"workflow_run"`
// The pull request associated with the workflow run (if applicable)
PullRequest *PullRequest `json:"pull_request,omitempty"`
// The organization that owns the repository (if applicable)
Organization *Organization `json:"organization,omitempty"`
// The repository containing the workflow
Repo *Repository `json:"repository"`
// The user who triggered the workflow run
Sender *User `json:"sender"`
}
// JSONPayload implements Payload
@@ -491,12 +620,18 @@ func (p *WorkflowRunPayload) JSONPayload() ([]byte, error) {
// WorkflowJobPayload represents a payload information of workflow job event.
type WorkflowJobPayload struct {
Action string `json:"action"`
WorkflowJob *ActionWorkflowJob `json:"workflow_job"`
PullRequest *PullRequest `json:"pull_request,omitempty"`
Organization *Organization `json:"organization,omitempty"`
Repo *Repository `json:"repository"`
Sender *User `json:"sender"`
// The action performed on the workflow job
Action string `json:"action"`
// The workflow job that was acted upon
WorkflowJob *ActionWorkflowJob `json:"workflow_job"`
// The pull request associated with the workflow job (if applicable)
PullRequest *PullRequest `json:"pull_request,omitempty"`
// The organization that owns the repository (if applicable)
Organization *Organization `json:"organization,omitempty"`
// The repository containing the workflow
Repo *Repository `json:"repository"`
// The user who triggered the workflow job
Sender *User `json:"sender"`
}
// JSONPayload implements Payload