Documentation ¶
Index ¶
- Constants
- Variables
- func Format(eventContent interface{}) (string, error)
- func MakeSureBuiltinHooks(impl *WebHookImpl) error
- type CreateHookRequest
- type CreateHookResponse
- type EditHookRequest
- type EditHookResponse
- type EventLabel
- type EventMessage
- type Hook
- type HookLocation
- type InspectHookResponse
- type ListHookEventsResponse
- type ListHooksResponse
- type WebHookHTTP
- func (w *WebHookHTTP) CheckPermission(ctx context.Context, orgIdStr, projectIdStr, applicationIdStr string) error
- func (w *WebHookHTTP) CreateHook(ctx context.Context, req *pb.CreateHookRequest, vars map[string]string) (*pb.CreateHookResponse, error)
- func (w *WebHookHTTP) DeleteHook(ctx context.Context, req *pb.DeleteHookRequest, vars map[string]string) (*pb.DeleteHookResponse, error)
- func (w *WebHookHTTP) EditHook(ctx context.Context, req *pb.EditHookRequest, vars map[string]string) (*pb.EditHookResponse, error)
- func (w *WebHookHTTP) InspectHook(ctx context.Context, req *pb.InspectHookRequest, vars map[string]string) (*pb.InspectHookResponse, error)
- func (w *WebHookHTTP) ListHookEvents(ctx context.Context, req *pb.ListHookEventsRequest, vars map[string]string) (*pb.ListHookEventsResponse, error)
- func (w *WebHookHTTP) ListHooks(ctx context.Context, req *pb.ListHooksRequest, vars map[string]string) (*pb.ListHooksResponse, error)
- func (w *WebHookHTTP) PingHook(ctx context.Context, req *pb.PingHookRequest, vars map[string]string) (*pb.PingHookResponse, error)
- type WebHookImpl
- func (w *WebHookImpl) CreateHook(realOrg string, h CreateHookRequest) (CreateHookResponse, error)
- func (w *WebHookImpl) DeleteHook(realOrg, id string) error
- func (w *WebHookImpl) EditHook(realOrg, id string, e EditHookRequest) (EditHookResponse, error)
- func (w *WebHookImpl) InspectHook(realOrg, id string) (InspectHookResponse, error)
- func (w *WebHookImpl) ListHooks(location HookLocation) (ListHooksResponse, error)
- func (w *WebHookImpl) PingHook(realOrg, id string) error
- func (w *WebHookImpl) SearchHooks(location HookLocation, event string) []Hook
Constants ¶
View Source
const ( BadRequestCode = "WH400" InternalServerErrCode = "WH500" OtherErrCode = "WH600" )
Variables ¶
View Source
var ( // ErrNoEventField event 消息中没有 'event' 字段 ErrNoEventField = errors.New("not found 'event' field") // ErrInvalidEvent 'event' 字段内容不是 string 类型 ErrInvalidEvent = errors.New("invalid 'event' type") // ErrNoFormat 在 fmtMap 没有对应的格式 ErrNoFormat = errors.New("not found related format") )
EXAMPLE pipeline event json
{ "action": "B_CREATE", "applicationID": "178", "content": { "kind": "B_CREATE", "operator": "10672", "pipeline": { "applicationID": 178, "applicationName": "dice", "basePipelineID": 4847, "branch": "develop", "clusterName": "terminus-y", "commit": "bc6410f8e3282e6e5d667551013efac0ded79491", "commitDetail": { "author": "郑嘉涛", "comment": "Merge branch 'feature/org-switch' into 'develop'\n\nfeature: org switch\n\nSee merge request !1645", "email": "ef@terminus.io", "repo": "http://gittar.app.terminus.io/dcos-terminus/dice", "repoAbbr": "dcos-terminus/dice", "time": "2019-03-13T10:41:01+08:00" }, "costTimeSec": -1, "cronID": null, "extra": { "callbackURLs": null, "configManageNamespaceOfSecrets": "pipeline-secrets-app-178-develop", "configManageNamespaceOfSecretsDefault": "pipeline-secrets-app-178-default", "cronTriggerTime": "0001-01-01T00:00:00Z", "diceWorkspace": "TEST", "isAutoRun": true, "submitUser": { "avatar": "", "id": 10672, "name": "姜政冬" } }, "id": 6461, "orgID": 2, "orgName": "terminus", "pipelineYml": "...", "pipelineYmlName": "pipeline.yml", "pipelineYmlSource": "content", "projectID": 70, "projectName": "dice", "snapshot": {}, "source": "qa", "status": "Analyzed", "timeBegin": "0001-01-01T00:00:00Z", "timeCreated": "2019-03-13T10:43:47.945103124+08:00", "timeEnd": "0001-01-01T00:00:00Z", "timeUpdated": "2019-03-13T10:43:48.035938235+08:00", "triggerMode": "manual", "type": "normal" } }, "env": "", "event": "pipeline", "orgID": "2", "projectID": "70", "timestamp": "2019-03-13 10:43:49" }
View Source
var BadRequestErr = errors.New("bad request input")
View Source
var InternalServerErr = errors.New("internal server error")
Functions ¶
func MakeSureBuiltinHooks ¶
func MakeSureBuiltinHooks(impl *WebHookImpl) error
MakeSureBuiltinHooks 创建默认 webhook (如果不存在)
Types ¶
type CreateHookRequest ¶
type CreateHookRequest = apistructs.CreateHookRequest
type CreateHookResponse ¶
type CreateHookResponse = apistructs.WebhookCreateResponseData
type EditHookRequest ¶
type EditHookRequest = apistructs.WebhookUpdateRequestBody
type EditHookResponse ¶
type EditHookResponse = apistructs.WebhookUpdateResponseData
type EventLabel ¶
type EventLabel = apistructs.EventHeader
type EventMessage ¶
type EventMessage struct { Event string `json:"event"` Action string `json:"action"` OrgID string `json:"orgID"` ProjectID string `json:"projectID"` ApplicationID string `json:"applicationID"` Env string `json:"env"` // content 结构跟具体 event 相关 Content json.RawMessage `json:"content"` TimeStamp string `json:"timestamp"` }
message which response to hooked url
func MkEventMessage ¶
func MkEventMessage(label EventLabel, content []byte) EventMessage
type Hook ¶
type Hook = apistructs.Hook
type HookLocation ¶
type HookLocation = apistructs.HookLocation
type InspectHookResponse ¶
type InspectHookResponse = apistructs.WebhookInspectResponseData
type ListHookEventsResponse ¶
type ListHookEventsResponse = apistructs.WebhookListEventsResponseData
type ListHooksResponse ¶
type ListHooksResponse = apistructs.WebhookListResponseData
type WebHookHTTP ¶
type WebHookHTTP struct { CoreService legacy.ExposedInterface // contains filtered or unexported fields }
func NewWebHookHTTP ¶
func NewWebHookHTTP() (*WebHookHTTP, error)
func (*WebHookHTTP) CheckPermission ¶
func (w *WebHookHTTP) CheckPermission(ctx context.Context, orgIdStr, projectIdStr, applicationIdStr string) error
func (*WebHookHTTP) CreateHook ¶
func (w *WebHookHTTP) CreateHook(ctx context.Context, req *pb.CreateHookRequest, vars map[string]string) (*pb.CreateHookResponse, error)
org, project will be provided in request body
func (*WebHookHTTP) DeleteHook ¶
func (w *WebHookHTTP) DeleteHook(ctx context.Context, req *pb.DeleteHookRequest, vars map[string]string) (*pb.DeleteHookResponse, error)
func (*WebHookHTTP) EditHook ¶
func (w *WebHookHTTP) EditHook(ctx context.Context, req *pb.EditHookRequest, vars map[string]string) (*pb.EditHookResponse, error)
func (*WebHookHTTP) InspectHook ¶
func (w *WebHookHTTP) InspectHook(ctx context.Context, req *pb.InspectHookRequest, vars map[string]string) (*pb.InspectHookResponse, error)
func (*WebHookHTTP) ListHookEvents ¶
func (w *WebHookHTTP) ListHookEvents(ctx context.Context, req *pb.ListHookEventsRequest, vars map[string]string) (*pb.ListHookEventsResponse, error)
func (*WebHookHTTP) ListHooks ¶
func (w *WebHookHTTP) ListHooks(ctx context.Context, req *pb.ListHooksRequest, vars map[string]string) (*pb.ListHooksResponse, error)
func (*WebHookHTTP) PingHook ¶
func (w *WebHookHTTP) PingHook(ctx context.Context, req *pb.PingHookRequest, vars map[string]string) (*pb.PingHookResponse, error)
type WebHookImpl ¶
type WebHookImpl struct {
// contains filtered or unexported fields
}
func NewWebHookImpl ¶
func NewWebHookImpl() (*WebHookImpl, error)
func (*WebHookImpl) CreateHook ¶
func (w *WebHookImpl) CreateHook(realOrg string, h CreateHookRequest) (CreateHookResponse, error)
func (*WebHookImpl) DeleteHook ¶
func (w *WebHookImpl) DeleteHook(realOrg, id string) error
func (*WebHookImpl) EditHook ¶
func (w *WebHookImpl) EditHook(realOrg, id string, e EditHookRequest) (EditHookResponse, error)
func (*WebHookImpl) InspectHook ¶
func (w *WebHookImpl) InspectHook(realOrg, id string) (InspectHookResponse, error)
func (*WebHookImpl) ListHooks ¶
func (w *WebHookImpl) ListHooks(location HookLocation) (ListHooksResponse, error)
ListHooks 列出符合 location 的 hook 列表。
func (*WebHookImpl) PingHook ¶
func (w *WebHookImpl) PingHook(realOrg, id string) error
func (*WebHookImpl) SearchHooks ¶
func (w *WebHookImpl) SearchHooks(location HookLocation, event string) []Hook
search hooks which include 'event' and is 'active'
Click to show internal directories.
Click to hide internal directories.