Documentation ¶
Index ¶
Constants ¶
View Source
const (
// CloudEventsFormat is the type for CloudEvents format.
CloudEventsFormat = "CloudEvents"
)
View Source
const (
// DefaultFormat is the type for default format.
DefaultFormat = "Default"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudEvents ¶
type CloudEvents struct{}
CloudEvents is the instance for the CloudEvents format.
func (*CloudEvents) Format ¶
func (ce *CloudEvents) Format(ctx context.Context, he *model.HookEvent) (http.Header, []byte, error)
Format implements the interface Formatter.
{ "specversion":"1.0", "requestid": "2eedfab8-61d3-4f3c-8ec3-8f82d1ec4c84", "id":"4b2f89a6-548d-4c12-9993-a1f5790b97d2", "source":"/projects/1/webhook/policies/3", "type":"harbor.artifact.pulled", "datacontenttype":"application/json", "time":"2023-03-06T06:08:43Z", "data":{ "resources":[ { "digest":"sha256:dde8e930c7b6a490f728e66292bc9bce42efc9bbb5278bae40e4f30f6e00fe8c", "tag":"sha256:dde8e930c7b6a490f728e66292bc9bce42efc9bbb5278bae40e4f30f6e00fe8c", "resource_url":"harbor.dev/library/busybox@sha256:dde8e930c7b6a490f728e66292bc9bce42efc9bbb5278bae40e4f30f6e00fe8c" } ], "repository":{ "date_created":1677053165, "name":"busybox", "namespace":"library", "repo_full_name":"library/busybox", "repo_type":"public" } }, "operator":"robot$library+scanner-Trivy-51fe4548-bbe5-11ed-9217-0242ac14000d" }
type Default ¶
type Default struct{}
Default is the instance for default format(original format in previous versions).
func (*Default) Format ¶
Format implements the interface Formatter.
{ "type":"PULL_ARTIFACT", "occur_at":1678082303, "operator":"admin", "event_data":{ "resources":[ { "digest":"sha256:dde8e930c7b6a490f728e66292bc9bce42efc9bbb5278bae40e4f30f6e00fe8c", "tag":"sha256:dde8e930c7b6a490f728e66292bc9bce42efc9bbb5278bae40e4f30f6e00fe8c", "resource_url":"harbor.dev/library/busybox@sha256:dde8e930c7b6a490f728e66292bc9bce42efc9bbb5278bae40e4f30f6e00fe8c" } ], "repository":{ "date_created":1677053165, "name":"busybox", "namespace":"library", "repo_full_name":"library/busybox", "repo_type":"public" } } }
type Formatter ¶
type Formatter interface { // Format formats the data to expected format and return request headers and encoded payload Format(context.Context, *model.HookEvent) (http.Header, []byte, error) }
Formatter is the interface for event which for implementing different drivers to organize their customize data format.
func GetFormatter ¶
GetFormatter returns corresponding formatter from format type.
Click to show internal directories.
Click to hide internal directories.