webhook

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const SplitSymbol = "&"

Variables

This section is empty.

Functions

func AutoCancelTask

func AutoCancelTask(autoCancelOpt *AutoCancelOpt, log *zap.SugaredLogger) error

func AutoCancelTestTask

func AutoCancelTestTask(autoCancelOpt *AutoCancelOpt, task *task.Task, log *zap.SugaredLogger) error

func AutoCancelWorkflowTask

func AutoCancelWorkflowTask(autoCancelOpt *AutoCancelOpt, task *task.Task, log *zap.SugaredLogger) error

func CodehubGetLatestCommit added in v1.3.0

func CodehubGetLatestCommit(client *codehub.Client, owner, repo string, branch string) (string, string, error)

func ContainsFile

func ContainsFile(h *commonmodels.GitHook, file string) bool

ContainsFile "/" 代表全部文件

func CreateEnvAndTaskByPR

func CreateEnvAndTaskByPR(workflowArgs *commonmodels.WorkflowTaskArgs, prID int, requestID string, log *zap.SugaredLogger) error

CreateEnvAndTaskByPR 根据pr触发创建环境、使用工作流更新该创建的环境、根据环境删除策略删除环境

func EventConfigured

func EventConfigured(m commonmodels.MainHookRepo, event config.HookEventType) bool

func GetAddress added in v1.4.0

func GetAddress(URL string) (string, error)

func GetCodehubServiceTemplates added in v1.3.0

func GetCodehubServiceTemplates() ([]*commonmodels.Service, error)

func GetGerritServiceTemplates

func GetGerritServiceTemplates() ([]*commonmodels.Service, error)

GetGerritServiceTemplates Get all service templates maintained in gerrit

func GetGerritWorkspaceBasePath

func GetGerritWorkspaceBasePath(repoName string) (string, error)

func GetGithubServiceTemplates

func GetGithubServiceTemplates() ([]*commonmodels.Service, error)

func GetGitlabServiceTemplates

func GetGitlabServiceTemplates() ([]*commonmodels.Service, error)

func GetIlyshinServiceTemplates added in v1.4.0

func GetIlyshinServiceTemplates() ([]*commonmodels.Service, error)

func GetOwnerRepoBranchPath

func GetOwnerRepoBranchPath(URL string) (string, string, string, string, string, string, error)

GetOwnerRepoBranchPath 获取gitlab路径中的owner、repo、branch和path

func GitlabGetLatestCommit

func GitlabGetLatestCommit(client *gitlabtool.Client, owner, repo string, ref, path string) (*gitlab.Commit, error)

func GitlabGetRawFiles

func GitlabGetRawFiles(client *gitlabtool.Client, owner, repo, ref, path, pathType string) (files []string, err error)

GitlabGetRawFiles ... projectID: identity of project, can be retrieved from s.GitlabGetProjectID(owner, repo) ref: branch (e.g. master) or commit (commit id) or tag path: file path of raw files, only retrieve leaf node(blob type == file), no recursive get

func IlyshinGetRawFiles added in v1.4.0

func IlyshinGetRawFiles(client *ilyshin.Client, owner, repo, ref, path, pathType string) (files []string, err error)

IlyshinGetRawFiles ...

func InitDiffNote

func InitDiffNote(ev *gitlab.MergeEvent, mainRepo commonmodels.MainHookRepo, log *zap.SugaredLogger) error

InitDiffNote 调用gitlab接口初始化DiffNote,并保存到数据库

func MatchChanges

func MatchChanges(m commonmodels.MainHookRepo, files []string) bool

func ProcessCodehubHook added in v1.3.0

func ProcessCodehubHook(payload []byte, req *http.Request, requestID string, log *zap.SugaredLogger) error

func ProcessGerritHook

func ProcessGerritHook(payload []byte, req *http.Request, requestID string, log *zap.SugaredLogger) error

func ProcessGithubHook

func ProcessGithubHook(payload []byte, req *http.Request, requestID string, log *zap.SugaredLogger) (output string, err error)

func ProcessGithubWebHook

func ProcessGithubWebHook(payload []byte, req *http.Request, requestID string, log *zap.SugaredLogger) error

func ProcessGitlabHook

func ProcessGitlabHook(payload []byte, req *http.Request, requestID string, log *zap.SugaredLogger) error

