webhook

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 57 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 AutoCancelWorkflowV4Task added in v1.9.9

func AutoCancelWorkflowV4Task(autoCancelOpt *AutoCancelOpt, 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 ConvertScanningHookToMainHookRepo added in v1.9.9

func ConvertScanningHookToMainHookRepo(hook *types.ScanningHook) *commonmodels.MainHookRepo

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 GetGiteeServiceTemplates added in v1.9.9

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

GetGiteeServiceTemplates Get all service templates maintained in gitee

func GetGithubServiceTemplates

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

func GetGitlabServiceTemplates

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

func GetOwnerRepoBranchPath

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

GetOwnerRepoBranchPath 获取gitlab路径中的owner、repo、branch和path return address, owner, repo, branch, path, pathType Note this function needs be optimized badly!

func GetWorkspaceBasePath added in v1.9.9

func GetWorkspaceBasePath(repoName string) (string, error)

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 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 ProcessGiteeHook added in v1.9.9

func ProcessGiteeHook(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) (string, error)

func ProcessGithubWebHook

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

func ProcessGithubWebHookForTest added in v1.8.0

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

func ProcessGithubWebHookForWorkflowV4 added in v1.9.9

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

func ProcessGithubWebhookForScanning added in v1.9.9

func ProcessGithubWebhookForScanning(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 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 the latest commit and content, Notes: if remains the same, quit sync; if updates, revision +1

func SyncServiceTemplateFromGitee added in v1.9.9

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

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 TriggerPipelineByGitlabEvent

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

func TriggerScanningByGithubEvent added in v1.9.9

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

func TriggerScanningByGitlabEvent added in v1.9.9

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

func TriggerTestByGiteeEvent added in v1.9.9

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

func TriggerTestByGithubEvent added in v1.8.0

func TriggerTestByGithubEvent(event interface{}, 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 TriggerWorkflowByGiteeEvent added in v1.9.9

func TriggerWorkflowByGiteeEvent(event interface{}, baseURI, 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 TriggerWorkflowV4ByGerritEvent added in v1.9.9

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

func TriggerWorkflowV4ByGiteeEvent added in v1.9.9

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

func TriggerWorkflowV4ByGithubEvent added in v1.9.9

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

func TriggerWorkflowV4ByGitlabEvent added in v1.9.9

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

func UpdateWorkflowTaskArgs added in v1.8.0

func UpdateWorkflowTaskArgs(triggerYaml *TriggerYaml, workflow *commonmodels.Workflow, workFlowArgs *commonmodels.WorkflowTaskArgs, item *commonmodels.WorkflowHook, branref string, prId int) 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
	IsYaml         bool
	AutoCancel     bool
	YamlHookPath   string
	WorkflowName   string
}

type Build added in v1.8.0

type Build struct {
	Services []*BuildServices `yaml:"services"`
}

type BuildServices added in v1.8.0

type BuildServices struct {
	Name          string       `yaml:"name"`
	ServiceModule string       `yaml:"service_module"`
	Variables     []*Variables `yaml:"variables"`
}

func ServicesMatchChangesFiles added in v1.8.0

func ServicesMatchChangesFiles(mf *MatchFoldersElem, files []string) []BuildServices

type CacheSet added in v1.8.0

type CacheSet struct {
	IgnoreCache bool `yaml:"ignore_cache"`
	ResetCache  bool `yaml:"reset_cache"`
}

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 Deploy added in v1.8.0

type Deploy struct {
	Strategy         DeployStrategy   `yaml:"strategy"`
	Envsname         []string         `yaml:"envs_name"`
	EnvRecyclePolicy EnvRecyclePolicy `yaml:"env_recycle_policy"`
	BaseNamespace    string           `yaml:"base_env"`
}

Strategy

 single:
	Update to the specified environment;
 dynamic:
	Dynamic selection of idle environment;
 base:
	Create a new environment based on the baseline environment
	And Need to set EnvRecyclePolicy:success/always/never

type DeployStrategy added in v1.9.9

type DeployStrategy string
const (
	DeployStrategySingle  DeployStrategy = "single"
	DeployStrategyDynamic DeployStrategy = "dynamic"
	DeployStrategyBase    DeployStrategy = "base"
)

type EnvRecyclePolicy added in v1.9.9

type EnvRecyclePolicy string
const (
	EnvRecyclePolicySuccess EnvRecyclePolicy = "success"
	EnvRecyclePolicyAlways  EnvRecyclePolicy = "always"
	EnvRecyclePolicyNever   EnvRecyclePolicy = "never"
)

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 MatchFoldersElem added in v1.8.0

type MatchFoldersElem struct {
	MatchSwitch          string              `yaml:"match_switch"`
	MatchFoldersTree     []*MatchFoldersTree `yaml:"match_folders_tree"`
	MatchFoldersSpecific string              `yaml:"match_folders_specific"`
}

type MatchFoldersTree added in v1.8.0

type MatchFoldersTree struct {
	Name          string   `yaml:"name"`
	ServiceModule string   `yaml:"service_module"`
	FileTree      []string `yaml:"file_tree"`
}

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 Repo added in v1.8.0

type Repo struct {
	Strategy TestRepoStrategy `yaml:"strategy"`
}

Strategy

 default:
	Code repository information configured by default on the zadig platform
 currentRepo:
	Use current changed code information

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 Rules added in v1.8.0

type Rules struct {
	Branchs      []string               `yaml:"branchs"`
	Events       []config.HookEventType `yaml:"events"`
	Strategy     *StrategyRules         `yaml:"strategy"`
	MatchFolders *MatchFoldersElem      `yaml:"match_folders"`
}

type Stage added in v1.9.9

type Stage string
const (
	StageBuild  Stage = "build"
	StageDeploy Stage = "deploy"
	StageTest   Stage = "test"
)

type StrategyRules added in v1.8.0

type StrategyRules struct {
	AutoCancel bool `yaml:"auto_cancel"`
}

type SubmitterInfo

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

type Test added in v1.8.0

type Test struct {
	Name      string       `yaml:"name"`
	Repo      *Repo        `yaml:"repo"`
	Variables []*Variables `yaml:"variables"`
}

type TestRepoStrategy added in v1.9.9

type TestRepoStrategy string
const (
	TestRepoStrategyDefault     TestRepoStrategy = "default"
	TestRepoStrategyCurrentRepo TestRepoStrategy = "currentRepo"
)

type TriggerYaml added in v1.8.0

type TriggerYaml struct {
	Stages   []Stage          `yaml:"stages"`
	Build    []*BuildServices `yaml:"build"`
	Deploy   *Deploy          `yaml:"deploy"`
	Test     []*Test          `yaml:"test"`
	Rules    *Rules           `yaml:"rules"`
	CacheSet *CacheSet        `yaml:"cache_set"`
}

type UploaderInfo

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

type Variables added in v1.8.0

type Variables struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

Jump to

Keyboard shortcuts

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