func ProcessIlyshinHook added in v1.4.0

func ProcessIlyshinHook(payload []byte, req *http.Request, requestID string, log *zap.SugaredLogger) error

func SplitYaml

func SplitYaml(yaml string) []string

func SyncServiceTemplateFromCodehub added in v1.3.0

func SyncServiceTemplateFromCodehub(service *commonmodels.Service, log *zap.SugaredLogger) error

SyncServiceTemplateFromCodehub Force to sync Service Template to latest commit and content, Notes: if remains the same, quit sync; if updates, revision +1

func SyncServiceTemplateFromGerrit

func SyncServiceTemplateFromGerrit(service *commonmodels.Service, log *zap.SugaredLogger) error

SyncServiceTemplateFromGerrit Force to sync Service Template to latest commit and content, Notes: if remains the same, quit sync; if updates, revision +1

func SyncServiceTemplateFromGithub

func SyncServiceTemplateFromGithub(service *commonmodels.Service, latestCommitID, latestCommitMessage string, log *zap.SugaredLogger) error

SyncServiceTemplateFromGithub Force to sync Service Template to latest commit and content, Notes: if remains the same, quit sync; if updates, revision +1

func SyncServiceTemplateFromGitlab

func SyncServiceTemplateFromGitlab(service *commonmodels.Service, log *zap.SugaredLogger) error

SyncServiceTemplateFromGitlab Force to sync Service Template to latest commit and content, Notes: if remains the same, quit sync; if updates, revision +1

func SyncServiceTemplateFromIlyshin added in v1.4.0

func SyncServiceTemplateFromIlyshin(service *commonmodels.Service, log *zap.SugaredLogger) error

SyncServiceTemplateFromIlyshin Force to sync Service Template to latest commit and content, Notes: if remains the same, quit sync; if updates, revision +1

func TriggerPipelineByGitlabEvent

func TriggerPipelineByGitlabEvent(event interface{}, baseURI, requestID string, log *zap.SugaredLogger) error

func TriggerTestByGitlabEvent added in v1.2.0

func TriggerTestByGitlabEvent(event interface{}, baseURI, requestID string, log *zap.SugaredLogger) error

TriggerTestByGitlabEvent 测试管理模块的触发器任务

func TriggerWorkflowByCodehubEvent added in v1.3.0

func TriggerWorkflowByCodehubEvent(event interface{}, baseURI, requestID string, log *zap.SugaredLogger) error

func TriggerWorkflowByGerritEvent

func TriggerWorkflowByGerritEvent(event *gerritTypeEvent, body []byte, uri, baseURI, domain, requestID string, log *zap.SugaredLogger) error

func TriggerWorkflowByGithubEvent

func TriggerWorkflowByGithubEvent(event interface{}, baseURI, deliveryID, requestID string, log *zap.SugaredLogger) error

func TriggerWorkflowByGitlabEvent

func TriggerWorkflowByGitlabEvent(event interface{}, baseURI, requestID string, log *zap.SugaredLogger) error

func TriggerWorkflowByIlyshinEvent added in v1.4.0

func TriggerWorkflowByIlyshinEvent(event interface{}, baseURI, requestID string, log *zap.SugaredLogger) error

func WaitEnvCreate

func WaitEnvCreate(timeoutSeconds int, envName string, workflowArgs *commonmodels.WorkflowTaskArgs, log *zap.SugaredLogger) error

func WaitEnvDelete

func WaitEnvDelete(timeoutSeconds int, envName string, workflowArgs *commonmodels.WorkflowTaskArgs, log *zap.SugaredLogger) error

Types

type AuthorInfo

type AuthorInfo struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Username string `json:"username"`
}

type AutoCancelOpt

type AutoCancelOpt struct {
	MergeRequestID string
	CommitID       string
	TaskType       config.PipelineType
	MainRepo       commonmodels.MainHookRepo
	WorkflowArgs   *commonmodels.WorkflowTaskArgs
	TestArgs       *commonmodels.TestTaskArgs
}

type ChangeInfo

type ChangeInfo struct {
	Project       string    `json:"project"`
	Branch        string    `json:"branch"`
	ID            string    `json:"id"`
	Number        int       `json:"number"`
	Subject       string    `json:"subject"`
	Owner         OwnerInfo `json:"owner"`
	URL           string    `json:"url"`
	CommitMessage string    `json:"commitMessage"`
	CreatedOn     int       `json:"createdOn"`
	Status        string    `json:"status"`
}

type ChangeKeyInfo

type ChangeKeyInfo struct {
	ID string `json:"id"`
}

type CommitInfo

type CommitInfo struct {
	ID        string        `json:"id"`
	Message   string        `json:"message"`
	Timestamp time.Time     `json:"timestamp"`
	URL       string        `json:"url"`
	Author    AuthorInfo    `json:"author"`
	Added     []interface{} `json:"added"`
	Modified  []string      `json:"modified"`
	Removed   []interface{} `json:"removed"`
}

type EventPush

type EventPush struct {
	EventName   string `json:"event_name"`
	Before      string `json:"before"`
	After       string `json:"after"`
	Ref         string `json:"ref"`
	CheckoutSha string `json:"checkout_sha"`
	ProjectID   int    `json:"project_id"`
	Body        string `json:"body"`
}

type GitlabEvent

type GitlabEvent struct {
	ObjectKind        string         `json:"object_kind"`
	EventName         string         `json:"event_name"`
	Before            string         `json:"before"`
	After             string         `json:"after"`
	Ref               string         `json:"ref"`
	CheckoutSha       string         `json:"checkout_sha"`
	Message           interface{}    `json:"message"`
	UserID            int            `json:"user_id"`
	UserName          string         `json:"user_name"`
	UserUsername      string         `json:"user_username"`
	UserEmail         string         `json:"user_email"`
	UserAvatar        string         `json:"user_avatar"`
	ProjectID         int            `json:"project_id"`
	Project           ProjectDetail  `json:"project"`
	Commits           []CommitInfo   `json:"commits"`
	TotalCommitsCount int            `json:"total_commits_count"`
	Repository        RepositoryInfo `json:"repository"`
}

type MatchFolders

type MatchFolders []string

func (MatchFolders) ContainsFile

func (m MatchFolders) ContainsFile(file string) bool

type OwnerInfo

type OwnerInfo struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Username string `json:"username"`
}

type PatchSetInfo

type PatchSetInfo struct {
	Number         int          `json:"number"`
	Revision       string       `json:"revision"`
	Parents        []string     `json:"parents"`
	Ref            string       `json:"ref"`
	Uploader       UploaderInfo `json:"uploader"`
	CreatedOn      int          `json:"createdOn"`
	Author         AuthorInfo   `json:"author"`
	Kind           string       `json:"kind"`
	SizeInsertions int          `json:"sizeInsertions"`
	SizeDeletions  int          `json:"sizeDeletions"`
}

type PipelineHook

type PipelineHook struct {
	PipelineName string
	GitHook      commonmodels.GitHook
}

type ProjectDetail

type ProjectDetail struct {
	ID                int         `json:"id"`
	Name              string      `json:"name"`
	Description       string      `json:"description"`
	WebURL            string      `json:"web_url"`
	AvatarURL         interface{} `json:"avatar_url"`
	GitSSHURL         string      `json:"git_ssh_url"`
	GitHTTPURL        string      `json:"git_http_url"`
	Namespace         string      `json:"namespace"`
	VisibilityLevel   int         `json:"visibility_level"`
	PathWithNamespace string      `json:"path_with_namespace"`
	DefaultBranch     string      `json:"default_branch"`
	CiConfigPath      interface{} `json:"ci_config_path"`
	Homepage          string      `json:"homepage"`
	URL               string      `json:"url"`
	SSHURL            string      `json:"ssh_url"`
	HTTPURL           string      `json:"http_url"`
}

type ProjectInfo

type ProjectInfo struct {
	Name string `json:"name"`
}

type RepositoryInfo

type RepositoryInfo struct {
	Name            string `json:"name"`
	URL             string `json:"url"`
	Description     string `json:"description"`
	Homepage        string `json:"homepage"`
	GitHTTPURL      string `json:"git_http_url"`
	GitSSHURL       string `json:"git_ssh_url"`
	VisibilityLevel int    `json:"visibility_level"`
}

type SubmitterInfo

type SubmitterInfo struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Username string `json:"username"`
}

type UploaderInfo

type UploaderInfo struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Username string `json:"username"`
}

Jump to

Keyboard shortcuts

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